21b3aba5b4e4e28d4f9b6b6c4cddf924473e8c1a
[tinc] / .github / workflows / test.yml
1 name: Build and test
2
3 on:
4   push:
5     branches:
6       - master
7       - "1.1"
8     tags:
9       - "release-*"
10
11   pull_request:
12     types:
13       - opened
14       - synchronize
15
16 jobs:
17   test-linux:
18     strategy:
19       matrix:
20         os: [ubuntu-18.04, ubuntu-20.04]
21         compiler: [clang, gcc]
22         legacy_protocol: ["", --disable-legacy-protocol]
23       fail-fast: false
24
25     runs-on: ${{ matrix.os }}
26     env:
27       CC: ${{ matrix.compiler }}
28
29     steps:
30       - name: Checkout code
31         uses: actions/checkout@v2
32
33       - name: Install Artistic Style and build deps
34         run: >
35           sudo apt-get install -y --no-install-{recommends,suggests}
36           zlib1g-dev
37           liblzo2-dev
38           libncurses-dev
39           libreadline-dev
40           libminiupnpc-dev
41           libvdeplug-dev
42           astyle
43           socket
44
45       - name: Install OpenSSL
46         run: sudo apt-get install -y libssl-dev
47         if: ${{ matrix.legacy_protocol == '' }}
48
49       - name: Run autoreconf
50         run: autoreconf -fsi
51
52       - name: Run ./configure
53         run: >
54           ./configure 
55           --enable-{miniupnpc,uml,vde}
56           ${{ matrix.legacy_protocol }}
57
58       - name: Check code formatting
59         run: make check-style
60
61       - name: Compile project
62         run: make -j$(nproc)
63
64       - name: Run tests
65         # root is required for some tests
66         run: sudo make check-recursive
67         timeout-minutes: 20
68
69       - name: Upload test results
70         uses: actions/upload-artifact@v2
71         with:
72           name: tests_${{ matrix.os }}_${{ matrix.compiler }}
73           path: test/test-suite.log
74         if: failure()
75
76   build-windows:
77     runs-on: windows-latest
78
79     steps:
80       - name: Checkout code
81         uses: actions/checkout@v2
82
83       - name: Install msys2
84         uses: msys2/setup-msys2@v2
85         with:
86           update: true
87           # https://packages.msys2.org/package/
88           install: >-
89             base-devel
90             mingw-w64-x86_64-gcc
91             mingw-w64-x86_64-openssl
92             mingw-w64-x86_64-zlib
93             mingw-w64-x86_64-lzo2
94             mingw-w64-x86_64-ncurses
95             mingw-w64-x86_64-miniupnpc
96             git
97
98       - name: Build the project
99         shell: msys2 {0}
100         run: |
101           autoreconf -fsi
102           ./configure --with-curses-include=/mingw64/include/ncurses --disable-readline
103           make -j$(nproc)
104
105       - name: Check that tinc can be started
106         shell: msys2 {0}
107         run: ./src/tinc --version
108
109       - name: Check that tincd can be started
110         shell: msys2 {0}
111         run: ./src/tincd --version
112
113   release-deb:
114     if: startsWith(github.ref, 'refs/tags/release-')
115     needs: test-linux
116
117     strategy:
118       matrix:
119         os: ["ubuntu-18.04", ubuntu-20.04]
120
121     runs-on: ${{ matrix.os }}
122
123     steps:
124       - name: Checkout code
125         uses: actions/checkout@v2
126
127       - name: Install build deps
128         run: >
129           sudo apt-get install -y --no-install-{recommends,suggests}
130           dh-make
131           texinfo
132           libssl-dev
133           zlib1g-dev
134           liblzo2-dev
135           libncurses-dev
136           libreadline-dev
137
138       - name: Run autoreconf
139         run: autoreconf -fsi
140
141       - name: Run ./configure
142         run: >
143           ./configure 
144           --prefix=/usr
145           --sbindir=/usr/sbin
146           --sysconfdir=/etc
147           --localstatedir=/var
148           --with-systemd=/usr/lib/systemd/system
149
150       - name: Prepare debian directory
151         run: >
152           dh_make
153           --yes
154           --single
155           --createorig
156           --copyright gpl2
157           --packagename "tinc_$(git describe --tags --always | sed 's/release-//')-${{ matrix.os }}"
158         env:
159           DEBFULLNAME: Automated Builds
160
161       - name: Build deb package
162         run: dpkg-buildpackage -d -us -uc
163
164       - name: Publish deb package
165         uses: softprops/action-gh-release@v1
166         with:
167           files: |
168             ../*.deb
169         env:
170           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
171
172   test-macos:
173     runs-on: macos-10.15
174
175     steps:
176       - name: Checkout code
177         uses: actions/checkout@v2
178
179       - name: Install dependencies
180         run: brew install coreutils netcat automake lzo miniupnpc
181
182       - name: Run autoreconf
183         run: autoreconf -fsi
184
185       - name: Run ./configure
186         run: >
187           ./configure
188           --with-openssl=/usr/local/opt/openssl@1.1
189           --enable-{tunemu,miniupnpc}
190
191       - name: Compile application
192         run: make -j$(sysctl -n hw.ncpu)
193
194       - name: Run tests
195         run: make check-recursive
196         timeout-minutes: 20
197
198       - name: Upload test results
199         uses: actions/upload-artifact@v2
200         with:
201           name: tests_${{ runner.os }}
202           path: test/test-suite.log
203         if: failure()