Files
Jonathan Steffan 70282d57fd ci: fix ccache effectiveness for Linux and Android builds
- Disable CMake module scanning, which made compilations uncacheable.
- Linux: trailing "." on cache key so one preset's key is not a prefix of
  another's.
- Android: add ccache (action, CCACHE_BASEDIR, gradle compiler launcher).
- Save cache on master only; evict files unused by the job.
2026-11-11 11:19:21 -07:00

613 lines
22 KiB
YAML

name: Build
on:
push:
pull_request:
env:
BUILD_TYPE: Release
SERVER_DEPS: libx264-dev libavcodec-dev libavutil-dev libbsd-dev libavahi-client-dev libavahi-glib-dev libeigen3-dev nlohmann-json3-dev librsvg2-dev libdrm-dev libglib2.0-dev-bin libpipewire-0.3-dev libcli11-dev libnotify-dev libarchive-dev libudev-dev
CSS: images/wivrn-${{(github.ref_type == 'tag' && 'release') || 'nightly'}}.css
jobs:
build-linux:
name: Linux
runs-on: ubuntu-26.04
if: ${{ vars.APK_ONLY == '' }}
strategy:
fail-fast: false
matrix:
config:
- preset: 'client-no-system-boost'
packages: libharfbuzz-dev libfreetype-dev libavcodec-dev libavutil-dev libswscale-dev librsvg2-bin gettext libcurl4-openssl-dev libfontconfig-dev libpipewire-0.3-dev
- preset: 'dashboard'
packages: extra-cmake-modules libarchive-dev libboost-all-dev libkf6coreaddons-dev libkf6qqc2desktopstyle-dev libkf6iconthemes-dev libkirigami-dev librsvg2-dev nlohmann-json3-dev qcoro-qt6-dev qml6-module-org-kde-kirigamiaddons-formcard
- preset: 'dissector-no-system-boost'
packages: libboost-all-dev wireshark-dev
- preset: 'server'
packages: libboost-all-dev libsystemd-dev
# tracing is opt-in and rarely built; build it here so the instrumentation and the
# Perfetto SDK glue don't bitrot (WIVRN_TRACE_MONADO needs percetto, not packaged in CI)
- preset: 'server-tracing'
packages: libboost-all-dev libsystemd-dev
- preset: 'server-no-systemd'
packages: libboost-all-dev
- preset: 'server-no-system-boost'
packages: libsystemd-dev
steps:
- uses: actions/checkout@v6
- name: Apt dependencies
uses: awalsh128/[email protected]
with:
packages: ccache libvulkan-dev glslang-tools spirv-tools libwayland-dev libxrandr-dev ${{matrix.config.packages}} ${{ startsWith(matrix.config.preset, 'server') && env.SERVER_DEPS || ''}}
- name: ccache
uses: hendrikmuhs/[email protected]
with:
# The trailing "." keeps one preset's key from being a prefix of another's
key: linux-${{matrix.config.preset}}.
verbose: 1
job-summary: ''
evict-old-files: job
save: ${{ github.ref == 'refs/heads/master' }}
- uses: actions/cache@v5
with:
key: cmake-linux-${{matrix.config.preset}}
path: |
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.tar.*
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.zip
${{github.workspace}}/cmake-fetch/*.tar.*
${{github.workspace}}/cmake-fetch/*.tgz
${{github.workspace}}/cmake-fetch/*-src/.git
restore-keys: cmake-linux-
- name: Install dependencies
if: ${{ startswith(matrix.config.preset, 'client') }}
run: |
wget https://github.com/KhronosGroup/KTX-Software/releases/download/v4.4.2/KTX-Software-4.4.2-Linux-x86_64.deb
sudo dpkg --install KTX-Software-4.4.2-Linux-x86_64.deb
npm install --global @gltf-transform/[email protected]
- name: Fetch Perfetto SDK
if: ${{ matrix.config.preset == 'server-tracing' }}
# The amalgamated SDK is two files; install them where server/CMakeLists.txt looks.
env:
PERFETTO_TAG: v51.0
run: |
sudo mkdir -p /usr/share/perfetto/sdk
for f in perfetto.h perfetto.cc; do
sudo curl -fsSL -o /usr/share/perfetto/sdk/$f \
https://raw.githubusercontent.com/google/perfetto/${PERFETTO_TAG}/sdk/$f
done
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{github.workspace}}/build
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-DFETCHCONTENT_BASE_DIR=${{github.workspace}}/cmake-fetch
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
--preset ${{ matrix.config.preset }}
-DWIVRN_USE_SYSTEM_OPENXR=OFF
- name: Package build dependencies
if: ${{ matrix.config.preset == 'server' }}
# For easier packaging, build dependencies are made available as a separate archive
run: cd ${{github.workspace}}/cmake-fetch ; tar --create --xz --exclude .git --file ${{github.workspace}}/server-build-deps.tar.xz *-src
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Publish build dependencies
if: ${{ matrix.config.preset == 'server' }}
uses: actions/upload-artifact@v7
with:
name: server-build-deps
path: server-build-deps.tar.xz
- name: Release build dependencies
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/') && matrix.config.preset == 'server'
with:
tag_name: ${{ inputs.ref }}
generate_release_notes: true
draft: true
files: server-build-deps.tar.xz
build-steam-frame:
name: Steam Frame
runs-on: ubuntu-24.04-arm
if: ${{ vars.APK_ONLY == '' }}
container:
image: registry.gitlab.steamos.cloud/steamrt/steamrt4/sdk/arm64:4.0.20260805.254769
volumes:
- ${{github.workspace}}/install:/tmp/install
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: Apt dependencies
uses: awalsh128/[email protected]
with:
packages: librsvg2-bin npm
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: steam-frame
verbose: 1
job-summary: ''
evict-old-files: job
save: ${{ github.ref == 'refs/heads/master' }}
restore-keys: steam-frame
- uses: actions/cache@v5
with:
key: cmake-frame
path: |
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.tar.*
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.zip
${{github.workspace}}/cmake-fetch/*.tar.*
${{github.workspace}}/cmake-fetch/*.tgz
${{github.workspace}}/cmake-fetch/*-src/.git
- name: Install dependencies
run: |
wget https://github.com/KhronosGroup/KTX-Software/releases/download/v4.4.2/KTX-Software-4.4.2-Linux-arm64.deb
sudo dpkg --install KTX-Software-4.4.2-Linux-arm64.deb
npm install --global @gltf-transform/[email protected]
- name: Configure CMake
run: >
cmake -B "$GITHUB_WORKSPACE/build"
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-DWIVRN_CSS=${{env.CSS}}
-DFETCHCONTENT_BASE_DIR="$GITHUB_WORKSPACE/cmake-fetch"
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_INSTALL_PREFIX=/usr
--preset frame
- name: Build
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
cd "$GITHUB_WORKSPACE/build"
DESTDIR="$GITHUB_WORKSPACE/install" ninja install
- name: Archive
uses: actions/upload-artifact@v7
with:
name: wivrn-frame-client.zip
path: install/usr
if-no-files-found: error
retention-days: 30
build-server-flatpak:
name: Linux server (flatpak)
runs-on: ubuntu-24.04
if: ${{ vars.APK_ONLY == '' }}
container:
# Tag matches runtime-version in the manifest.
image: ghcr.io/flathub-infra/flatpak-github-actions:kde-6.11
options: --privileged
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/cache/restore@v5
id: cache
with:
path: |
flatpak/monado-*.tar.gz
flatpak/xrizer-gen-src-*.json
.flatpak-builder
key: flatpak-build-${{ hashFiles('flatpak/io.github.wivrn.wivrn.yml.in', 'flatpak/ct-ng-x86_64.config', 'flatpak/ct-ng-aarch64.config', 'monado-rev') }}
restore-keys: flatpak-build-
- name: Create the flatpak manifest
run: |
git config --global --add safe.directory $(pwd)
pip install toml aiohttp
tools/gen_flatpak_manifest.py --gitlocal --out flatpak
cat flatpak/io.github.wivrn.wivrn.yml
- name: Update flatpak runtimes
run: |
for i in 1 2 3; do
flatpak update -y --noninteractive && exit 0
echo "flatpak update failed (attempt $i), retrying"
sleep 20
done
exit 1
- uses: flatpak/flatpak-github-actions/[email protected]
with:
manifest-path: flatpak/io.github.wivrn.wivrn.yml
bundle: wivrn-server.flatpak
restore-cache: false
save-cache: false
- uses: actions/cache/save@v5
if: success() && steps.cache.outputs.cache-hit != 'true'
with:
path: |
flatpak/monado-*.tar.gz
flatpak/xrizer-gen-src-*.json
.flatpak-builder
key: flatpak-build-${{ hashFiles('flatpak/io.github.wivrn.wivrn.yml.in', 'flatpak/ct-ng-x86_64.config', 'flatpak/ct-ng-aarch64.config', 'monado-rev') }}
- name: Debug bundle
uses: actions/upload-artifact@v7
if: failure()
with:
name: flatpak-debug
path: .flatpak-builder
include-hidden-files: true
retention-days: 1
nix-test:
name: Test Nix package and devshell
runs-on: ubuntu-24.04
if: ${{ vars.APK_ONLY == '' }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: cachix/install-nix-action@v31
- run: nix flake check
- run: nix build --print-build-logs
build-android:
name: Android
runs-on: ubuntu-24.04
if: ${{ vars.APK_ONLY == '' }}
strategy:
matrix:
buildtype: ['Release', 'Debug', 'DebugWithValidationLayer', 'Oculus']
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/cache@v5
with:
key: cmake-android-${{matrix.buildtype}}
path: |
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.tar.*
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.zip
${{github.workspace}}/cmake-fetch/*.tar.*
${{github.workspace}}/cmake-fetch/*.zip
${{github.workspace}}/cmake-fetch/*.tgz
restore-keys: cmake-android-
- name: ccache
uses: hendrikmuhs/[email protected]
with:
# The trailing "." keeps one build type's key from being a prefix of another's
key: android-${{matrix.buildtype}}.
verbose: 1
job-summary: ''
evict-old-files: job
save: ${{ github.ref == 'refs/heads/master' }}
# Gradle distribution and the Android plugin's dependencies.
- uses: actions/cache@v5
with:
key: gradle-android-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', 'build.gradle') }}
path: |
~/.gradle/caches
~/.gradle/wrapper
restore-keys: gradle-android-
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install glslang-tools spirv-tools librsvg2-bin gettext
wget https://github.com/KhronosGroup/KTX-Software/releases/download/v4.3.2/KTX-Software-4.3.2-Linux-x86_64.deb
sudo dpkg --install KTX-Software-4.3.2-Linux-x86_64.deb
npm install --global @gltf-transform/cli
- name: Check for Secret availability
id: secret-check
shell: bash
run: |
if [[ "${{ secrets.APK_SIGNINGKEYPASSWORD }}" != '' && "${{ secrets.APK_KEYSTORE_BASE64 }}" != '' ]]; then
echo "available=true" >> $GITHUB_OUTPUT;
else
echo "available=false" >> $GITHUB_OUTPUT;
fi
if [[ "${{ secrets.OCULUS_TOKEN }}" != '' ]]; then
echo "oculus-token=true" >> $GITHUB_OUTPUT;
else
echo "oculus-token=false" >> $GITHUB_OUTPUT;
fi
- name: Secrets
if: ${{ steps.secret-check.outputs.available == 'true' }}
env:
APK_SIGNINGKEYPASSWORD: ${{ secrets.APK_SIGNINGKEYPASSWORD }}
APK_KEYSTORE_BASE64: ${{ secrets.APK_KEYSTORE_BASE64 }}
run: |
echo signingKeyPassword="$APK_SIGNINGKEYPASSWORD" > gradle.properties
echo "$APK_KEYSTORE_BASE64" | base64 --decode --ignore-garbage > ks.keystore
- name: Build
env:
# Paths under the workspace are hashed relative to it
CCACHE_BASEDIR: ${{github.workspace}}
run: |
VERSION=$(git describe --tags --always | sed "s/^v\([0-9]\)/\1/")
if [ ${{ matrix.buildtype }} = 'Oculus' ]
then
SUFFIX=""
VERSION_CODE=$(( 2 * $(git rev-list --count HEAD) ))
if [ ${{ github.ref_type }} = 'tag' ]
then
VERSION_CODE=$(( $VERSION_CODE + 1 ))
fi
APPNAME=WiVRn
else
VERSION_CODE=1
if [ ${{ github.ref_type }} = 'tag' ]
then
SUFFIX=".github"
APPNAME="WiVRn"
else
SUFFIX=".github.testing"
APPNAME="WiVRn Testing"
fi
fi
echo Setting version $VERSION and version code $VERSION_CODE in manifest
echo Using stylesheet ${{env.CSS}} and name $APPNAME
chmod +x gradlew
./gradlew \
-Pwivrn_version=$VERSION \
-Pwivrn_versionCode=$VERSION_CODE \
-Psuffix=$SUFFIX \
-Pwivrn_css=${{env.CSS}} \
-Pwivrn_app_name="$APPNAME" \
-Pwivrn_compress_glb=ON \
-Pfetchcontent_base_dir=${{github.workspace}}/cmake-fetch \
-Pcompiler_launcher=ccache \
assemble${{ matrix.buildtype }}
- name: Upload build dir
uses: actions/upload-artifact@v7
if: failure()
with:
name: android-cxx-debug-${{ matrix.buildtype }}
path: .cxx
include-hidden-files: true
retention-days: 1
- name: Prepare before archiving artifacts
run: |
mkdir apk
mv $(find build/outputs/apk/ -name "*.apk") apk/
mkdir debug
mv build/intermediates/merged_native_libs/*/*/out/lib/* debug/
find debug -name libopenxr_loader.so -delete
- name: Archive APK
uses: actions/upload-artifact@v7
if: ${{ matrix.buildtype != 'Oculus' }}
with:
name: apk-${{ (steps.secret-check.outputs.available == 'false' && matrix.buildtype == 'Release') && 'Release-unsigned' || matrix.buildtype }}
path: apk/*.apk
retention-days: 30
- name: Archive debug symbols
uses: actions/upload-artifact@v7
with:
name: symbols-${{ matrix.buildtype }}
path: debug/**/*.so
- name: Push to Oculus store
if: ${{ matrix.buildtype == 'Oculus' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master') && steps.secret-check.outputs.oculus-token == 'true' }}
env:
OCULUS_TOKEN: ${{ secrets.OCULUS_TOKEN }}
run: |
curl -L 'https://www.oculus.com/download_app/?id=5159709737372459' -o ovr-platform-util
chmod +x ovr-platform-util
if [ ${{ github.ref_type }} = 'tag' ]
then
CHANNEL=RC
IS_DRAFT=--draft
else
CHANNEL=NIGHTLY
IS_DRAFT=
fi
./ovr-platform-util upload-quest-build --app-id 7959676140827574 --token $OCULUS_TOKEN --apk apk/WiVRn-oculus.apk --channel $CHANNEL --age-group TEENS_AND_ADULTS $IS_DRAFT --debug_symbols_dir debug/ --debug-symbols-pattern '*.so'
build-ubuntu:
name: Build Ubuntu package
if: ${{ vars.APK_ONLY == '' }}
strategy:
fail-fast: false
matrix:
distro: ['plucky']
runs-on: ubuntu-24.04
container: ubuntu:${{ matrix.distro }}
steps:
- name: Install dependencies
run: |
apt update
apt install --yes libcjson-dev libx264-dev libavcodec-dev libavutil-dev libswscale-dev libavfilter-dev libbsd-dev libavahi-client-dev libavahi-glib-dev libeigen3-dev glslang-tools libudev-dev libwayland-dev libx11-xcb-dev libxrandr-dev libxcb-randr0-dev libgl-dev libglx-dev mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev libsystemd-dev libva-dev nlohmann-json3-dev xz-utils libpipewire-0.3-dev libcli11-dev qt6-base-dev qt6-tools-dev pkexec libboost-all-dev librsvg2-bin dpkg-dev pkg-config debhelper-compat build-essential lintian cmake libnotify-dev qt6-declarative-dev extra-cmake-modules libkirigami-dev libkf6i18n-dev libkf6coreaddons-dev libkf6qqc2desktopstyle-dev libkf6iconthemes-dev jq sudo cmake gcc g++ git wget libssl-dev qcoro-qt6-dev librsvg2-dev libarchive-dev npm qml6-module-org-kde-kirigamiaddons-formcard
wget https://github.com/KhronosGroup/KTX-Software/releases/download/v4.3.2/KTX-Software-4.3.2-Linux-x86_64.deb
sudo dpkg --install KTX-Software-4.3.2-Linux-x86_64.deb
npm install --global @gltf-transform/cli
- uses: actions/checkout@v6
with:
fetch-depth: 0
path: wivrn
- name: Download monado
run: |
MONADO_COMMIT=$(cat wivrn/monado-rev)
wget https://gitlab.freedesktop.org/monado/monado/-/archive/$MONADO_COMMIT/monado-$MONADO_COMMIT.tar.gz
mkdir wivrn/monado-src
tar xzf monado-*.tar.gz --strip-components=1 -C wivrn/monado-src
- name: Patch monado
working-directory: wivrn/monado-src
run: ../patches/apply.sh ../patches/monado/*
- name: Download stb
run: |
wget https://github.com/nothings/stb/archive/013ac3beddff3dbffafd5177e7972067cd2b5083.tar.gz -O stb.tar.gz
mkdir wivrn/stb-src
tar xzf stb.tar.gz --strip-components=1 -C wivrn/stb-src
- name: Edit changelog
working-directory: wivrn
run: >
tools/gen_debian_changelog.py
--out debian/changelog
${{ (startsWith(github.ref, 'refs/tags/') && '' ) || '--nightly' }}
--author "github-actions <[email protected]>"
--distribution "${{ matrix.distro }}";
cat debian/changelog
- name: Build package
working-directory: wivrn
run: dpkg-buildpackage --build=binary --no-sign
- name: Publish package
uses: actions/upload-artifact@v7
with:
name: wivrn-${{ matrix.distro }}
path: |
*.deb
*.ddeb
- name: Check package
working-directory: wivrn
run: lintian --fail-on error | sed -e s/^W:/::warning::/ -e s/^E:/::error::/
release:
name: Create release
runs-on: ubuntu-22.04
needs: [build-linux, build-android, build-server-flatpak, build-ubuntu]
if: success() && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
path: wivrn
- name: Check for FLATHUB_TOKEN
id: flathub-token-check
shell: bash
run: |
if [[ "${{ secrets.FLATHUB_TOKEN}}" != '' ]]; then
echo "available=true" >> $GITHUB_OUTPUT;
else
echo "available=false" >> $GITHUB_OUTPUT;
fi
- uses: actions/checkout@v6
if: ${{ steps.flathub-token-check.outputs.available == 'true' }}
with:
fetch-depth: 0
repository: ${{ github.repository_owner }}/io.github.wivrn.wivrn
path: flathub
token: ${{ secrets.FLATHUB_TOKEN }}
- name: Download artifacts (APK)
uses: actions/download-artifact@v8
with:
name: apk-Release
path: apk
- name: Download artifacts (flatpak)
uses: actions/download-artifact@v8
with:
name: wivrn-server-x86_64.flatpak
path: flatpak
- name: Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ inputs.ref }}
generate_release_notes: true
draft: true
files: |
apk/*.apk
flatpak/*.flatpak
- name: Update flatpak manifest for flathub
if: ${{ steps.flathub-token-check.outputs.available == 'true' }}
run: |
WIVRN_TAG=$(echo $GITHUB_REF | sed -E -e "s,refs/[^/]*/v?,,")
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
sudo apt-get install python3-toml python3-aiohttp
cd flathub
git remote add upstream https://github.com/flathub/io.github.wivrn.wivrn.git
git fetch upstream
git reset --hard upstream/master
git config --global --add safe.directory $(pwd)
../wivrn/tools/gen_flatpak_manifest.py --git https://github.com/${{github.repository}}.git
cp ../wivrn/flatpak/*.config .
git checkout -b $WIVRN_TAG
git add io.github.wivrn.wivrn.yml xrizer-gen-src.json *.config
git commit -m "Version "$WIVRN_TAG
git push --set-upstream origin $WIVRN_TAG
git show
sync_fork_downstream:
name: Sync fork downstream
runs-on: ubuntu-24.04
needs: [build-linux, build-android]
if: ${{ vars.APK_ONLY == '' && github.ref == 'refs/heads/master' }}
steps:
- name: Check for DOWNSTREAM_GITHUB_TOKEN
id: downstream-secret-check
shell: bash
run: |
if [[ "${{ secrets.DOWNSTREAM_GITHUB_TOKEN }}" != '' ]]; then
echo "available=true" >> $GITHUB_OUTPUT;
else
echo "available=false" >> $GITHUB_OUTPUT;
fi
- name: Sync fork downstream
if: ${{ steps.downstream-secret-check.outputs.available == 'true' }}
run: |
curl -X POST -H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.DOWNSTREAM_GITHUB_TOKEN }}" \
https://api.github.com/repos/WiVRn/WiVRn-APK/merge-upstream \
-d '{"branch":"master"}'