Build suddenly failed on Github Actions for MacOS
I have started to add some of my projects to Github Actions in stead of building everything locally with Jenkins. Github Actions is free for Open Source projects, and it's a convenient way for me to check that everything works on Linux, Windows and MacOS.
To guard against problems with newer versions of boost libraries or compilers I have configured Github Actions to rebuild my projects every month even if I don't update anything.
May first, all my projects failed building on MacOS. The problem seems to
be that they have upgraded their runners from X64 to ARM64 hardware.
I use an action, aminya/setup-cpp@v1
to install the the C++ compiler,
CMake and Ninja before the build. It seems like it's broken for the
runners Github Actions use for MacOS now.
The solution was do remove the compiler name from the matrix for MacOS, and add a new step where I simply use homebrew to install a recent llvm compiler.
This is the new workflow for one of the projects:
1name: CI
2on:
3 push:
4 pull_request:
5 schedule:
6 - cron: '0 0 1 * *' # This line schedules the workflow to run at 00:00 on the first day of every month
7jobs:
8 build:
9 runs-on: ${{ matrix.os }}
10 strategy:
11 matrix:
12 include:
13 - os: ubuntu-latest
14 compiler: gcc
15 - os: ubuntu-latest
16 compiler: clang
17 - os: windows-latest
18 compiler: msvc
19 - os: macos-latest
20 compiler:
21
22 steps:
23 - name: Checkout code
24 uses: actions/checkout@v4
25 with:
26 submodules: true
27
28 - name: Cache
29 uses: actions/cache@v4
30 with:
31 path: |
32 ~/vcpkg
33 ./build/vcpkg_installed
34 ${{ env.HOME }}/.cache/vcpkg/archives
35 ${{ env.XDG_CACHE_HOME }}/vcpkg/archives
36 ${{ env.LOCALAPPDATA }}\vcpkg\archives
37 ${{ env.APPDATA }}\vcpkg\archives
38 key: ${{ runner.os }}-${{ matrix.compiler }}-${{ env.BUILD_TYPE }}-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('./vcpkg.json')}}
39 restore-keys: |
40 ${{ runner.os }}-${{ env.BUILD_TYPE }}-
41
42 - name: Setup Cpp
43 uses: aminya/setup-cpp@v1
44 with:
45 compiler: ${{ matrix.compiler }}
46 vcvarsall: ${{ contains(matrix.os, 'windows') }}
47 cmake: true
48 ninja: true
49 vcpkg: true
50 cppcheck: false
51
52 - name: Install compiler for Macos
53 if: startsWith(matrix.os, 'macos')
54 run: |
55 brew install llvm
56
57 - name: Prepare the PATH
58 run: |
59 if [[ "${{ runner.os }}" == "Windows" ]]; then
60 echo "$env:USERPROFILE\vcpkg" >> $GITHUB_PATH
61 echo "$env:USERPROFILE\ninja" >> $GITHUB_PATH
62 else
63 echo "$HOME/vcpkg" >> $GITHUB_PATH
64 echo "$HOME/ninja" >> $GITHUB_PATH
65 fi
66 shell: bash
67
68 - name: Install dependencies
69 run: |
70 vcpkg install
71
72 - name: Build project
73 shell: bash
74 run: |
75 if [ -d build ]; then
76 echo "Build dir exists"
77 ls -la build
78 else
79 mkdir build
80 fi
81 pushd build
82 cmake .. -DCMAKE_BUILD_TYPE=Release -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake
83 cmake --build .
84 popd
85
86 - name: Run Unit Tests
87 run: |
88 pushd build
89 ctest -C Release
90 popd
91 shell: bash
92
This has a new step, Install compiler for Macos that works.