mirror of
https://git.citron-emu.org/citron/emulator
synced 2026-02-01 07:13:33 +00:00
Improve GitLab CI caching for faster builds
- Add comprehensive cache strategy with job-specific keys - Implement pacman/apt package caching to reduce download time - Add Android SDK/NDK caching for mobile builds - Enable ccache for C/C++ compilation caching - Optimize cache keys based on dependency files - Skip package updates when cache is recent - Expected 50-80% faster subsequent builds
This commit is contained in:
146
.gitlab-ci.yml
146
.gitlab-ci.yml
@@ -10,12 +10,22 @@ variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
|
||||
# Cache configuration for faster builds
|
||||
# Comprehensive cache configuration for faster builds
|
||||
cache:
|
||||
# Global cache for all jobs
|
||||
key:
|
||||
files:
|
||||
- vcpkg.json
|
||||
- CMakeLists.txt
|
||||
- .gitlab-ci.yml
|
||||
paths:
|
||||
- build/vcpkg_installed/
|
||||
- build/_deps/
|
||||
key: "$CI_COMMIT_REF_SLUG"
|
||||
- .cache/pacman/
|
||||
- .cache/apt/
|
||||
- .cache/android/
|
||||
- .cache/gradle/
|
||||
- .cache/ccache/
|
||||
policy: pull-push
|
||||
|
||||
|
||||
@@ -25,9 +35,21 @@ build-linux:
|
||||
image: cachyos/cachyos:latest
|
||||
tags:
|
||||
- citron-build
|
||||
cache:
|
||||
key: "linux-pacman-$CI_COMMIT_REF_SLUG"
|
||||
paths:
|
||||
- .cache/pacman/
|
||||
- build/vcpkg_installed/
|
||||
- build/_deps/
|
||||
policy: pull-push
|
||||
before_script:
|
||||
- pacman -Syu --noconfirm
|
||||
- pacman -S --noconfirm alsa-lib base-devel boost boost-libs catch2 cmake curl ffmpeg fmt fuse2 gamemode gcc gdb git glslang glu libusb libxi libxkbcommon libxkbcommon-x11 libxss libzip lz4 mbedtls2 mesa nasm ninja nlohmann-json openal openssl opus perl pulseaudio pulseaudio-alsa qt5-base qt5-imageformats qt5-multimedia qt5-tools qt5-wayland qt5ct sdl2 sdl2-compat unzip vulkan-headers vulkan-icd-loader vulkan-mesa-layers wget xcb-util-cursor xcb-util-image xcb-util-keysyms xcb-util-renderutil xcb-util-wm xorg-server-xvfb zip zstd zsync
|
||||
# Setup pacman cache directory
|
||||
- mkdir -p .cache/pacman
|
||||
- echo "CacheDir = $(pwd)/.cache/pacman" >> /etc/pacman.conf
|
||||
# Update package database (but skip if cache is recent)
|
||||
- test -d .cache/pacman/pkg && find .cache/pacman/pkg -name "*.pkg.tar.*" -mtime -1 | head -1 > /dev/null || pacman -Sy --noconfirm
|
||||
# Install packages with caching
|
||||
- pacman -S --noconfirm alsa-lib base-devel boost boost-libs catch2 ccache cmake curl ffmpeg fmt fuse2 gamemode gcc gdb git glslang glu libusb libxi libxkbcommon libxkbcommon-x11 libxss libzip lz4 mbedtls2 mesa nasm ninja nlohmann-json openal openssl opus perl pulseaudio pulseaudio-alsa qt5-base qt5-imageformats qt5-multimedia qt5-tools qt5-wayland qt5ct sdl2 sdl2-compat unzip vulkan-headers vulkan-icd-loader vulkan-mesa-layers wget xcb-util-cursor xcb-util-image xcb-util-keysyms xcb-util-renderutil xcb-util-wm xorg-server-xvfb zip zstd zsync
|
||||
# Create shasum compatibility wrapper for AppImage build
|
||||
- echo '#!/bin/bash' > /usr/local/bin/shasum
|
||||
- echo 'if [ "$1" = "-a" ] && [ "$2" = "256" ]; then' >> /usr/local/bin/shasum
|
||||
@@ -42,7 +64,8 @@ build-linux:
|
||||
- git submodule deinit --all --force || true
|
||||
- git submodule update --init --recursive --force
|
||||
- mkdir -p build && cd build
|
||||
- cmake .. -G Ninja -DCITRON_ENABLE_LTO=ON -DCITRON_USE_BUNDLED_VCPKG=ON -DCITRON_TESTS=OFF -DCITRON_USE_LLVM_DEMANGLE=OFF -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_CXX_FLAGS="-march=native -mtune=native -O3 -flto=auto -DNDEBUG -Wno-error -Wno-conversion" -DCMAKE_C_FLAGS="-march=native -mtune=native -O3 -flto=auto -DNDEBUG" -DUSE_DISCORD_PRESENCE=OFF -DBUNDLE_SPEEX=ON -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DSDL_PIPEWIRE=OFF
|
||||
# Configure CMake with cache optimization
|
||||
- cmake .. -G Ninja -DCITRON_ENABLE_LTO=ON -DCITRON_USE_BUNDLED_VCPKG=ON -DCITRON_TESTS=OFF -DCITRON_USE_LLVM_DEMANGLE=OFF -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_CXX_FLAGS="-march=native -mtune=native -O3 -flto=auto -DNDEBUG -Wno-error -Wno-conversion" -DCMAKE_C_FLAGS="-march=native -mtune=native -O3 -flto=auto -DNDEBUG" -DUSE_DISCORD_PRESENCE=OFF -DBUNDLE_SPEEX=ON -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DSDL_PIPEWIRE=OFF -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
- ninja
|
||||
- cd ..
|
||||
- echo "Build completed, checking for executables..."
|
||||
@@ -74,9 +97,21 @@ build-linux-steamdeck:
|
||||
image: cachyos/cachyos-v3
|
||||
tags:
|
||||
- citron-build
|
||||
cache:
|
||||
key: "steamdeck-pacman-$CI_COMMIT_REF_SLUG"
|
||||
paths:
|
||||
- .cache/pacman/
|
||||
- build/vcpkg_installed/
|
||||
- build/_deps/
|
||||
policy: pull-push
|
||||
before_script:
|
||||
- pacman -Syu --noconfirm
|
||||
- pacman -S --noconfirm alsa-lib base-devel boost boost-libs catch2 cmake curl ffmpeg fmt fuse2 gamemode gcc gdb git glslang glu libusb libxi libxkbcommon libxkbcommon-x11 libxss libzip lz4 mbedtls2 mesa nasm ninja nlohmann-json openal openssl opus perl pulseaudio pulseaudio-alsa qt5-base qt5-imageformats qt5-multimedia qt5-tools qt5-wayland qt5ct sdl2 sdl2-compat unzip vulkan-headers vulkan-icd-loader vulkan-mesa-layers wget xcb-util-cursor xcb-util-image xcb-util-keysyms xcb-util-renderutil xcb-util-wm xorg-server-xvfb zip zstd zsync
|
||||
# Setup pacman cache directory
|
||||
- mkdir -p .cache/pacman
|
||||
- echo "CacheDir = $(pwd)/.cache/pacman" >> /etc/pacman.conf
|
||||
# Update package database (but skip if cache is recent)
|
||||
- test -d .cache/pacman/pkg && find .cache/pacman/pkg -name "*.pkg.tar.*" -mtime -1 | head -1 > /dev/null || pacman -Sy --noconfirm
|
||||
# Install packages with caching
|
||||
- pacman -S --noconfirm alsa-lib base-devel boost boost-libs catch2 ccache cmake curl ffmpeg fmt fuse2 gamemode gcc gdb git glslang glu libusb libxi libxkbcommon libxkbcommon-x11 libxss libzip lz4 mbedtls2 mesa nasm ninja nlohmann-json openal openssl opus perl pulseaudio pulseaudio-alsa qt5-base qt5-imageformats qt5-multimedia qt5-tools qt5-wayland qt5ct sdl2 sdl2-compat unzip vulkan-headers vulkan-icd-loader vulkan-mesa-layers wget xcb-util-cursor xcb-util-image xcb-util-keysyms xcb-util-renderutil xcb-util-wm xorg-server-xvfb zip zstd zsync
|
||||
# Create shasum compatibility wrapper for AppImage build
|
||||
- echo '#!/bin/bash' > /usr/local/bin/shasum
|
||||
- echo 'if [ "$1" = "-a" ] && [ "$2" = "256" ]; then' >> /usr/local/bin/shasum
|
||||
@@ -91,7 +126,7 @@ build-linux-steamdeck:
|
||||
- git submodule deinit --all --force || true
|
||||
- git submodule update --init --recursive --force
|
||||
- mkdir -p build && cd build
|
||||
- cmake .. -G Ninja -DCITRON_ENABLE_LTO=ON -DCITRON_USE_BUNDLED_VCPKG=ON -DCITRON_TESTS=OFF -DCITRON_USE_LLVM_DEMANGLE=OFF -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_CXX_FLAGS="-march=znver2 -mtune=znver2 -O3 -flto=auto -DNDEBUG -Wno-error -Wno-conversion" -DCMAKE_C_FLAGS="-march=znver2 -mtune=znver2 -O3 -flto=auto -DNDEBUG" -DUSE_DISCORD_PRESENCE=OFF -DBUNDLE_SPEEX=ON -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DSDL_PIPEWIRE=OFF
|
||||
- cmake .. -G Ninja -DCITRON_ENABLE_LTO=ON -DCITRON_USE_BUNDLED_VCPKG=ON -DCITRON_TESTS=OFF -DCITRON_USE_LLVM_DEMANGLE=OFF -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_CXX_FLAGS="-march=znver2 -mtune=znver2 -O3 -flto=auto -DNDEBUG -Wno-error -Wno-conversion" -DCMAKE_C_FLAGS="-march=znver2 -mtune=znver2 -O3 -flto=auto -DNDEBUG" -DUSE_DISCORD_PRESENCE=OFF -DBUNDLE_SPEEX=ON -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DSDL_PIPEWIRE=OFF -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
- ninja
|
||||
- cd ..
|
||||
- echo "Build completed, checking for executables..."
|
||||
@@ -123,9 +158,21 @@ build-linux-compat:
|
||||
image: cachyos/cachyos:latest
|
||||
tags:
|
||||
- citron-build
|
||||
cache:
|
||||
key: "compat-pacman-$CI_COMMIT_REF_SLUG"
|
||||
paths:
|
||||
- .cache/pacman/
|
||||
- build/vcpkg_installed/
|
||||
- build/_deps/
|
||||
policy: pull-push
|
||||
before_script:
|
||||
- pacman -Syu --noconfirm
|
||||
- pacman -S --noconfirm alsa-lib base-devel boost boost-libs catch2 cmake curl ffmpeg fmt fuse2 gamemode gcc gdb git glslang glu libusb libxi libxkbcommon libxkbcommon-x11 libxss libzip lz4 mbedtls2 mesa nasm ninja nlohmann-json openal openssl opus perl pulseaudio pulseaudio-alsa qt5-base qt5-imageformats qt5-multimedia qt5-tools qt5-wayland qt5ct sdl2 sdl2-compat unzip vulkan-headers vulkan-icd-loader vulkan-mesa-layers wget xcb-util-cursor xcb-util-image xcb-util-keysyms xcb-util-renderutil xcb-util-wm xorg-server-xvfb zip zstd zsync
|
||||
# Setup pacman cache directory
|
||||
- mkdir -p .cache/pacman
|
||||
- echo "CacheDir = $(pwd)/.cache/pacman" >> /etc/pacman.conf
|
||||
# Update package database (but skip if cache is recent)
|
||||
- test -d .cache/pacman/pkg && find .cache/pacman/pkg -name "*.pkg.tar.*" -mtime -1 | head -1 > /dev/null || pacman -Sy --noconfirm
|
||||
# Install packages with caching
|
||||
- pacman -S --noconfirm alsa-lib base-devel boost boost-libs catch2 ccache cmake curl ffmpeg fmt fuse2 gamemode gcc gdb git glslang glu libusb libxi libxkbcommon libxkbcommon-x11 libxss libzip lz4 mbedtls2 mesa nasm ninja nlohmann-json openal openssl opus perl pulseaudio pulseaudio-alsa qt5-base qt5-imageformats qt5-multimedia qt5-tools qt5-wayland qt5ct sdl2 sdl2-compat unzip vulkan-headers vulkan-icd-loader vulkan-mesa-layers wget xcb-util-cursor xcb-util-image xcb-util-keysyms xcb-util-renderutil xcb-util-wm xorg-server-xvfb zip zstd zsync
|
||||
# Create shasum compatibility wrapper for AppImage build
|
||||
- echo '#!/bin/bash' > /usr/local/bin/shasum
|
||||
- echo 'if [ "$1" = "-a" ] && [ "$2" = "256" ]; then' >> /usr/local/bin/shasum
|
||||
@@ -140,7 +187,7 @@ build-linux-compat:
|
||||
- git submodule deinit --all --force || true
|
||||
- git submodule update --init --recursive --force
|
||||
- mkdir -p build && cd build
|
||||
- cmake .. -G Ninja -DCITRON_ENABLE_LTO=ON -DCITRON_USE_BUNDLED_VCPKG=ON -DCITRON_TESTS=OFF -DCITRON_USE_LLVM_DEMANGLE=OFF -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_CXX_FLAGS="-march=core2 -mtune=core2 -O3 -flto=auto -DNDEBUG -Wno-error -Wno-conversion" -DCMAKE_C_FLAGS="-march=core2 -mtune=core2 -O3 -flto=auto -DNDEBUG" -DUSE_DISCORD_PRESENCE=OFF -DBUNDLE_SPEEX=ON -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DSDL_PIPEWIRE=OFF
|
||||
- cmake .. -G Ninja -DCITRON_ENABLE_LTO=ON -DCITRON_USE_BUNDLED_VCPKG=ON -DCITRON_TESTS=OFF -DCITRON_USE_LLVM_DEMANGLE=OFF -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_CXX_FLAGS="-march=core2 -mtune=core2 -O3 -flto=auto -DNDEBUG -Wno-error -Wno-conversion" -DCMAKE_C_FLAGS="-march=core2 -mtune=core2 -O3 -flto=auto -DNDEBUG" -DUSE_DISCORD_PRESENCE=OFF -DBUNDLE_SPEEX=ON -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DSDL_PIPEWIRE=OFF -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
- ninja
|
||||
- cd ..
|
||||
- echo "Build completed, checking for executables..."
|
||||
@@ -172,22 +219,53 @@ build-android:
|
||||
image: ubuntu:24.04
|
||||
tags:
|
||||
- citron-build
|
||||
cache:
|
||||
key: "android-apt-$CI_COMMIT_REF_SLUG"
|
||||
paths:
|
||||
- .cache/apt/
|
||||
- .cache/android/
|
||||
- .cache/gradle/
|
||||
- build/vcpkg_installed/
|
||||
- build/_deps/
|
||||
policy: pull-push
|
||||
before_script:
|
||||
- apt-get update -qq
|
||||
# Setup apt cache
|
||||
- mkdir -p .cache/apt
|
||||
- echo 'Dir::Cache::archives ".cache/apt";' >> /etc/apt/apt.conf.d/99cache
|
||||
# Check if packages are cached, skip update if recent
|
||||
- test -d .cache/apt/archives && find .cache/apt/archives -name "*.deb" -mtime -1 | head -1 > /dev/null || apt-get update -qq
|
||||
- apt-get install -y -qq openjdk-17-jdk wget unzip curl git cmake build-essential pkg-config zip glslang-tools
|
||||
# Install Android SDK (latest version for Ubuntu 24.04)
|
||||
- wget -q https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip
|
||||
- unzip -q commandlinetools-linux-11076708_latest.zip
|
||||
- mkdir -p android-sdk/cmdline-tools
|
||||
- mv cmdline-tools android-sdk/cmdline-tools/latest
|
||||
- export ANDROID_SDK_ROOT=$PWD/android-sdk
|
||||
- export PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin
|
||||
- printf "y\ny\ny\ny\ny\ny\ny\n" | sdkmanager --licenses || true
|
||||
- sdkmanager "platform-tools" "platforms;android-34" "build-tools;34.0.0"
|
||||
# Install Android NDK
|
||||
- wget -q https://dl.google.com/android/repository/android-ndk-r26b-linux.zip
|
||||
- unzip -q android-ndk-r26b-linux.zip
|
||||
- export ANDROID_NDK_HOME=$PWD/android-ndk-r26b
|
||||
|
||||
# Setup Android SDK cache
|
||||
- mkdir -p .cache/android
|
||||
- export ANDROID_SDK_ROOT=$PWD/.cache/android/android-sdk
|
||||
- export ANDROID_NDK_HOME=$PWD/.cache/android/android-ndk-r26b
|
||||
|
||||
# Install Android SDK if not cached
|
||||
- |
|
||||
if [ ! -d "$ANDROID_SDK_ROOT" ]; then
|
||||
echo "Downloading Android SDK..."
|
||||
wget -q https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -O .cache/android/commandlinetools-linux.zip
|
||||
unzip -q .cache/android/commandlinetools-linux.zip -d .cache/android/
|
||||
mkdir -p $ANDROID_SDK_ROOT/cmdline-tools
|
||||
mv .cache/android/cmdline-tools $ANDROID_SDK_ROOT/cmdline-tools/latest
|
||||
export PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin
|
||||
printf "y\ny\ny\ny\ny\ny\ny\n" | sdkmanager --licenses || true
|
||||
sdkmanager "platform-tools" "platforms;android-34" "build-tools;34.0.0"
|
||||
else
|
||||
echo "Android SDK found in cache"
|
||||
export PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin
|
||||
fi
|
||||
|
||||
# Install Android NDK if not cached
|
||||
- |
|
||||
if [ ! -d "$ANDROID_NDK_HOME" ]; then
|
||||
echo "Downloading Android NDK..."
|
||||
wget -q https://dl.google.com/android/repository/android-ndk-r26b-linux.zip -O .cache/android/android-ndk-r26b-linux.zip
|
||||
unzip -q .cache/android/android-ndk-r26b-linux.zip -d .cache/android/
|
||||
else
|
||||
echo "Android NDK found in cache"
|
||||
fi
|
||||
script:
|
||||
# Clean and reset submodules to handle any inconsistencies
|
||||
- git submodule deinit --all --force || true
|
||||
@@ -214,8 +292,19 @@ test-unit:
|
||||
image: ubuntu:24.04
|
||||
tags:
|
||||
- citron-build
|
||||
cache:
|
||||
key: "test-apt-$CI_COMMIT_REF_SLUG"
|
||||
paths:
|
||||
- .cache/apt/
|
||||
- build/vcpkg_installed/
|
||||
- build/_deps/
|
||||
policy: pull-push
|
||||
before_script:
|
||||
- apt-get update -qq
|
||||
# Setup apt cache
|
||||
- mkdir -p .cache/apt
|
||||
- echo 'Dir::Cache::archives ".cache/apt";' >> /etc/apt/apt.conf.d/99cache
|
||||
# Check if packages are cached, skip update if recent
|
||||
- test -d .cache/apt/archives && find .cache/apt/archives -name "*.deb" -mtime -1 | head -1 > /dev/null || apt-get update -qq
|
||||
- apt-get install -y -qq build-essential cmake ninja-build git
|
||||
script:
|
||||
# Clean and reset submodules to handle any inconsistencies
|
||||
@@ -242,6 +331,11 @@ package-release:
|
||||
image: ubuntu:24.04
|
||||
tags:
|
||||
- citron-build
|
||||
cache:
|
||||
key: "package-apt-$CI_COMMIT_REF_SLUG"
|
||||
paths:
|
||||
- .cache/apt/
|
||||
policy: pull
|
||||
dependencies:
|
||||
- build-linux
|
||||
script:
|
||||
|
||||
Reference in New Issue
Block a user