@@ -3,20 +3,32 @@ name: Build and test OpenVR driver
33on : [ push, pull_request, workflow_dispatch ]
44
55jobs :
6+ setup-matrix :
7+ name : Setup build matrix
8+ runs-on : ubuntu-latest
9+ outputs :
10+ matrix : ${{ steps.setup-matrix.outputs.matrix }}
11+ steps :
12+ - id : setup-matrix
13+ shell : bash
14+ run : |
15+ cat <<EOF | jq -c >> $GITHUB_OUTPUT
16+ {
17+ "include": [
18+ {"os": "windows-2025", "name": "win64"},
19+ {"os": "ubuntu-latest", "name": "x64-linux"},
20+ {"os": "ubuntu-24.04-arm", "name": "aarch64-linux"}
21+ ]
22+ }
23+ EOF
24+
625 build :
726 name : Build (${{ matrix.os }})
27+ needs : [setup-matrix]
828 runs-on : ${{ matrix.os }}
929 strategy :
1030 fail-fast : false
11- matrix :
12- os : [windows-2025, ubuntu-latest, ubuntu-24.04-arm]
13- include :
14- - os : windows-2025
15- name : win64
16- - os : ubuntu-latest
17- name : x64-linux
18- - os : ubuntu-24.04-arm
19- name : aarch64-linux
31+ matrix : ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
2032 env :
2133 # Indicates the CMake build directory where project files and binaries are being produced.
2234 CMAKE_BUILD_DIR : ${{ github.workspace }}/build
@@ -26,35 +38,51 @@ jobs:
2638 with :
2739 submodules : true
2840
29- - if : matrix.os == 'ubuntu-latest'
30- name : Install Ninja
31- uses : awalsh128/cache-apt-pkgs-action@v1.6.0
32- with :
33- add-repository : ' ppa:ubuntu-toolchain-r/test'
34- packages : ninja-build
35- version : 1.0
41+ - name : Generate cache key
42+ id : gen-cache-key
43+ shell : bash
44+ run : |
45+ echo "cache-key=${{ matrix.os }}-$(git submodule foreach --recursive git rev-parse HEAD)-${{ hashFiles('CMakeLists.txt') }}" >> $GITHUB_OUTPUT
3646
37- - uses : lukka/get-cmake@latest
47+ - name : Set up CPM cache
48+ id : setup-cpm-cache
49+ uses : actions/cache@v5
50+ with :
51+ path : ~/cpm-cache
52+ key : cpm-${{ steps.gen-cache-key.outputs.cache-key }}
53+ restore-keys : |
54+ cpm-${{ matrix.os }}-
3855
3956 - uses : hendrikmuhs/ccache-action@v1.2
40-
41- - name : Get submodule commit hashes
42- id : submodule_hashes
43- run : git submodule foreach --recursive git rev-parse HEAD > submodule_hashes.txt
57+ id : setup-ccache
58+ with :
59+ key : ccache-${{ steps.gen-cache-key.outputs.cache-key }}
60+ restore-keys : |
61+ ccache-${{ matrix.os }}-
4462
4563 - if : matrix.os == 'windows-2025'
4664 name : Configure and build on Windows
4765 shell : cmd
4866 run : |
4967 call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
50- cmake -S "${{ github.workspace }}" -B "${{ env.CMAKE_BUILD_DIR }}" -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=Release -DSLIMEVR_BUILD_TESTS=ON
51- cmake --build "${{ env.CMAKE_BUILD_DIR }}" --config Release -j 6 --
68+ cmake -S "${{ github.workspace }}" -B "${{ env.CMAKE_BUILD_DIR }}" -G Ninja \
69+ -DCPM_SOURCE_CACHE=%USERPROFILE%\cpm-cache
70+ -DCMAKE_C_COMPILER_LAUNCHER=ccache
71+ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
72+ -DSLIMEVR_BUILD_TESTS=ON
73+ -DCMAKE_BUILD_TYPE=Release
74+ cmake --build "${{ env.CMAKE_BUILD_DIR }}" --config Release -j6
5275
5376 - if : matrix.os != 'windows-2025'
5477 name : Configure and build on Unix
5578 run : |
56- cmake -S "${{ github.workspace }}" -B "${{ env.CMAKE_BUILD_DIR }}" -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=Release -DSLIMEVR_BUILD_TESTS=ON
57- cmake --build "${{ env.CMAKE_BUILD_DIR }}" --config Release -j 6 --
79+ cmake -S "${{ github.workspace }}" -B "${{ env.CMAKE_BUILD_DIR }}" -G Ninja \
80+ -DCPM_SOURCE_CACHE=~/cpm-cache
81+ -DCMAKE_C_COMPILER_LAUNCHER=ccache
82+ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
83+ -DSLIMEVR_BUILD_TESTS=ON
84+ -DCMAKE_BUILD_TYPE=Release
85+ cmake --build "${{ env.CMAKE_BUILD_DIR }}" --config Release -j6
5886
5987 - name : Upload driver
6088 uses : actions/upload-artifact@v7
@@ -70,19 +98,11 @@ jobs:
7098
7199 test :
72100 name : Run tests (${{ matrix.os }})
73- needs : build
74- runs-on : ${{ matrix.os }}
101+ needs : [setup-matrix, build]
75102 strategy :
76103 fail-fast : false
77- matrix :
78- os : [windows-2025, ubuntu-latest, ubuntu-24.04-arm]
79- include :
80- - os : windows-2025
81- name : win64
82- - os : ubuntu-latest
83- name : x64-linux
84- - os : ubuntu-24.04-arm
85- name : aarch64-linux
104+ matrix : ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
105+ runs-on : ${{ matrix.os }}
86106 steps :
87107 - name : Download build artifact
88108 uses : actions/download-artifact@v8
0 commit comments