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