Cache Warmup #45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Cache Warmup | |
| env: | |
| LLVM_VERSION: 21.1.8 | |
| LLVM_CACHE_VERSION: v13 | |
| ICU_VERSION: 78.3 | |
| ICU_CACHE_VERSION: v1 | |
| VCPKG_CACHE_VERSION: v1 | |
| on: | |
| schedule: | |
| - cron: "0 0 */5 * *" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| warm-cache: | |
| name: Warm Cache (${{ matrix.rust_target }}) | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| CARGO_BUILD_TARGET: ${{ matrix.rust_target }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-24.04 | |
| rust_target: x86_64-unknown-linux-gnu | |
| - os: ubuntu-24.04-arm | |
| rust_target: aarch64-unknown-linux-gnu | |
| - os: macos-15-intel | |
| rust_target: x86_64-apple-darwin | |
| - os: macos-15 | |
| rust_target: aarch64-apple-darwin | |
| - os: windows-latest | |
| rust_target: x86_64-pc-windows-msvc | |
| vcpkg_triplet: x64-windows | |
| - os: windows-11-vs2026-arm | |
| rust_target: aarch64-pc-windows-msvc | |
| vcpkg_triplet: arm64-windows | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Add Rust target | |
| run: rustup target add ${{ matrix.rust_target }} | |
| - name: Install LLVM link dependencies | |
| if: runner.os == 'Linux' | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| sudo apt-get update -q -y | |
| sudo apt-get install -q -y libffi-dev libxml2-dev libzstd-dev zlib1g-dev | |
| - name: Cache LLVM 21.1.x | |
| id: cache-llvm | |
| uses: actions/cache@v4 | |
| with: | |
| path: .llvm/${{ runner.os }}-${{ runner.arch }}-${{ matrix.rust_target }} | |
| key: llvm-${{ runner.os }}-${{ runner.arch }}-${{ matrix.rust_target }}-${{ env.LLVM_VERSION }}-${{ env.LLVM_CACHE_VERSION }} | |
| - name: Cache ICU prebuilt (Unix) | |
| if: runner.os != 'Windows' | |
| id: cache-icu-prebuilt-unix | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| bitcodes/c/lib/icu | |
| bitcodes/c/lib/icu-prebuilt | |
| target/icu-prebuilt-build | |
| key: icu-prebuilt-${{ runner.os }}-${{ runner.arch }}-${{ matrix.rust_target }}-${{ env.ICU_VERSION }}-${{ env.ICU_CACHE_VERSION }} | |
| - name: Cache ICU prebuilt (Windows) | |
| if: runner.os == 'Windows' | |
| id: cache-icu-prebuilt-windows | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ runner.temp }}/vcpkg | |
| key: icu-prebuilt-${{ runner.os }}-${{ runner.arch }}-${{ matrix.vcpkg_triplet }}-${{ env.ICU_VERSION }}-${{ env.VCPKG_CACHE_VERSION }} | |
| - name: Install LLVM 21.1.x (Unix) | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| LLVM_INSTALL_DIR="$GITHUB_WORKSPACE/.llvm/${RUNNER_OS}-${RUNNER_ARCH}-${{ matrix.rust_target }}" | |
| LLVM_INSTALL_DIR="$LLVM_INSTALL_DIR" ./tools/install_llvm_prebuilt.sh | |
| - name: Build LLVM 21.1.x (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| $llvmRootDir = Join-Path $env:GITHUB_WORKSPACE '.llvm' | |
| $llvmInstallDir = Join-Path $llvmRootDir "$($env:RUNNER_OS)-$($env:RUNNER_ARCH)-${{ matrix.rust_target }}" | |
| ./tools/install_llvm_source.ps1 -InstallDir $llvmInstallDir -TargetArch "${{ matrix.rust_target }}" | |
| - name: Export LLVM env (Unix) | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| run: | | |
| LLVM_ROOT="$GITHUB_WORKSPACE/.llvm/${RUNNER_OS}-${RUNNER_ARCH}-${{ matrix.rust_target }}" | |
| echo "LLVM_SYS_211_PREFIX=$LLVM_ROOT" >> "$GITHUB_ENV" | |
| echo "LLVM_CONFIG_PATH=$LLVM_ROOT/bin/llvm-config" >> "$GITHUB_ENV" | |
| echo "LD_LIBRARY_PATH=$LLVM_ROOT/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> "$GITHUB_ENV" | |
| echo "$LLVM_ROOT/bin" >> "$GITHUB_PATH" | |
| - name: Export LLVM env (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| $llvmRootDir = Join-Path $env:GITHUB_WORKSPACE '.llvm' | |
| $llvmRoot = Join-Path $llvmRootDir "$($env:RUNNER_OS)-$($env:RUNNER_ARCH)-${{ matrix.rust_target }}" | |
| "LLVM_SYS_211_PREFIX=$llvmRoot" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| "LLVM_CONFIG_PATH=$llvmRoot\bin\llvm-config.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| "$llvmRoot\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| - name: Verify LLVM link metadata (Unix) | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| run: | | |
| "$LLVM_CONFIG_PATH" --version | |
| "$LLVM_CONFIG_PATH" --system-libs --link-static | |
| - name: Verify LLVM version (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| & "$env:LLVM_CONFIG_PATH" --version | |
| & "$env:LLVM_CONFIG_PATH" --host-target | |
| - name: Use native Linux linker on ARM64 | |
| if: runner.os == 'Linux' && runner.arch == 'ARM64' | |
| shell: bash | |
| run: | | |
| echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=cc" >> "$GITHUB_ENV" | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ matrix.rust_target }}-${{ env.LLVM_CACHE_VERSION }} | |
| - name: Setup and build (Unix) | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| run: | | |
| if [[ "${{ steps.cache-icu-prebuilt-unix.outputs.cache-hit }}" == "true" ]]; then | |
| ./setup.sh | |
| else | |
| ./setup.sh --clean-icu | |
| fi | |
| - name: Cache ICU runtime (Linux) | |
| if: runner.os == 'Linux' | |
| id: cache-icu-runtime | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| target/icu-runtime | |
| target/icu-runtime-build | |
| key: icu-runtime-${{ runner.os }}-${{ runner.arch }}-${{ matrix.rust_target }}-${{ env.ICU_VERSION }}-${{ env.ICU_CACHE_VERSION }} | |
| - name: Build bundled ICU runtime (Linux) | |
| if: runner.os == 'Linux' | |
| shell: bash | |
| run: | | |
| if [[ "${{ steps.cache-icu-runtime.outputs.cache-hit }}" == "true" ]]; then | |
| ./tools/build_icu_runtime.sh | |
| else | |
| ./tools/build_icu_runtime.sh --clean | |
| fi | |
| - name: Setup and build (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| if ("${{ steps.cache-icu-prebuilt-windows.outputs.cache-hit }}" -eq "true") { | |
| ./setup.ps1 -SkipCheck -VcpkgTriplet "${{ matrix.vcpkg_triplet }}" | |
| } else { | |
| ./setup.ps1 -CleanIcu -SkipCheck -VcpkgTriplet "${{ matrix.vcpkg_triplet }}" | |
| } | |
| warm-cache-linux-emulated: | |
| name: Warm Cache Linux (${{ matrix.arch }}) | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - arch: aarch64 | |
| distro: ubuntu24.04 | |
| - arch: armv7 | |
| distro: ubuntu24.04 | |
| - arch: s390x | |
| distro: ubuntu24.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Cache LLVM 21.1.x | |
| id: cache-llvm | |
| uses: actions/cache@v4 | |
| with: | |
| path: .llvm-emulated/${{ matrix.arch }} | |
| key: llvm-linux-${{ matrix.arch }}-${{ env.LLVM_VERSION }}-${{ env.LLVM_CACHE_VERSION }} | |
| - name: Cache ICU prebuilt | |
| id: cache-icu-prebuilt | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| bitcodes/c/lib/icu | |
| bitcodes/c/lib/icu-prebuilt-${{ matrix.arch }} | |
| target/icu-prebuilt-build-${{ matrix.arch }} | |
| key: icu-prebuilt-linux-${{ matrix.arch }}-${{ env.ICU_VERSION }}-${{ env.ICU_CACHE_VERSION }} | |
| - name: Cache ICU runtime | |
| id: cache-icu-runtime | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| target/icu-runtime-${{ matrix.arch }} | |
| target/icu-runtime-build-${{ matrix.arch }} | |
| key: icu-runtime-linux-${{ matrix.arch }}-${{ env.ICU_VERSION }}-${{ env.ICU_CACHE_VERSION }} | |
| - name: Cache cargo build outputs | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| .cargo-home/${{ matrix.arch }} | |
| .rustup-home/${{ matrix.arch }} | |
| target/cargo-${{ matrix.arch }} | |
| key: cargo-linux-${{ matrix.arch }}-${{ env.LLVM_VERSION }}-${{ env.LLVM_CACHE_VERSION }}-${{ hashFiles('Cargo.lock') }} | |
| restore-keys: | | |
| cargo-linux-${{ matrix.arch }}-${{ env.LLVM_VERSION }}-${{ env.LLVM_CACHE_VERSION }}- | |
| - name: Warm cache on ${{ matrix.arch }} | |
| uses: uraimo/run-on-arch-action@v3 | |
| with: | |
| arch: ${{ matrix.arch }} | |
| distro: ${{ matrix.distro }} | |
| githubToken: ${{ github.token }} | |
| env: | | |
| ICU_CACHE_HIT: "${{ steps.cache-icu-prebuilt.outputs.cache-hit }}" | |
| ICU_RUNTIME_CACHE_HIT: "${{ steps.cache-icu-runtime.outputs.cache-hit }}" | |
| install: | | |
| apt-get update -q -y | |
| DEBIAN_FRONTEND=noninteractive apt-get install -q -y \ | |
| build-essential \ | |
| ca-certificates \ | |
| clang \ | |
| cmake \ | |
| curl \ | |
| git \ | |
| gzip \ | |
| libffi-dev \ | |
| libxml2-dev \ | |
| libzstd-dev \ | |
| ninja-build \ | |
| perl \ | |
| pkg-config \ | |
| python3 \ | |
| tar \ | |
| zlib1g-dev | |
| run: | | |
| set -euxo pipefail | |
| export CARGO_HOME="$PWD/.cargo-home/${{ matrix.arch }}" | |
| export CARGO_TARGET_DIR="$PWD/target/cargo-${{ matrix.arch }}" | |
| export RUSTUP_HOME="$PWD/.rustup-home/${{ matrix.arch }}" | |
| mkdir -p "$CARGO_HOME" "$CARGO_TARGET_DIR" "$RUSTUP_HOME" | |
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ | |
| | sh -s -- -y --profile minimal --default-toolchain stable | |
| . "$CARGO_HOME/env" | |
| if [[ "$(uname -m)" == "aarch64" ]]; then | |
| export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=cc | |
| fi | |
| export LLVM_ROOT="$PWD/.llvm-emulated/${{ matrix.arch }}" | |
| LLVM_INSTALL_DIR="$LLVM_ROOT" ./tools/install_llvm_prebuilt.sh | |
| export LLVM_SYS_211_PREFIX="$LLVM_ROOT" | |
| export LLVM_CONFIG_PATH="$LLVM_ROOT/bin/llvm-config" | |
| export PATH="$LLVM_ROOT/bin:$PATH" | |
| export LD_LIBRARY_PATH="$LLVM_ROOT/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" | |
| "$LLVM_CONFIG_PATH" --version | |
| "$LLVM_CONFIG_PATH" --system-libs --link-static | |
| export XYO_ICU_PREBUILT_DIR="$PWD/bitcodes/c/lib/icu-prebuilt-${{ matrix.arch }}" | |
| export XYO_ICU_PREBUILT_BUILD_DIR="$PWD/target/icu-prebuilt-build-${{ matrix.arch }}" | |
| if [[ "${ICU_CACHE_HIT}" == "true" ]]; then | |
| ./setup.sh | |
| else | |
| ./setup.sh --clean-icu | |
| fi | |
| export XYO_ICU_RUNTIME_DIR="$PWD/target/icu-runtime-${{ matrix.arch }}" | |
| export XYO_ICU_RUNTIME_BUILD_DIR="$PWD/target/icu-runtime-build-${{ matrix.arch }}" | |
| if [[ "${ICU_RUNTIME_CACHE_HIT}" == "true" ]]; then | |
| ./tools/build_icu_runtime.sh | |
| else | |
| ./tools/build_icu_runtime.sh --clean | |
| fi |