a8776a3693d8278a334bb324bbd2e926aa8f87ce
[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:bullseye
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:bullseye-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
201           - alpine:edge
202           - centos:7 # aka RHEL 7
203           - almalinux:8 # aka RHEL 8
204           - almalinux:9 # aka RHEL 9
205           - fedora
206           - debian:buster
207           - debian:bullseye
208           - debian:testing
209           - ubuntu # current LTS
210           - ubuntu:rolling # latest
211     container:
212       image: ${{ matrix.os }}
213       options: --privileged
214       env:
215         CI: 1
216     steps:
217       - name: Checkout code
218         uses: actions/checkout@v1
219
220       - name: Install deps
221         run: sh .ci/deps.sh
222
223       - name: Assign name for test results artifact
224         run: echo ARTIFACT="$(echo '${{ matrix.os }}' | sed 's|[:/]|_|g')" >>"$GITHUB_ENV"
225
226       - name: Create a non-privileged user
227         run: sh .ci/test/prepare.sh
228
229       - name: Run tests with OpenSSL 3
230         run: sudo -u build CI=1 sh .ci/test/run.sh openssl3
231
232       - name: Run tests with default settings
233         run: sudo -u build CI=1 sh .ci/test/run.sh default
234         if: always()
235
236       - name: Run tests without legacy protocol
237         run: sudo -u build CI=1 sh .ci/test/run.sh nolegacy
238         if: always()
239
240       - name: Run tests with libgcrypt
241         run: sudo -u build CI=1 sh .ci/test/run.sh gcrypt
242         if: always()
243
244       - name: Upload test results
245         uses: actions/upload-artifact@v2
246         with:
247           name: tests_${{ env.ARTIFACT }}
248           path: /tmp/logs/tests.*.tar.gz
249         if: always()
250
251       - name: Build package
252         run: sh .ci/package/build.sh
253         if: github.ref == 'refs/heads/1.1' || startsWith(github.ref, 'refs/tags/release-')
254         continue-on-error: true
255
256       - name: Upload package
257         uses: actions/upload-artifact@v2
258         with:
259           name: pkg-${{ env.ARTIFACT }}
260           path: |
261             *.deb
262             ~/rpmbuild/RPMS/*/*.rpm
263         continue-on-error: true
264
265   pkg-publish:
266     if: always() && (github.ref == 'refs/heads/1.1' || startsWith(github.ref, 'refs/tags/release-'))
267     runs-on: ubuntu-22.04
268     continue-on-error: true
269     needs:
270       - linux
271       - mingw
272
273     steps:
274       - name: Create artifact directory
275         run: mkdir -p /tmp/artifacts
276
277       - name: Download packages
278         uses: actions/download-artifact@v2
279         with:
280           path: /tmp/artifacts
281
282       - name: Publish packages (dev)
283         uses: marvinpinto/action-automatic-releases@latest
284         with:
285           repo_token: ${{ secrets.GITHUB_TOKEN }}
286           automatic_release_tag: latest
287           title: Development release
288           prerelease: true
289           files: /tmp/artifacts/**/*.(deb|rpm|exe)
290         if: startsWith(github.ref, 'refs/heads/')
291
292       - name: Publish packages (release)
293         uses: softprops/action-gh-release@v1
294         with:
295           files: |
296             /tmp/artifacts/**/*.deb
297             /tmp/artifacts/**/*.rpm
298             /tmp/artifacts/**/*.exe
299         if: startsWith(github.ref, 'refs/tags/')
300
301   macos:
302     runs-on: macos-12
303     timeout-minutes: 20
304
305     steps:
306       - name: Checkout code
307         uses: actions/checkout@v1
308
309       - name: Install build deps
310         run: sh .ci/deps.sh
311
312       - name: Run tests with default settings
313         run: sh .ci/test/run.sh default
314
315       - name: Run tests without legacy protocol
316         run: sh .ci/test/run.sh nolegacy
317         if: always()
318
319       - name: Run tests with libgcrypt
320         run: sh .ci/test/run.sh gcrypt
321         if: always()
322
323       - name: Upload test results
324         uses: actions/upload-artifact@v2
325         with:
326           name: tests_macos
327           path: /tmp/logs/tests.*.tar.gz
328         if: always()
329
330   mingw:
331     runs-on: windows-latest
332     timeout-minutes: 30
333
334     steps:
335       - name: Install msys2
336         uses: msys2/setup-msys2@v2
337         with:
338           update: true
339           # https://packages.msys2.org/package/
340           install: >-
341             base-devel
342             mingw-w64-x86_64-meson
343             mingw-w64-x86_64-pkgconf
344             mingw-w64-x86_64-gcc
345             mingw-w64-x86_64-openssl
346             mingw-w64-x86_64-libgcrypt
347             mingw-w64-x86_64-zlib
348             mingw-w64-x86_64-lzo2
349             mingw-w64-x86_64-lz4
350             mingw-w64-x86_64-ncurses
351             mingw-w64-x86_64-miniupnpc
352             mingw-w64-x86_64-nsis
353             git
354             openbsd-netcat
355             procps
356
357       - name: Checkout code
358         uses: actions/checkout@v1
359
360       - name: Run tests with default settings
361         shell: msys2 {0}
362         run: sh .ci/test/run.sh default
363
364       - name: Create installer
365         shell: msys2 {0}
366         run: sh .ci/package/build.sh
367         if: github.ref == 'refs/heads/1.1' || startsWith(github.ref, 'refs/tags/release-')
368         continue-on-error: true
369
370       - name: Upload package
371         uses: actions/upload-artifact@v2
372         with:
373           name: pkg-windows
374           path: .ci/package/win/tinc-*.exe
375         continue-on-error: true
376
377       - name: Run tests without legacy protocol
378         shell: msys2 {0}
379         run: sh .ci/test/run.sh nolegacy
380         if: always()
381
382       - name: Run tests with libgcrypt
383         shell: msys2 {0}
384         run: sh .ci/test/run.sh gcrypt
385         if: always()
386
387       - name: Upload test results
388         uses: actions/upload-artifact@v2
389         with:
390           name: tests_windows
391           path: /tmp/logs/tests.*.tar.gz
392         if: always()
393
394   msvc:
395     runs-on: windows-latest
396     timeout-minutes: 30
397
398     strategy:
399       fail-fast: false
400       matrix:
401         target:
402           - { build: amd64, host: amd64, test: test }
403           - { build: amd64, host: x86, test: test }
404           - { build: amd64, host: arm64, test: notest }
405
406     env:
407       HOST_ARCH: ${{ matrix.target.host }}
408       BUILD_ARCH: ${{ matrix.target.build }}
409
410     steps:
411       - name: Install meson
412         run: pip3 install meson
413
414       - name: Checkout code
415         uses: actions/checkout@v1
416
417       - name: Activate dev environment
418         uses: ilammy/msvc-dev-cmd@v1
419         with:
420           arch: ${{ matrix.target.build == matrix.target.host && matrix.target.host || format('{0}_{1}', matrix.target.build, matrix.target.host) }}
421
422       - name: Build (nolegacy)
423         run: .ci\windows\build.cmd nolegacy
424
425       - name: Test (nolegacy)
426         run: .ci\windows\test.cmd nolegacy
427         if: always() && matrix.target.test == 'test'
428
429       - name: Build (OpenSSL)
430         run: .ci\windows\build.cmd openssl
431         if: always()
432
433       - name: Test (OpenSSL)
434         run: .ci\windows\test.cmd openssl
435         if: always() && matrix.target.test == 'test'