@@ -13,128 +13,99 @@ env:
1313 CTEST_PARALLEL_LEVEL : 2
1414
1515jobs :
16- # ###################
17- # Linux / macOS
18- # ###################
19-
20- Unix :
16+ Build :
2117 name : ${{ matrix.name }} (${{ matrix.config }})
2218 runs-on : ${{ matrix.os }}
2319 strategy :
2420 fail-fast : false
2521 matrix :
26- os : [ubuntu-20.04 , macos-latest]
22+ os : [ubuntu-latest , macos-latest, windows -latest]
2723 config : [Debug, Release]
2824 include :
2925 - os : macos-latest
3026 name : macOS
31- - os : ubuntu-20.04
27+ - os : ubuntu-latest
3228 name : Linux
29+ - os : windows-latest
30+ name : Windows
3331 steps :
3432 - name : Checkout repository
35- uses : actions/checkout@v3
33+ uses : actions/checkout@v4.0.0
3634 with :
3735 fetch-depth : 10
3836
3937 - name : Dependencies (Linux)
4038 if : runner.os == 'Linux'
4139 run : |
42- sudo apt-get update
43- sudo apt-get install ccache
40+ sudo apt-get install ccache
41+ echo 'CACHE_PATH=~/.cache/ccache' >> "$GITHUB_ENV"
4442
4543 - name : Dependencies (macOS)
4644 if : runner.os == 'macOS'
47- run : brew install ccache
45+ run : |
46+ brew install ccache
47+ echo 'CACHE_PATH=~/Library/Caches/ccache' >> "$GITHUB_ENV"
48+
49+ - name : Dependencies (Windows)
50+ if : runner.os == 'Windows'
51+ run : |
52+ choco install ccache
53+ "CACHE_PATH=${env:LOCALAPPDATA}\ccache" | Out-File -FilePath $env:GITHUB_ENV -Append
54+
55+ # Install Ninja (only needed on Windows)
56+ - name : Install Ninja
57+ if : runner.os == 'Windows'
58+ uses : seanmiddleditch/gha-setup-ninja@master
59+
60+ - name : Get number of CPU cores
61+ 62+ id : cpu-cores
4863
4964 - name : Cache Build
5065 id : cache-build
51- uses : actions/cache@v1
66+ uses : actions/cache@v4
5267 with :
53- path : ~/.ccache
68+ path : ${{ env.CACHE_PATH }}
5469 key : ${{ runner.os }}-${{ matrix.config }}-cache
5570
5671 - name : Prepare ccache
5772 run : |
5873 ccache --max-size=1.0G
59- ccache -V && ccache --show-stats && ccache --zero-stats
74+ ccache -V && ccache --show-config
75+ ccache --show-stats && ccache --zero-stats
6076
61- - name : Configure
77+ - name : Configure (Linux/macOS)
78+ if : runner.os != 'Windows'
6279 run : |
6380 mkdir -p build
6481 cd build
6582 cmake .. \
66- -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
6783 -DFINITE_DIFF_BUILD_UNIT_TESTS=ON \
6884 -DCMAKE_BUILD_TYPE=${{ matrix.config }}
6985
70- - name : Build
71- run : cd build; make -j2; ccache --show-stats
72-
73- - name : Tests
74- run : cd build; ctest --verbose
75-
76- # ###################
77- # Windows
78- # ###################
79-
80- Windows :
81- name : ${{ matrix.name }} (${{ matrix.config }})
82- runs-on : windows-2019
83- env :
84- CC : cl.exe
85- CXX : cl.exe
86- SCCACHE_IDLE_TIMEOUT : " 12000"
87- strategy :
88- fail-fast : false
89- matrix :
90- config : [Debug, Release]
91- include :
92- - os : windows-2019
93- name : Windows
94- steps :
95- - name : Checkout repository
96- uses : actions/checkout@v3
97- with :
98- fetch-depth : 10
99- - uses : seanmiddleditch/gha-setup-ninja@master
100-
101- # https://github.com/actions/cache/issues/101
102- - name : Set env
103- run : |
104- echo "appdata=$env:LOCALAPPDATA" >> ${env:GITHUB_ENV}
105-
106- - name : Cache build
107- id : cache-build
108- uses : actions/cache@v2
109- with :
110- path : ${{ env.appdata }}\Mozilla\sccache
111- key : ${{ runner.os }}-${{ matrix.config }}-cache-${{ github.sha }}
112- restore-keys : ${{ runner.os }}-${{ matrix.config }}-cache
113-
114- - name : Prepare sccache
115- run : |
116- iwr -useb 'https://raw.githubusercontent.com/scoopinstaller/install/master/install.ps1' -outfile 'install.ps1'
117- .\install.ps1 -RunAsAdmin
118- scoop install sccache --global
119- # Scoop modifies the PATH so we make it available for the next steps of the job
120- echo "${env:PATH}" >> ${env:GITHUB_PATH}
121-
122- # We run configure + build in the same step, since they both need to call VsDevCmd
123- # Also, cmd uses ^ to break commands into multiple lines (in powershell this is `)
124- - name : Configure and build
86+ - name : Configure (Windows)
87+ if : runner.os == 'Windows'
12588 shell : cmd
12689 run : |
127- call "C:\Program Files (x86) \Microsoft Visual Studio\2019 \Enterprise\Common7\Tools\VsDevCmd.bat" -arch=x64
90+ call "C:\Program Files\Microsoft Visual Studio\2022 \Enterprise\Common7\Tools\VsDevCmd.bat" -arch=x64
12891 cmake -G Ninja ^
129- -DCMAKE_CXX_COMPILER_LAUNCHER=sccache ^
130- -DCMAKE_BUILD_TYPE=${{ matrix.config }} ^
13192 -DFINITE_DIFF_BUILD_UNIT_TESTS=ON ^
93+ -DCMAKE_BUILD_TYPE=${{ matrix.config }} ^
13294 -B build ^
13395 -S .
134- cd build
135- ninja -j1
13696
137- - name : Tests
97+ - name : Build (Linux/macOS)
98+ if : runner.os != 'Windows'
13899 run : |
139- cd build
140- ctest --verbose --output-on-failure
100+ cmake --build build -j ${{ steps.cpu-cores.outputs.count }}
101+ ccache --show-stats
102+
103+ - name : Build (Windows)
104+ if : runner.os == 'Windows'
105+ shell : cmd
106+ run : |
107+ call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=x64
108+ cmake --build build -j ${{ steps.cpu-cores.outputs.count }} && ccache --show-stats
109+
110+ - name : Tests
111+ run : cd build; ctest --verbose -j ${{ steps.cpu-cores.outputs.count }}
0 commit comments