Skip to content

Commit 0b07516

Browse files
committed
Merge commit 'e62239d24f1ded0ef5ca3c6fcacb82667cb6f3ea' as 'src/note-c'
2 parents dd118e7 + e62239d commit 0b07516

File tree

234 files changed

+50229
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

234 files changed

+50229
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Container with dependencies necessary to run note-c unit tests.
2+
3+
# Build development environment
4+
# $ docker build . --tag note_c_run_unit_tests
5+
6+
# Launch development environment (mount source root as /note-c/)
7+
# $ docker run --rm --volume $(pwd)/../../../:/note-c/ --workdir /note-c/ note_c_run_unit_tests
8+
9+
# Global Argument(s)
10+
ARG DEBIAN_FRONTEND="noninteractive"
11+
ARG UID=1000
12+
ARG USER="blues"
13+
14+
# POSIX compatible (Linux/Unix) base image.
15+
FROM --platform=linux/amd64 debian:stable-slim
16+
17+
# Import Global Argument(s)
18+
ARG DEBIAN_FRONTEND
19+
ARG UID
20+
ARG USER
21+
22+
# Local Argument(s)
23+
24+
# Local Environment Variable(s)
25+
ENV LC_ALL="C.UTF-8"
26+
27+
# Create Non-Root User
28+
RUN ["dash", "-c", "\
29+
addgroup \
30+
--gid ${UID} \
31+
\"${USER}\" \
32+
&& adduser \
33+
--disabled-password \
34+
--gecos \"\" \
35+
--ingroup \"${USER}\" \
36+
--uid ${UID} \
37+
\"${USER}\" \
38+
&& usermod \
39+
--append \
40+
--groups \"dialout,plugdev\" \
41+
\"${USER}\" \
42+
"]
43+
44+
# Add 32-bit binaries to the index.
45+
RUN ["dash", "-c", "\
46+
dpkg --add-architecture i386 \
47+
"]
48+
49+
# Install whatever dependencies we can via apt-get.
50+
RUN ["dash", "-c", "\
51+
apt-get update --quiet \
52+
&& apt-get install --assume-yes --no-install-recommends --quiet \
53+
astyle \
54+
ca-certificates \
55+
curl \
56+
g++ \
57+
g++-multilib \
58+
gcc \
59+
gcc-multilib \
60+
gdb \
61+
git \
62+
lcov \
63+
libc6-dbg:i386 \
64+
make \
65+
nano \
66+
python3-pip \
67+
python3-sphinx \
68+
cppcheck \
69+
valgrind \
70+
&& pip install --break-system-packages \
71+
breathe \
72+
sphinx-rtd-theme \
73+
&& apt-get clean \
74+
&& apt-get purge \
75+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
76+
"]
77+
78+
# Download and install Doxygen 1.9.8. Currently, the version of Doxygen that
79+
# gets installed via apt-get doesn't have support FAIL_ON_WARNINGS_PRINT for the
80+
# WARN_AS_ERROR config option (added in 1.9.7).
81+
RUN ["dash", "-c", "\
82+
curl -LO https://github.com/doxygen/doxygen/releases/download/Release_1_9_8/doxygen-1.9.8.linux.bin.tar.gz \
83+
&& tar xf doxygen-1.9.8.linux.bin.tar.gz \
84+
&& cd doxygen-1.9.8 \
85+
&& make INSTALL=/usr install \
86+
&& cd .. \
87+
&& rm doxygen-1.9.8.linux.bin.tar.gz \
88+
&& rm -rf doxygen-1.9.8 \
89+
"]
90+
91+
# Download and install CMake v3.25.1. We need CMake v3.20+ in order to get the
92+
# ctest --test-dir option used by run_unit_tests.sh.
93+
RUN ["dash", "-c", "\
94+
curl -LO https://github.com/Kitware/CMake/releases/download/v3.25.1/cmake-3.25.1-linux-x86_64.tar.gz \
95+
&& tar xf cmake-3.25.1-linux-x86_64.tar.gz --strip-components=1 -C /usr \
96+
&& rm cmake-3.25.1-linux-x86_64.tar.gz \
97+
"]
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.205.2/containers/docker-existing-dockerfile
3+
{
4+
"name": "Continuous Integration Development Environment Dockerfile",
5+
6+
// Sets the run context to one level up instead of the .devcontainer folder.
7+
"context": "${localWorkspaceFolder}",
8+
9+
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
10+
"image": "ghcr.io/blues/note_c_ci:latest",
11+
// "dockerFile": "Dockerfile",
12+
13+
// Set *default* container specific settings.json values on container create.
14+
"settings": {},
15+
16+
// Add the IDs of extensions you want installed when the container is created.
17+
"extensions": [
18+
"matepek.vscode-catch2-test-adapter",
19+
"ms-vscode.cpptools",
20+
"shardulm94.trailing-spaces",
21+
"twxs.cmake"
22+
],
23+
24+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
25+
// "forwardPorts": [],
26+
27+
// Uncomment the next line to run commands after the container is created - for example installing curl.
28+
// "postCreateCommand": "apt-get update && apt-get install -y curl",
29+
30+
// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
31+
// "runArgs": [
32+
// "--device=/dev/bus/usb/"
33+
// ],
34+
35+
// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
36+
// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
37+
38+
// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
39+
"remoteUser": "blues"
40+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: 'Load note-c CI Docker image'
2+
runs:
3+
using: 'composite'
4+
steps:
5+
- name: Set up Docker Buildx
6+
uses: docker/setup-buildx-action@v2
7+
8+
- name: Download image artifact
9+
uses: actions/download-artifact@v4
10+
with:
11+
name: note_c_ci_image
12+
path: /tmp
13+
14+
- name: Load Docker image
15+
shell: bash
16+
run: |
17+
docker load --input /tmp/note_c_ci_image.tar

src/note-c/.github/workflows/ci.yml

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
name: note-c CI Pipeline
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
check_dockerfile_changed:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
changed: ${{ steps.filter.outputs.changed }}
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
# TODO: This is a 3rd party GitHub action from some dude. Ideally, we'd
20+
# use something more "official".
21+
- name: Check if Dockerfile changed
22+
uses: dorny/paths-filter@v2
23+
id: filter
24+
with:
25+
base: 'master'
26+
filters: |
27+
changed:
28+
- '.devcontainer/ci/Dockerfile'
29+
30+
build_ci_docker_image:
31+
runs-on: ubuntu-latest
32+
needs: [check_dockerfile_changed]
33+
if: ${{ needs.check_dockerfile_changed.outputs.changed == 'true' }}
34+
35+
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@v4
38+
39+
- name: Login to GitHub Container Registry
40+
uses: docker/login-action@v2
41+
with:
42+
registry: ghcr.io
43+
username: ${{ github.actor }}
44+
password: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Set up Docker Buildx
47+
uses: docker/setup-buildx-action@v2
48+
49+
- name: Rebuild image
50+
uses: docker/build-push-action@v4
51+
with:
52+
context: .
53+
file: .devcontainer/ci/Dockerfile
54+
load: true
55+
tags: ghcr.io/blues/note_c_ci:latest
56+
outputs: type=docker,dest=/tmp/note_c_ci_image.tar
57+
58+
- name: Upload image artifact
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: note_c_ci_image
62+
path: /tmp/note_c_ci_image.tar
63+
64+
build_docs:
65+
runs-on: ubuntu-latest
66+
if: ${{ always() }}
67+
needs: [build_ci_docker_image]
68+
69+
steps:
70+
- name: Checkout code
71+
uses: actions/checkout@v4
72+
73+
- name: Load CI Docker image
74+
# Only load the Docker image artifact if build_ci_docker_image actually
75+
# ran (e.g. it wasn't skipped and was successful).
76+
if: ${{ needs.build_ci_docker_image.result == 'success' }}
77+
uses: ./.github/actions/load-ci-image
78+
79+
- name: Build docs
80+
run: |
81+
docker run --rm --volume $(pwd):/note-c/ --workdir /note-c/ --entrypoint ./scripts/build_docs.sh ghcr.io/blues/note_c_ci:latest
82+
83+
check_libc_dependencies:
84+
runs-on: ubuntu-latest
85+
if: ${{ always() }}
86+
needs: [build_ci_docker_image]
87+
88+
steps:
89+
- name: Checkout code
90+
uses: actions/checkout@v4
91+
92+
- name: Load CI Docker image
93+
# Only load the Docker image artifact if build_ci_docker_image actually
94+
# ran (e.g. it wasn't skipped and was successful).
95+
if: ${{ needs.build_ci_docker_image.result == 'success' }}
96+
uses: ./.github/actions/load-ci-image
97+
98+
- name: Check note-c's libc dependencies
99+
run: |
100+
docker run --rm --volume $(pwd):/note-c/ --workdir /note-c/ --entrypoint ./scripts/check_libc_dependencies.sh ghcr.io/blues/note_c_ci:latest
101+
102+
run_unit_tests:
103+
runs-on: ubuntu-latest
104+
if: ${{ always() }}
105+
needs: [build_ci_docker_image]
106+
107+
steps:
108+
- name: Checkout code
109+
uses: actions/checkout@v4
110+
111+
- name: Load CI Docker image
112+
# Only load the Docker image artifact if build_ci_docker_image actually
113+
# ran (e.g. it wasn't skipped and was successful).
114+
if: ${{ needs.build_ci_docker_image.result == 'success' }}
115+
uses: ./.github/actions/load-ci-image
116+
117+
- name: Run tests
118+
run: |
119+
docker run --rm --volume $(pwd):/note-c/ \
120+
--workdir /note-c/ \
121+
--entrypoint ./scripts/run_unit_tests.sh \
122+
--user root \
123+
ghcr.io/blues/note_c_ci:latest --coverage --mem-check
124+
125+
- name: Adjust lcov source file paths for Coveralls
126+
run: sudo sed -i 's/\/note-c\///g' ./build/test/coverage/lcov.info
127+
128+
- name: Publish test coverage
129+
uses: coverallsapp/github-action@master
130+
with:
131+
github-token: ${{ secrets.GITHUB_TOKEN }}
132+
path-to-lcov: ./build/test/coverage/lcov.info
133+
134+
run_low_mem_unit_tests:
135+
runs-on: ubuntu-latest
136+
if: ${{ always() }}
137+
needs: [build_ci_docker_image]
138+
139+
steps:
140+
- name: Checkout code
141+
uses: actions/checkout@v4
142+
143+
- name: Load CI Docker image
144+
# Only load the Docker image artifact if build_ci_docker_image actually
145+
# ran (e.g. it wasn't skipped and was successful).
146+
if: ${{ needs.build_ci_docker_image.result == 'success' }}
147+
uses: ./.github/actions/load-ci-image
148+
149+
- name: Run tests with NOTE_LOWMEM defined
150+
run: |
151+
docker run --rm --volume $(pwd):/note-c/ --workdir /note-c/ --entrypoint ./scripts/run_unit_tests.sh ghcr.io/blues/note_c_ci:latest --mem-check --low-mem --single-precision
152+
153+
run_astyle:
154+
runs-on: ubuntu-latest
155+
if: ${{ always() }}
156+
needs: [build_ci_docker_image]
157+
158+
steps:
159+
- name: Checkout code
160+
uses: actions/checkout@v4
161+
162+
- name: Load CI Docker image
163+
# Only load the Docker image artifact if build_ci_docker_image actually
164+
# ran (e.g. it wasn't skipped and was successful).
165+
if: ${{ needs.build_ci_docker_image.result == 'success' }}
166+
uses: ./.github/actions/load-ci-image
167+
168+
- name: Run astyle
169+
run: |
170+
docker run --rm --volume $(pwd):/note-c/ --workdir /note-c/ --entrypoint ./scripts/run_astyle.sh ghcr.io/blues/note_c_ci:latest
171+
172+
run_cppcheck:
173+
runs-on: ubuntu-latest
174+
if: ${{ always() }}
175+
needs: [build_ci_docker_image]
176+
177+
steps:
178+
- name: Checkout code
179+
uses: actions/checkout@v4
180+
181+
- name: Load CI Docker image
182+
# Only load the Docker image artifact if build_ci_docker_image actually
183+
# ran (e.g. it wasn't skipped and was successful).
184+
if: ${{ needs.build_ci_docker_image.result == 'success' }}
185+
uses: ./.github/actions/load-ci-image
186+
187+
- name: Run cppcheck
188+
run: |
189+
docker run --rm --volume $(pwd):/note-c/ --workdir /note-c/ --entrypoint ./scripts/run_cppcheck.sh ghcr.io/blues/note_c_ci:latest
190+
191+
publish_ci_image:
192+
runs-on: ubuntu-latest
193+
# Make sure unit tests unit tests passed before publishing.
194+
needs: [build_ci_docker_image, run_unit_tests]
195+
# Only publish the image if this is a push event and the Docker image was rebuilt
196+
if: ${{ github.event_name == 'push' && needs.build_ci_docker_image.result == 'success' }}
197+
198+
steps:
199+
- name: Login to GitHub Container Registry
200+
uses: docker/login-action@v2
201+
with:
202+
registry: ghcr.io
203+
username: ${{ github.actor }}
204+
password: ${{ secrets.GITHUB_TOKEN }}
205+
206+
- name: Set up Docker Buildx
207+
uses: docker/setup-buildx-action@v2
208+
209+
- name: Push image to registry
210+
uses: docker/build-push-action@v4
211+
with:
212+
push: true
213+
tags: ghcr.io/blues/note_c_ci:latest

0 commit comments

Comments
 (0)