@@ -3,20 +3,33 @@ 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 > matrix.json
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+ echo "matrix=$(cat matrix.json)" >> $GITHUB_OUTPUT
25+
626 build :
727 name : Build (${{ matrix.os }})
28+ needs : [setup-matrix]
829 runs-on : ${{ matrix.os }}
930 strategy :
1031 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
32+ matrix : ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
2033 env :
2134 # Indicates the CMake build directory where project files and binaries are being produced.
2235 CMAKE_BUILD_DIR : ${{ github.workspace }}/build
@@ -26,35 +39,55 @@ jobs:
2639 with :
2740 submodules : true
2841
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
42+ - name : Get submodule commit hashes
43+ id : get-submodule-commit-hashes
44+ run : git submodule foreach --recursive git rev-parse HEAD > submodule-hashes.txt
3645
37- - uses : lukka/get-cmake@latest
46+ - name : Generate cache key
47+ id : gen-cache-key
48+ shell : bash
49+ run : |
50+ echo "cache-key=${{ matrix.os }}-${{ hashFiles('submodule-hashes.txt') }}-${{ hashFiles('CMakeLists.txt') }}" >> $GITHUB_OUTPUT
3851
39- - uses : hendrikmuhs/ccache-action@v1.2
52+ - name : Set up CPM cache
53+ id : setup-cpm-cache
54+ uses : actions/cache@v5
55+ with :
56+ path : ~/cpm-cache
57+ key : cpm-${{ steps.gen-cache-key.outputs.cache-key }}
58+ restore-keys : |
59+ cpm-${{ matrix.os }}-
4060
41- - name : Get submodule commit hashes
42- id : submodule_hashes
43- run : git submodule foreach --recursive git rev-parse HEAD > submodule_hashes.txt
61+ - uses : hendrikmuhs/ccache-action@v1.2
62+ id : setup-ccache
63+ with :
64+ key : ccache-${{ steps.gen-cache-key.outputs.cache-key }}
65+ restore-keys : |
66+ ccache-${{ matrix.os }}-
4467
4568 - if : matrix.os == 'windows-2025'
4669 name : Configure and build on Windows
4770 shell : cmd
4871 run : |
4972 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 --
73+ cmake -S "${{ github.workspace }}" -B "${{ env.CMAKE_BUILD_DIR }}" -G Ninja ^
74+ -DCPM_SOURCE_CACHE=%USERPROFILE%\cpm-cache ^
75+ -DCMAKE_C_COMPILER_LAUNCHER=ccache ^
76+ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ^
77+ -DSLIMEVR_BUILD_TESTS=ON ^
78+ -DCMAKE_BUILD_TYPE=Release
79+ cmake --build "${{ env.CMAKE_BUILD_DIR }}" --config Release -j6
5280
5381 - if : matrix.os != 'windows-2025'
5482 name : Configure and build on Unix
5583 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 --
84+ cmake -S "${{ github.workspace }}" -B "${{ env.CMAKE_BUILD_DIR }}" -G Ninja \
85+ -DCPM_SOURCE_CACHE=~/cpm-cache \
86+ -DCMAKE_C_COMPILER_LAUNCHER=ccache \
87+ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
88+ -DSLIMEVR_BUILD_TESTS=ON \
89+ -DCMAKE_BUILD_TYPE=Release
90+ cmake --build "${{ env.CMAKE_BUILD_DIR }}" --config Release -j6
5891
5992 - name : Upload driver
6093 uses : actions/upload-artifact@v7
@@ -70,19 +103,11 @@ jobs:
70103
71104 test :
72105 name : Run tests (${{ matrix.os }})
73- needs : build
74- runs-on : ${{ matrix.os }}
106+ needs : [setup-matrix, build]
75107 strategy :
76108 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
109+ matrix : ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
110+ runs-on : ${{ matrix.os }}
86111 steps :
87112 - name : Download build artifact
88113 uses : actions/download-artifact@v8
0 commit comments