GitHub CI: update list of container images
[tinc] / .github / workflows / test.yml
1 name: Test
2
3 concurrency:
4   group: test-${{ github.head_ref }}
5   cancel-in-progress: true
6
7 on:
8   push:
9   pull_request:
10     types:
11       - opened
12       - synchronize
13
14 jobs:
15   cross:
16     runs-on: ubuntu-22.04
17     timeout-minutes: 30
18     strategy:
19       fail-fast: false
20       matrix:
21         arch:
22           - armhf
23           - mipsel
24           - mingw
25
26     container:
27       image: debian:stable
28       options: --privileged
29
30     steps:
31       - name: Checkout code
32         uses: actions/checkout@v1
33
34       - name: Install deps
35         run: HOST=${{ matrix.arch }} sh .ci/deps.sh
36
37       - name: Prepare the system
38         run: HOST=${{ matrix.arch }} sh .ci/test/prepare.sh
39
40       - name: Run tests with default settings
41         run: sudo -u build CI=1 HOST=${{ matrix.arch }} sh .ci/test/run.sh default
42
43       - name: Run tests without legacy protocol
44         run: sudo -u build CI=1 HOST=${{ matrix.arch }} sh .ci/test/run.sh nolegacy
45         if: always()
46
47       - name: Run tests with libgcrypt
48         run: sudo -u build CI=1 HOST=${{ matrix.arch }} sh .ci/test/run.sh gcrypt
49         if: always()
50
51       - name: Upload test results
52         uses: actions/upload-artifact@v2
53         with:
54           name: tests_cross_${{ matrix.arch }}
55           path: /tmp/logs/tests.*.tar.gz
56         if: always()
57
58   muon:
59     runs-on: ubuntu-22.04
60     timeout-minutes: 20
61     container:
62       image: debian:stable-slim
63       env:
64         CI: 1
65
66     steps:
67       - name: Checkout code
68         uses: actions/checkout@v1
69
70       - name: Install dependencies
71         run: SKIP_OPENSSL3=1 SKIP_MESON=1 .ci/deps.sh libpkgconf-dev
72
73       - name: Compatibility with muon
74         run: ./.ci/muon/run.sh
75
76   analysis:
77     runs-on: ubuntu-22.04
78     timeout-minutes: 30
79     steps:
80       - name: Checkout tinc
81         uses: actions/checkout@v3
82         with:
83           fetch-depth: 0
84
85       - name: Install dependencies
86         run: sudo SKIP_OPENSSL3=1 .ci/deps.sh autoconf automake iperf3
87
88       - name: Compatibility with older versions of tinc
89         run: sudo ./.ci/compat/run.sh
90         if: always()
91
92       - name: Install tools
93         run: |
94           sudo apt-get install -y astyle clang-tidy-$CLANG
95           sudo update-alternatives --install /usr/bin/clang-tidy     clang-tidy     /usr/bin/clang-tidy-$CLANG     100
96           sudo update-alternatives --install /usr/bin/run-clang-tidy run-clang-tidy /usr/bin/run-clang-tidy-$CLANG 100
97           curl -OL "https://github.com/koalaman/shellcheck/releases/download/v$SHELLCHECK/shellcheck-v${SHELLCHECK}.linux.x86_64.tar.xz"
98           tar -C ~ --strip-components=1 --wildcards -xf ./shellcheck-*.tar.xz 'shellcheck-*/shellcheck'
99           curl -o ~/shfmt -L "https://github.com/mvdan/sh/releases/download/v$SHFMT/shfmt_v${SHFMT}_linux_amd64"
100           chmod 755 ~/shfmt ~/shellcheck
101           python3 -m venv /tmp/venv
102           . /tmp/venv/bin/activate
103           pip3 install black pylint mypy markflow
104         env:
105           CLANG: 11
106           SHELLCHECK: 0.8.0
107           SHFMT: 3.5.0
108         if: always()
109
110       - name: Lint/typecheck/check formatting on C/shell/Python code
111         run: |
112           . /tmp/venv/bin/activate
113           PATH=$PATH:$HOME ./lint.py
114         if: always()
115
116       - name: Check warnings (clang)
117         run: bash .ci/warn/run.sh
118         env:
119           CC: clang-12
120         if: always()
121
122       - name: Check warnings (gcc)
123         run: bash .ci/warn/run.sh
124         env:
125           CC: gcc-11
126         if: always()
127
128       - name: Check that very long paths work
129         run: |
130           meson setup "$WD"
131           meson test -C "$WD" --verbose
132         env:
133           WD: /tmp/tinc_testing_directory_with_a_very_long_path_which_goes_over_the_108_char_limit_on_unix_socket_file_paths
134         if: always()
135
136       - name: Archive test results
137         run: sudo tar -caf tests.tar.gz /usr/local/etc
138         continue-on-error: true
139         if: always()
140
141       - name: Upload test results
142         uses: actions/upload-artifact@v2
143         with:
144           name: tests_compat
145           path: tests.tar.gz
146         if: always()
147
148   sanitizer:
149     runs-on: ubuntu-22.04
150     timeout-minutes: 30
151     strategy:
152       fail-fast: false
153       matrix:
154         sanitizer:
155           - address
156           - thread
157           - undefined
158     env:
159       SANITIZER: "${{ matrix.sanitizer }}"
160
161     steps:
162       - name: Checkout code
163         uses: actions/checkout@v1
164
165       - name: Install deps
166         run: |
167           sudo sh .ci/deps.sh iputils-arping
168           sudo pip3 install --upgrade cryptography
169
170       - name: Run tests with OpenSSL 3
171         run: bash .ci/sanitizers/run.sh openssl3
172         if: always()
173
174       - name: Sanitize tests with default settings
175         run: bash .ci/sanitizers/run.sh default
176         if: always()
177
178       - name: Sanitize tests without legacy protocol
179         run: bash .ci/sanitizers/run.sh nolegacy
180         if: always()
181
182       - name: Run tests with libgcrypt
183         run: bash .ci/sanitizers/run.sh gcrypt
184         if: always()
185
186       - name: Upload test results
187         uses: actions/upload-artifact@v2
188         with:
189           name: tests_sanitizer_${{ matrix.sanitizer }}
190           path: /tmp/logs/tests.*.tar.gz
191         if: always()
192
193   linux:
194     runs-on: ubuntu-22.04
195     timeout-minutes: 30
196     strategy:
197       fail-fast: false
198       matrix:
199         os:
200           - alpine:latest
201           - alpine:edge
202           - almalinux:latest
203           - fedora:latest
204           - fedora:rawhide
205           - debian:oldstable
206           - debian:stable
207           - debian:testing
208           - ubuntu:latest
209           - ubuntu:rolling
210     container:
211       image: ${{ matrix.os }}
212       options: --privileged
213       env:
214         CI: 1
215     steps:
216       - name: Checkout code
217         uses: actions/checkout@v1
218
219       - name: Install deps
220         run: sh .ci/deps.sh
221
222       - name: Assign name for test results artifact
223         run: echo ARTIFACT="$(echo '${{ matrix.os }}' | sed 's|[:/]|_|g')" >>"$GITHUB_ENV"
224
225       - name: Create a non-privileged user
226         run: sh .ci/test/prepare.sh
227
228       - name: Run tests with OpenSSL 3
229         run: sudo -u build CI=1 sh .ci/test/run.sh openssl3
230
231       - name: Run tests with default settings
232         run: sudo -u build CI=1 sh .ci/test/run.sh default
233         if: always()
234
235       - name: Run tests without legacy protocol
236         run: sudo -u build CI=1 sh .ci/test/run.sh nolegacy
237         if: always()
238
239       - name: Run tests with libgcrypt
240         run: sudo -u build CI=1 sh .ci/test/run.sh gcrypt
241         if: always()
242
243       - name: Upload test results
244         uses: actions/upload-artifact@v2
245         with:
246           name: tests_${{ env.ARTIFACT }}
247           path: /tmp/logs/tests.*.tar.gz
248         if: always()
249
250       - name: Build package
251         run: sh .ci/package/build.sh
252         if: github.ref == 'refs/heads/1.1' || startsWith(github.ref, 'refs/tags/release-')
253         continue-on-error: true
254
255       - name: Upload package
256         uses: actions/upload-artifact@v2
257         with:
258           name: pkg-${{ env.ARTIFACT }}
259           path: |
260             *.deb
261             ~/rpmbuild/RPMS/*/*.rpm
262         continue-on-error: true
263
264   pkg-publish:
265     if: always() && (github.ref == 'refs/heads/1.1' || startsWith(github.ref, 'refs/tags/release-'))
266     runs-on: ubuntu-22.04
267     continue-on-error: true
268     needs:
269       - linux
270       - mingw
271
272     steps:
273       - name: Create artifact directory
274         run: mkdir -p /tmp/artifacts
275
276       - name: Download packages
277         uses: actions/download-artifact@v2
278         with:
279           path: /tmp/artifacts
280
281       - name: Publish packages (dev)
282         uses: marvinpinto/action-automatic-releases@latest
283         with:
284           repo_token: ${{ secrets.GITHUB_TOKEN }}
285           automatic_release_tag: latest
286           title: Development release
287           prerelease: true
288           files: /tmp/artifacts/**/*.(deb|rpm|exe)
289         if: startsWith(github.ref, 'refs/heads/')
290
291       - name: Publish packages (release)
292         uses: softprops/action-gh-release@v1
293         with:
294           files: |
295             /tmp/artifacts/**/*.deb
296             /tmp/artifacts/**/*.rpm
297             /tmp/artifacts/**/*.exe
298         if: startsWith(github.ref, 'refs/tags/')
299
300   macos:
301     runs-on: macos-12
302     timeout-minutes: 20
303
304     steps:
305       - name: Checkout code
306         uses: actions/checkout@v1
307
308       - name: Install build deps
309         run: sh .ci/deps.sh
310
311       - name: Run tests with default settings
312         run: sh .ci/test/run.sh default
313
314       - name: Run tests without legacy protocol
315         run: sh .ci/test/run.sh nolegacy
316         if: always()
317
318       - name: Run tests with libgcrypt
319         run: sh .ci/test/run.sh gcrypt
320         if: always()
321
322       - name: Upload test results
323         uses: actions/upload-artifact@v2
324         with:
325           name: tests_macos
326           path: /tmp/logs/tests.*.tar.gz
327         if: always()
328
329   mingw:
330     runs-on: windows-latest
331     timeout-minutes: 30
332
333     steps:
334       - name: Install msys2
335         uses: msys2/setup-msys2@v2
336         with:
337           update: true
338           # https://packages.msys2.org/package/
339           install: >-
340             base-devel
341             mingw-w64-x86_64-meson
342             mingw-w64-x86_64-pkgconf
343             mingw-w64-x86_64-gcc
344             mingw-w64-x86_64-openssl
345             mingw-w64-x86_64-libgcrypt
346             mingw-w64-x86_64-zlib
347             mingw-w64-x86_64-lzo2
348             mingw-w64-x86_64-lz4
349             mingw-w64-x86_64-ncurses
350             mingw-w64-x86_64-miniupnpc
351             mingw-w64-x86_64-nsis
352             git
353             openbsd-netcat
354             procps
355
356       - name: Checkout code
357         uses: actions/checkout@v1
358
359       - name: Run tests with default settings
360         shell: msys2 {0}
361         run: sh .ci/test/run.sh default
362
363       - name: Create installer
364         shell: msys2 {0}
365         run: sh .ci/package/build.sh
366         if: github.ref == 'refs/heads/1.1' || startsWith(github.ref, 'refs/tags/release-')
367         continue-on-error: true
368
369       - name: Upload package
370         uses: actions/upload-artifact@v2
371         with:
372           name: pkg-windows
373           path: .ci/package/win/tinc-*.exe
374         continue-on-error: true
375
376       - name: Run tests without legacy protocol
377         shell: msys2 {0}
378         run: sh .ci/test/run.sh nolegacy
379         if: always()
380
381       - name: Run tests with libgcrypt
382         shell: msys2 {0}
383         run: sh .ci/test/run.sh gcrypt
384         if: always()
385
386       - name: Upload test results
387         uses: actions/upload-artifact@v2
388         with:
389           name: tests_windows
390           path: /tmp/logs/tests.*.tar.gz
391         if: always()
392
393   msvc:
394     runs-on: windows-latest
395     timeout-minutes: 30
396
397     strategy:
398       fail-fast: false
399       matrix:
400         target:
401           - { build: amd64, host: amd64, test: test }
402           - { build: amd64, host: x86, test: test }
403           - { build: amd64, host: arm64, test: notest }
404
405     env:
406       HOST_ARCH: ${{ matrix.target.host }}
407       BUILD_ARCH: ${{ matrix.target.build }}
408
409     steps:
410       - name: Install meson
411         run: pip3 install meson
412
413       - name: Checkout code
414         uses: actions/checkout@v1
415
416       - name: Activate dev environment
417         uses: ilammy/msvc-dev-cmd@v1
418         with:
419           arch: ${{ matrix.target.build == matrix.target.host && matrix.target.host || format('{0}_{1}', matrix.target.build, matrix.target.host) }}
420
421       - name: Build (nolegacy)
422         run: .ci\windows\build.cmd nolegacy
423
424       - name: Test (nolegacy)
425         run: .ci\windows\test.cmd nolegacy
426         if: always() && matrix.target.test == 'test'
427
428       - name: Build (OpenSSL)
429         run: .ci\windows\build.cmd openssl
430         if: always()
431
432       - name: Test (OpenSSL)
433         run: .ci\windows\test.cmd openssl
434         if: always() && matrix.target.test == 'test'