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