ci: Don't fail fast in matrix builds
[quassel.git] / .github / workflows / main.yml
1 # Workflow that builds Quassel on various Linux distros, and creates packages for both Windows and macOS.
2 # For tagged pushes, a draft release is automatically created, using the tag message as release description
3 # and attaching Windows and macOS builds, as well as the source archive.
4 name: Quassel CI
5
6 on: [ push, pull_request ]
7
8 defaults:
9   run:
10     shell: bash
11
12 jobs:
13
14 # ------------------------------------------------------------------------------------------------------------------------------------------
15   build-linux:
16     name: Linux
17     runs-on: ubuntu-latest
18     container: quassel/quassel-build-env:${{ matrix.dist }}
19     strategy:
20       fail-fast: false
21       matrix:
22         dist: [ debian-stable, debian-testing, ubuntu-xenial, ubuntu-bionic, ubuntu-eoan, ubuntu-focal ]
23         cxx: [ gcc, clang++ ]
24         with-kde: [ -DWITH_KDE=ON ]
25         extra-options: [ -DWITH_WEBENGINE=ON ]
26         include:
27           # Baseline, test more combinations
28           - dist: ubuntu-xenial
29             with-kde: -DWITH_KDE=OFF
30             extra-options: -DWITH_WEBKIT=ON
31           - dist: ubuntu-xenial
32             with-kde: -DWITH_KDE=ON
33             extra-options: -DWITH_WEBKIT=ON
34         exclude:
35           # QtWebEngine is not available on Xenial
36           - dist: ubuntu-xenial
37             extra-options: -DWITH_WEBENGINE=ON
38     env:
39         CCACHE_BASEDIR: ${{ github.workspace }}
40         CCACHE_DIR: ${{ github.workspace }}/ccache
41         CCACHE_MAXSIZE: 100M
42
43     steps:
44     - name: Check out source code
45       uses: actions/checkout@v2
46
47     - name: Get timestamp
48       id: get-timestamp
49       run: echo "::set-output name=timestamp::$(date -u "+%F-%R")"
50
51     - name: Setup ccache
52       uses: actions/cache@v2
53       with:
54         path: ${{ github.workspace }}/ccache
55         key: ${{ matrix.dist }}-ccache-${{ steps.get-timestamp.outputs.timestamp }}
56         restore-keys: |
57              ${{ matrix.dist }}-ccache-
58
59     - name: Zero ccache stats
60       run: ccache -z
61
62     - name: Configure
63       run: |
64         mkdir build
65         cd build && cmake $GITHUB_WORKSPACE \
66                           -GNinja \
67                           -DCMAKE_BUILD_TYPE=Release \
68                           -DBUILD_TESTING=ON \
69                           -DFATAL_WARNINGS=ON \
70                           ${{ matrix.with-kde }} \
71                           ${{ matrix.extra-options }}
72
73     - name: Build
74       run: cd build && ninja
75
76     - name: Run tests
77       run: cd build && ctest
78
79     - name: Install
80       run: cd build && DESTDIR=$GITHUB_WORKSPACE/image ninja install
81
82     - name: Print ccache stats
83       run: ccache -s
84
85 # ------------------------------------------------------------------------------------------------------------------------------------------
86   build-macos:
87     name: macOS
88     runs-on: macos-latest
89     env:
90       CCACHE_BASEDIR: ${{ github.workspace }}
91       CCACHE_DIR: ${{ github.workspace }}/ccache
92       CCACHE_MAXSIZE: 100M
93
94     steps:
95     - name: Check out source code
96       uses: actions/checkout@v2
97       with:
98         fetch-depth: 0  # so git-describe works
99
100     - name: Fetch tag information
101       if: startsWith(github.ref, 'refs/tags/')
102       run: git fetch -f origin $GITHUB_REF:$GITHUB_REF
103
104     - name: Install dependencies
105       # Skip "brew update" as it can trigger 50+ minutes of updating.
106       # GitHub Actions intentionally disables the default auto-update on their
107       # macOS CI images (and macOS CI images usually update once a week).
108       #
109       # See https://github.com/actions/virtual-environments/issues/2173
110       # > We've set no auto-update intentionally here [...]
111       # And https://github.com/microsoft/appcenter/issues/293
112       #
113       # If Homebrew begins failing in the future due to out-of-date versions,
114       # it can be re-enabled here as follows...
115       # run: brew update && [below command]
116       run: brew install boost ccache ninja qca qt5
117
118     - name: Get timestamp
119       id: get-timestamp
120       run: echo "::set-output name=timestamp::$(date -u "+%F-%R")"
121
122     - name: Setup ccache
123       uses: actions/cache@v2
124       with:
125         path: ${{ github.workspace }}/ccache
126         key: macos-ccache-${{ steps.get-timestamp.outputs.timestamp }}
127         restore-keys: |
128              macos-ccache-
129
130     - name: Zero ccache stats
131       run: ccache -z
132
133     - name: Configure
134       run: |
135         mkdir build
136         cd build && cmake $GITHUB_WORKSPACE \
137                           -GNinja \
138                           -DCMAKE_PREFIX_PATH=/usr/local/opt/qt/lib/cmake \
139                           -DCMAKE_BUILD_TYPE=Release \
140                           -DBUILD_TESTING=ON \
141                           -DFATAL_WARNINGS=OFF \
142                           -DDEPLOY=ON \
143                           -DENABLE_SHARED=OFF
144
145     - name: Build
146       run: |
147         # Deploy scripts require qmake in the path
148         export PATH=$PATH:/usr/local/opt/qt5/bin
149         cd build && ninja
150
151     - name: Run tests
152       run: cd build && ctest
153
154     - name: Install
155       run: cd build && DESTDIR=$GITHUB_WORKSPACE/image ninja install
156
157     - name: Print ccache stats
158       run: ccache -s
159
160     - name: Upload artifacts
161       uses: actions/upload-artifact@v2
162       with:
163         name: macOS
164         path: ${{ github.workspace }}/build/*.dmg
165
166 # ------------------------------------------------------------------------------------------------------------------------------------------
167   build-windows:
168     name: Windows
169     runs-on: windows-latest
170     env:
171       WORKSPACE: ${{ github.workspace }}
172       CRAFT: /C/CraftMaster/windows-msvc2019_64-cl/craft/bin/craft.py
173
174     steps:
175     - name: Check out source code
176       uses: actions/checkout@v2
177       with:
178         fetch-depth: 0  # so git-describe works
179
180     - name: Fetch tag information
181       if: startsWith(github.ref, 'refs/tags/')
182       run: git fetch -f origin $GITHUB_REF:$GITHUB_REF
183
184     - name: Clone CraftMaster
185       run: git clone --depth=1 https://invent.kde.org/kde/craftmaster.git /C/CraftMaster/CraftMaster
186
187     - name: Configure CraftMaster
188       run: python /C/CraftMaster/CraftMaster/CraftMaster.py --config $WORKSPACE/.craftsettings.ini --variables "WORKSPACE=$WORKSPACE"
189
190     - name: Add Quassel blueprint
191       run: python $CRAFT --add-blueprint-repository https://github.com/quassel/craft-blueprints-quassel.git
192
193     - name: Install NSIS
194       run: python $CRAFT dev-utils/nsis
195
196     - name: Install dependencies
197       run: python $CRAFT --install-deps quassel/quassel
198
199     - name: Build
200       run: python $CRAFT --no-cache --src-dir $WORKSPACE quassel/quassel
201
202     - name: Run tests
203       run: python $CRAFT --no-cache --src-dir $WORKSPACE --test quassel/quassel
204
205     - name: Package
206       run: python $CRAFT --no-cache --src-dir $WORKSPACE --package quassel/quassel
207
208     - name: Upload artifacts
209       uses: actions/upload-artifact@v2
210       with:
211         name: Windows
212         path: ${{ github.workspace }}/packages/*
213
214 # ------------------------------------------------------------------------------------------------------------------------------------------
215   post-build:
216     name: Post-Build
217     runs-on: ubuntu-latest
218     needs: [ build-linux, build-macos, build-windows ]
219     env:
220       GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
221
222     steps:
223     - name: Check out source code
224       uses: actions/checkout@v2
225
226     - name: Fetch tag information
227       if: startsWith(github.ref, 'refs/tags/')
228       run: git fetch -f origin $GITHUB_REF:$GITHUB_REF
229
230     - name: Download artifacts
231       uses: actions/download-artifact@v2
232       with:
233         path: artifacts
234
235     - name: List artifacts
236       run: ls -lhR artifacts
237
238     - name: Check artifacts
239       run: |
240         # Sanity check: We should have exactly 5 files matching the given patterns
241         [[ 5 -eq $(find artifacts/ \( -type f -name 'Quassel*.dmg' -o -name 'quassel*.exe' -o -name 'quassel*.7z' \) -printf '.' | wc -c) ]]
242
243     - name: Create release notes
244       if: startsWith(github.ref, 'refs/tags/')
245       run: |
246         # Use the tag's annotation as release notes
247         TAGNAME=$(git rev-parse --abbrev-ref $GITHUB_REF)
248         MESSAGE=$(git tag -l --format='%(contents)' $TAGNAME | perl -ne 'print if not /-----BEGIN PGP SIGNATURE-----/../-----END PGP SIGNATURE-----/')
249         echo -e "Quassel $TAGNAME\n\n$MESSAGE" > release_notes.txt
250
251     - name: Prepare source archive
252       if: startsWith(github.ref, 'refs/tags/')
253       run: |
254         mkdir assets
255         TAGNAME=$(git rev-parse --abbrev-ref $GITHUB_REF)
256         git archive --format=tar --prefix=quassel-$TAGNAME/ $TAGNAME | xz > assets/quassel-$TAGNAME.tar.xz
257
258     - name: Prepare packages for release
259       if: startsWith(github.ref, 'refs/tags/')
260       run: |
261         TAGNAME=$(git rev-parse --abbrev-ref $GITHUB_REF)
262         for type in Client Core Mono; do
263           mv artifacts/macOS/Quassel$type*.dmg assets/Quassel$type-macOS-$TAGNAME.dmg
264         done
265         mv artifacts/Windows/quassel-*.exe assets/quassel-windows-setup-$TAGNAME.exe
266         mv artifacts/Windows/quassel-*.7z assets/quassel-windows-$TAGNAME.7z
267
268     - name: Create checksums for release assets
269       if: startsWith(github.ref, 'refs/tags/')
270       run: find assets/ -type f -execdir sh -c 'sha256sum "$1" > "$1.sha256sum"' _ {} \;
271
272     - name: Create draft release
273       if: startsWith(github.ref, 'refs/tags/')
274       run: |
275         # The stock upload-release-asset action can only handle single files
276         # Instead, use the hub utility so we can upload all assets at once
277         assets=()
278         for asset in assets/*; do assets+=("-a" "$asset"); done
279         hub release create -d "${assets[@]}" -F release_notes.txt `git rev-parse --abbrev-ref $GITHUB_REF`