summaryrefslogtreecommitdiffstats
path: root/.github/workflows/build.yml
blob: cd7dd0a2205dc75328ecb320a4210ef676c46110 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
name: Build

on:
  push:
  pull_request:

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        include:
          - name: Ubuntu 18.04 (gcc)
            os: ubuntu-18.04
            cmake_args: >-
              -DWARNINGS_FATAL=ON
              -DBULK=ON
              -DFAAD=ON
              -DFFMPEG=OFF
              -DLOCALECOMPARE=ON
              -DMAD=ON
              -DMODPLUG=ON
              -DWAVPACK=ON
              -DINSTALL_USER_UDEV_RULES=OFF
            cmake_generator: Unix Makefiles
            cmake_build_type: RelWithDebInfo
            ctest_args:
            compiler_cache: ccache
            compiler_cache_path: ~/.ccache
            cpack_generator: DEB
            buildenv_basepath: /home/runner/buildenv
            buildenv_script: tools/debian_buildenv.sh
            artifacts_name: Ubuntu 18.04 DEB
            artifacts_path: build/*.deb
            qt_qpa_platform: offscreen
          - name: Ubuntu 20.04 (gcc)
            os: ubuntu-20.04
            cmake_args: >-
              -DWARNINGS_FATAL=ON
              -DBULK=ON
              -DFFMPEG=ON
              -DLOCALECOMPARE=ON
              -DMAD=ON
              -DMODPLUG=ON
              -DWAVPACK=ON
              -DINSTALL_USER_UDEV_RULES=OFF
            cmake_generator: Unix Makefiles
            cmake_build_type: RelWithDebInfo
            ctest_args:
            compiler_cache: ccache
            compiler_cache_path: ~/.ccache
            cpack_generator: DEB
            buildenv_basepath: /home/runner/buildenv
            buildenv_script: tools/debian_buildenv.sh
            artifacts_name: Ubuntu 20.04 DEB
            artifacts_path: build/*.deb
            qt_qpa_platform: offscreen
          - name: macOS 10.15
            os: macos-10.15
            cmake_args: >-
              -DBULK=ON
              -DCOREAUDIO=ON
              -DHSS1394=ON
              -DMACOS_BUNDLE=ON
              -DMODPLUG=OFF
              -DWAVPACK=OFF
            cmake_generator: Unix Makefiles
            cmake_build_type: RelWithDebInfo
            # TODO: Fix this broken test on macOS
            ctest_args: --exclude-regex DirectoryDAOTest.relocateDirectory
            cpack_generator: DragNDrop
            compiler_cache: ccache
            compiler_cache_path: /Users/runner/Library/Caches/ccache
            buildenv_basepath: /Users/runner/buildenv
            buildenv_script: tools/macos_buildenv.sh
            artifacts_name: macOS DMG
            artifacts_path: build/*.dmg
            artifacts_slug: macos-macosintel
            qt_qpa_platform: offscreen
          - name: Windows 2019 (MSVC)
            os: windows-2019
            # TODO: Reenable FFmpeg after licensing issues have been clarified
            # Attention: If you change the cmake_args for the Windows CI build,
            #            also adjust the for the local Windows build setup in
            #            ./tools/windows_buildenv.bat
            cmake_args: >-
              -DBULK=OFF
              -DFFMPEG=OFF
              -DHSS1394=ON
              -DLOCALECOMPARE=ON
              -DMAD=ON
              -DMEDIAFOUNDATION=ON
              -DMODPLUG=ON
              -DWAVPACK=ON
            cc: cl
            cxx: cl
            cmake_generator: Ninja
            cmake_build_type: RelWithDebInfo
            # TODO: Fix these broken tests on Windows
            ctest_args: --exclude-regex '^AutoDJProcessorTest.*$'
            cpack_generator: WIX
            compiler_cache: sccache
            compiler_cache_path: C:\Users\runneradmin\AppData\Local\Mozilla\sccache\cache
            buildenv_basepath: C:\buildenv
            buildenv_script: tools/windows_buildenv.bat
            artifacts_name: Windows Installer
            artifacts_path: build/*.msi
            artifacts_slug: windows-windows64
            qt_qpa_platform: windows

    env:
      SCCACHE_COMMIT: 3f318a8675e4c3de4f5e8ab2d086189f2ae5f5cf
      # macOS codesigning
      APPLE_CODESIGN_IDENTITY: 2C2B5D3EDCE82BA55E22E9A67F16F8D03E390870
      MACOS_CODESIGN_OPENSSL_PASSWORD: ${{ secrets.MACOS_CODESIGN_OPENSSL_PASSWORD }}
      MACOS_CODESIGN_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CODESIGN_CERTIFICATE_PASSWORD }}

    runs-on: ${{ matrix.os }}
    name: ${{ matrix.name }}
    outputs:
      artifact-macos-macosintel: ${{ steps.generate_artifact_metadata.outputs.artifact-macos-macosintel }}
      artifact-windows-windows64: ${{ steps.generate_artifact_metadata.outputs.artifact-windows-windows64 }}
    steps:

    # sccache's handling of the /fp:fast MSVC compiler option is broken, so use our fork with the fix.
    # https://github.com/mozilla/sccache/issues/950
    - name: "[Windows] Set up cargo cache"
      if: runner.os == 'Windows'
      uses: actions/cache@v2
      id: sccache-build-cache
      with:
        path: C:\Users\runneradmin\.cargo
        # hash of commit to build
        key: sccache-${{ env.SCCACHE_COMMIT }}

    # This needs to be done first because something later messes with $PATH in a way that breaks cargo
    # by causing it to find link.exe from Git for Windows instead of MSVC.
    - name: "[Windows] Build fixed sccache"
      shell: bash
      if: runner.os == 'Windows' && steps.sccache-build-cache.outputs.cache-hit != 'true'
      # TODO: change this to simply `cargo install sccache` after 0.2.16 has been released
      run: cargo install --git https://github.com/mozilla/sccache.git --rev "${SCCACHE_COMMIT}"

    - name: "Check out repository"
      uses: actions/checkout@v2
      with:
        fetch-depth: 0

    - name: "Set up cmake"
      uses: jwlawson/actions-setup-cmake@v1.4
      with:
        # This should always match the mininum required version in
        # our CMakeLists.txt
        cmake-version: '3.16.x'

    - name: "[Windows] Set up MSVC Developer Command Prompt"
      if: runner.os == 'Windows'
      uses: seanmiddleditch/gha-setup-vsdevenv@v3

    - name: "[macOS/Windows] Get build environment name"
      if: runner.os != 'Linux'
      id: buildenv_name
      run: ${{ matrix.buildenv_script }} name

    - name: "[macOS/Windows] Set up build environment cache"
      if: runner.os != 'Linux'
      uses: actions/cache@v2
      with:
        path: ${{ matrix.buildenv_basepath }}
        key: ${{ runner.os }}-buildenv-${{ env.BUILDENV_NAME }}

    - name: "[macOS] Import Apple code signing identity"
      id: apple_codesign
      if: runner.os == 'macOS' && env.MACOS_CODESIGN_OPENSSL_PASSWORD != null && env.MACOS_CODESIGN_CERTIFICATE_PASSWORD != null
      run: |
        # Decrypt the certificate
        openssl enc -aes-256-cbc -d -md sha512 \
          -k "${MACOS_CODESIGN_OPENSSL_PASSWORD}" \
          -in /Users/runner/work/mixxx/mixxx/packaging/certificates/macos_developer_id_codesign_certificate.p12.enc \
          -out ~/certificate.p12

        # Create a temporary keychain for the certificate and import it.
        security create-keychain -p mixxx Mixxx.keychain
        security unlock-keychain -p mixxx Mixxx.keychain
        security import ~/certificate.p12 -k Mixxx.keychain \
          -P "${MACOS_CODESIGN_CERTIFICATE_PASSWORD}" -A
        security set-key-partition-list -S "apple-tool:,apple:" -k mixxx Mixxx.keychain
        # Add keychain to search list
        security list-keychains -s Mixxx.keychain
        # Prevent keychain access from timing out
        security set-keychain-settings Mixxx.keychain
        echo "CMAKE_ARGS_EXTRA=${CMAKE_ARGS_EXTRA} -DAPPLE_CODESIGN_IDENTITY=${APPLE_CODESIGN_IDENTITY}" >> "${GITHUB_ENV}"

    - name: "[Windows] Set up Windows code signing"
      env:
        WINDOWS_CODESIGN_CERTIFICATE_PATH: ${{ github.workspace }}\packaging\certificates\windows_sectigo_codesign_certificate.pfx
        WINDOWS_CODESIGN_CERTIFICATE_PASSWORD: ${{ secrets.WINDOWS_CODESIGN_CERTIFICATE_PASSWORD }}
        WINDOWS_CODESIGN_SECURE_FILE_SALT: ${{ secrets.WINDOWS_CODESIGN_SECURE_FILE_SALT }}
        WINDOWS_CODESIGN_SECURE_FILE_SECRET: ${{ secrets.WINDOWS_CODESIGN_SECURE_FILE_SECRET }}
      if: runner.os == 'Windows' && env.WINDOWS_CODESIGN_SECURE_FILE_SALT != null && env.WINDOWS_CODESIGN_SECURE_FILE_SECRET != null
      run: |
        iex ((New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/appveyor/secure-file/master/install.ps1'))
        appveyor-tools/secure-file -decrypt "$Env:WINDOWS_CODESIGN_CERTIFICATE_PATH.enc" -secret "$Env:WINDOWS_CODESIGN_SECURE_FILE_SECRET" -salt "$Env:WINDOWS_CODESIGN_SECURE_FILE_SALT"
        Add-Content -Path "$Env:GITHUB_ENV" -Value "WINDOWS_CODESIGN_CERTIFICATE_PATH=$Env:WINDOWS_CODESIGN_CERTIFICATE_PATH"
        Add-Content -Path "$Env:GITHUB_ENV" -Value "WINDOWS_CODESIGN_CERTIFICATE_PASSWORD=$Env:WINDOWS_CODESIGN_CERTIFICATE_PASSWORD"
        Add-Content -Path "$Env:GITHUB_ENV" -Value "CMAKE_ARGS_EXTRA=-DWINDOWS_CODESIGN=ON"

    - name: "Set up build environment"
      id: buildenv
      run: ${{ matrix.buildenv_script }} setup
      env:
        BUILDENV_BASEPATH: ${{ matrix.buildenv_basepath }}

    - name: "[Ubuntu/macOS] Set compiler cache size limit"
      # Set size to 2 GiB
      run: ${{ matrix.compiler_cache }}  -M 2097152
      if: runner.os != 'windows'

    - name: "Set up compiler cache"
      uses: actions/cache@v2
      with:
        path: ${{ matrix.compiler_cache_path }}
        key: ${{ matrix.os }}-${{ matrix.compiler_cache }}-${{ github.head_ref }}-${{ github.run_number }}
        restore-keys: |
          ${{ matrix.os }}-${{ matrix.compiler_cache }}-${{ github.head_ref }}
          ${{ matrix.os }}-${{ matrix.compiler_cache }}

    - name: "Create build directory"
      run: mkdir build

    - name: "Configure"
      run: >-
        cmake
        -G "${{ matrix.cmake_generator }}"
        -DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }}
        -DCMAKE_PREFIX_PATH="${{ env.CMAKE_PREFIX_PATH }}"
        -DDEBUG_ASSERTIONS_FATAL=ON
        -DQt5_DIR=${{ env.QT_PATH }} ${{ matrix.cmake_args }} ${{ env.CMAKE_ARGS_EXTRA }}
        -DBATTERY=ON
        -DBROADCAST=ON
        -DHID=ON
        -DKEYFINDER=ON
        -DLILV=ON
        -DOPUS=ON
        -DQTKEYCHAIN=ON
        -DVINYLCONTROL=ON
        -DCMAKE_VERBOSE_MAKEFILE=OFF
        -L
        ..
      working-directory: build
      env:
        CC: ${{ matrix.cc }}
        CXX: ${{ matrix.cxx }}

    - name: "[Ubuntu/macOS] Set up gcc/clang problem matcher"
      if: runner.os != 'Windows'
      uses: ammaraskar/gcc-problem-matcher@master

    - name: "[Windows] Set up MSVC problem matcher"
      if: runner.os == 'Windows'
      uses: ammaraskar/msvc-problem-matcher@master

    - name: "Build"
      run: cmake --build . --config ${{ matrix.cmake_build_type }}
      working-directory: build
      env:
        CC: ${{ matrix.cc }}
        CXX: ${{ matrix.cxx }}
        CMAKE_BUILD_PARALLEL_LEVEL: 2
        # GitHub Actions automatically zstd compresses caches
        CCACHE_NOCOMPRESS: true
        SCCACHE_CACHE_SIZE: 2G

    - name: "Print compiler cache stats"
      run: ${{ matrix.compiler_cache }} -s

    - name: "Test"
      run: ctest --timeout 45 ${{ matrix.ctest_args }}
      working-directory: build
      env:
        # Render analyzer waveform tests to an offscreen buffer
        QT_QPA_PLATFORM: ${{ matrix.qt_qpa_platform }}
        GTEST_COLOR: 1
        # Windows tests fail randomly if run in parallel