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