Install OpenSSL 1.1 in the CentOS 7 test environment.
[tinc] / .github / workflows / test.yml
1 name: Test
2
3 on:
4   push:
5   pull_request:
6     types:
7       - opened
8       - synchronize
9
10 jobs:
11   code-style:
12     runs-on: ubuntu-latest
13     steps:
14       - name: Checkout code
15         uses: actions/checkout@v2
16
17       - name: Install code formatting tools
18         run: |
19           sudo apt-get install -y astyle
20           curl -OL 'https://github.com/koalaman/shellcheck/releases/download/v0.7.2/shellcheck-v0.7.2.linux.x86_64.tar.xz'
21           tar -C ~ --strip-components=1 --wildcards -xf ./shellcheck-*.tar.xz 'shellcheck-*/shellcheck'
22           curl -o ~/shfmt -L 'https://github.com/mvdan/sh/releases/download/v3.3.0/shfmt_v3.3.0_linux_amd64'
23           chmod 755 ~/shfmt ~/shellcheck
24
25       - name: Check code formatting
26         run: "! astyle -r --options=.astylerc --dry-run --formatted '*.c' '*.h' | grep '^Formatted'"
27
28       - name: Check scripts formatting
29         run: find -type f -regextype egrep -regex '.+\.(sh|sh\.in|test)$' -exec ~/shfmt -d -i 2 -s '{}' +
30         if: always()
31
32       - name: Run static analysis on scripts
33         run: find -type f -regextype egrep -regex '.+\.sh(\.in)?$' -exec shellcheck -x '{}' +
34         if: always()
35
36       - name: Prepare test library and run static analysis on tests
37         run: |
38           autoreconf -fsi
39           ./configure --disable-{lzo,readline,zlib,curses}
40           find -type f -name '*.test' -execdir shellcheck -x '{}' +
41         if: always()
42
43   sanitizer:
44     runs-on: ubuntu-latest
45     strategy:
46       fail-fast: false
47       matrix:
48         sanitizer:
49           - thread
50           - undefined
51     env:
52       SANITIZER: "${{ matrix.sanitizer }}"
53
54     steps:
55       - name: Checkout code
56         uses: actions/checkout@v2
57         with:
58           fetch-depth: 0
59
60       - name: Install deps
61         shell: bash
62         run: >
63           sudo apt-get install -y
64           git binutils make autoconf automake diffutils texinfo netcat
65           zlib1g-dev lib{ssl,lzo2,ncurses,readline,vdeplug,miniupnpc}-dev
66
67       - name: Configure and compile
68         shell: bash
69         run: bash .github/workflows/sanitizers/build.sh
70         env:
71           CC: clang-12
72
73       - name: Run tests
74         run: bash .github/workflows/sanitizers/run.sh
75
76       - name: Archive test results
77         run: sudo tar -c -z -f test-results.tar.gz test/ sanitizer/
78         if: always()
79
80       - name: Upload test results
81         uses: actions/upload-artifact@v2
82         with:
83           name: tests_sanitizer_${{ matrix.sanitizer }}
84           path: test-results.tar.gz
85         if: always()
86
87   linux:
88     runs-on: ubuntu-latest
89     strategy:
90       fail-fast: false
91       matrix:
92         os:
93           - alpine:3.13
94           - centos:7 # aka RHEL 7
95           - almalinux:8 # aka RHEL 8
96           - debian:oldstable
97           - debian:stable
98           - debian:testing
99           - debian:unstable
100           - ubuntu:18.04 # previous LTS
101           - ubuntu:20.04 # current LTS
102           - opensuse/leap # aka SLES
103     container:
104       image: ${{ matrix.os }}
105       options: --privileged
106
107     steps:
108       - name: Install deps (Alpine)
109         run: >
110           apk add git binutils make autoconf automake gcc linux-headers libtool
111           diffutils texinfo procps openssl-dev zlib-dev lzo-dev ncurses-dev
112           readline-dev musl-dev lz4-dev socat
113         if: startsWith(matrix.os, 'alpine')
114
115       - name: Install deps (Debian and Ubuntu)
116         shell: bash
117         run: |
118           apt-get update
119           apt-get install -y git binutils make autoconf automake gcc diffutils \
120             texinfo netcat procps socat zlib1g-dev lib{ssl,lzo2,lz4,ncurses,readline}-dev
121         env:
122           DEBIAN_FRONTEND: noninteractive
123         if: startsWith(matrix.os, 'debian') || startsWith(matrix.os, 'ubuntu')
124
125       - name: Install deps (RHEL)
126         shell: bash
127         run: |
128           if type dnf 2>/dev/null; then
129             dnf install -y 'dnf-command(config-manager)'
130             dnf config-manager --enable powertools
131           fi
132           yum install -y epel-release
133           yum install -y git binutils make autoconf automake gcc diffutils \
134             texinfo netcat procps socat {lzo,zlib,lz4,openssl11,ncurses,readline}-devel
135         if: startsWith(matrix.os, 'centos') || startsWith(matrix.os, 'alma')
136
137       - name: Install deps (SUSE)
138         shell: bash
139         run: >
140           zypper install -y tar git binutils make autoconf automake gcc procps
141           makeinfo diffutils gzip socat {openssl,zlib,lzo,liblz4,ncurses,readline}-devel
142         if: startsWith(matrix.os, 'opensuse')
143
144       - name: Checkout code
145         uses: actions/checkout@v2
146         with:
147           fetch-depth: 0
148
149       - name: Assign name for test results artifact
150         run: echo TEST_ARTIFACT="$(echo '${{ matrix.os }}' | sed 's|[:/]|_|g')" >>"$GITHUB_ENV"
151
152       - name: Run tests with default settings
153         run: sh .github/workflows/test/run.sh default
154
155       - name: Run tests without legacy protocol
156         run: sh .github/workflows/test/run.sh nolegacy
157
158       - name: Upload test results
159         uses: actions/upload-artifact@v2
160         with:
161           name: tests_${{ env.TEST_ARTIFACT }}
162           path: /tmp/tests.*.tar.gz
163         if: always()
164
165   deb-build:
166     if: startsWith(github.ref, 'refs/tags/release-')
167     needs: linux
168
169     strategy:
170       matrix:
171         os: [ubuntu-18.04, ubuntu-20.04]
172
173     runs-on: ${{ matrix.os }}
174
175     steps:
176       - name: Checkout code
177         uses: actions/checkout@v2
178         with:
179           fetch-depth: 0
180
181       - name: Install build deps
182         run: >
183           sudo apt-get install -y --no-install-{recommends,suggests}
184           devscripts
185           git-buildpackage
186           dh-make
187           texinfo
188           libssl-dev
189           zlib1g-dev
190           liblzo2-dev
191           libncurses-dev
192           libreadline-dev
193           libminiupnpc-dev
194
195       - name: Configure project
196         run: autoreconf -fsi
197
198       - name: Prepare debian directory
199         run: bash .github/workflows/deb/prepare.sh
200         env:
201           JOB_DISTRIBUTION: ${{ matrix.os }}
202
203       - name: Build deb package
204         run: |
205           dpkg-buildpackage -d -us -uc
206           mv ../*.deb .
207
208       - name: Upload packages
209         uses: actions/upload-artifact@v2
210         with:
211           name: deb-${{ matrix.os }}
212           path: "*.deb"
213
214   deb-publish:
215     needs: deb-build
216
217     strategy:
218       matrix:
219         os: [ubuntu-18.04, ubuntu-20.04]
220
221     runs-on: ${{ matrix.os }}
222
223     steps:
224       - name: Download built packages
225         uses: actions/download-artifact@v2
226         with:
227           name: deb-${{ matrix.os }}
228
229       - name: Install package
230         run: sudo apt-get install -y ./*.deb
231
232       - name: Prepare tinc configs
233         run: |
234           set -eu
235           sudo mkdir -p /etc/tinc/test/hosts
236           sudo tinc -b -n test generate-ed25519-keys
237           echo "Name test" | sudo tee /etc/tinc/test/tinc.conf
238
239       - name: Enable and start tincd
240         run: |
241           sudo systemctl start tinc@test
242           sudo tinc -n test dump reachable nodes
243
244       - name: Publish deb package
245         uses: softprops/action-gh-release@v1
246         with:
247           files: "*.deb"
248         env:
249           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
250
251   macos:
252     runs-on: macos-latest
253
254     strategy:
255       fail-fast: false
256       matrix:
257         legacy_protocol: ["", --disable-legacy-protocol]
258
259     steps:
260       - name: Checkout code
261         uses: actions/checkout@v2
262         with:
263           fetch-depth: 0
264
265       - name: Install build deps
266         run: brew install coreutils netcat automake lzo lz4 miniupnpc
267
268       - name: Configure project
269         run: |
270           autoreconf -fsi
271           ./configure --with-openssl=/usr/local/opt/openssl@1.1 --enable-{tunemu,miniupnpc} ${{ matrix.legacy_protocol }}
272
273       - name: Compile project
274         run: make -j$(sysctl -n hw.ncpu)
275
276       - name: Run tests
277         run: make check-recursive VERBOSE=1
278
279       - name: Archive test results
280         run: sudo tar -c -z -f test-results.tar.gz test/
281         if: always()
282
283       - name: Upload test results
284         uses: actions/upload-artifact@v2
285         with:
286           name: tests_${{ runner.os }}_${{ matrix.legacy_protocol }}
287           path: test-results.tar.gz
288         if: always()
289
290   windows:
291     runs-on: windows-latest
292
293     strategy:
294       fail-fast: false
295       matrix:
296         legacy_protocol: ["", --disable-legacy-protocol]
297
298     steps:
299       - name: Checkout code
300         uses: actions/checkout@v2
301         with:
302           fetch-depth: 0
303
304       - name: Install msys2
305         uses: msys2/setup-msys2@v2
306         with:
307           update: true
308           # https://packages.msys2.org/package/
309           install: >-
310             base-devel
311             mingw-w64-x86_64-gcc
312             mingw-w64-x86_64-openssl
313             mingw-w64-x86_64-zlib
314             mingw-w64-x86_64-lzo2
315             mingw-w64-x86_64-lz4
316             mingw-w64-x86_64-ncurses
317             mingw-w64-x86_64-miniupnpc
318             git
319             netcat
320             procps
321
322       - name: Configure project
323         shell: msys2 {0}
324         run: |
325           autoreconf -fsi
326           ./configure --enable-miniupnpc --disable-readline --with-curses-include=/mingw64/include/ncurses ${{ matrix.legacy_protocol }}
327
328       - name: Compile project
329         shell: msys2 {0}
330         run: make -j$(nproc)
331
332       - name: Run tests
333         shell: msys2 {0}
334         run: make check-recursive VERBOSE=1
335
336       - name: Archive test results
337         shell: msys2 {0}
338         run: tar -c -z -f test-results.tar.gz test/
339         if: always()
340
341       - name: Upload test results
342         uses: actions/upload-artifact@v2
343         with:
344           name: tests_${{ runner.os }}_${{ matrix.legacy_protocol }}
345           path: test-results.tar.gz
346         if: always()