Files
Behdad Esfahbod 4fd912a3c8 [ci] Avoid saving unchanged compiler-cache snapshots
Restore compiler caches through a shared setup action and save them
explicitly only when compilation reports cache misses. Keep existing
restore prefixes and make cache-save failures nonfatal. Before saving
ccache, prune entries that were not used during the job.

This avoids duplicate snapshots on fully cached runs and removes
unrelated restored objects from changed snapshots. Key the MSVC
installed prefix by its dependency build inputs rather than unrelated
workflow edits; dependency options remain in the hashed helper project.

Validation: actual ccache 4.9.1 cold/warm and pruning checks; sccache
statistics and failure-path checks; nine workflow setup/save pairs;
actionlint, git diff --check, and meson test -C build
(302 passed, one skipped). Remote uploads remain for CI.

Assisted-by: OpenAI Codex
2026-11-11 19:48:07 -06:00

115 lines
4.2 KiB
YAML

name: msvc
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
msvc:
runs-on: ${{ matrix.os }}
env:
MSVC_DEPS_PREFIX: ${{ github.workspace }}/msvc-deps-install
strategy:
fail-fast: false
matrix:
include:
- name: msvc-2025-x86
os: windows-2025
ARCH: x86
OPTIMIZATION: 1
- name: msvc-2025-amd64
os: windows-2025
ARCH: amd64
OPTIMIZATION: 3
name: ${{ matrix.name }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Ccache
id: compiler-cache
uses: ./.github/actions/compiler-cache
with:
variant: sccache
key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.ARCH }}
- name: Setup Python
id: python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: '3.12'
- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
with:
arch : ${{ matrix.ARCH }}
- name: Install Python Dependencies
run: |
pip3 install -r .ci/requirements.txt --require-hashes
- name: Install pkg-config
run: choco install pkgconfiglite --version=0.28 --yes --no-progress
- name: Identify MSVC Toolset
id: msvc-version
run: |
"version=$((Get-Item (Get-Command cl.exe).Source).VersionInfo.FileVersion)" >> $env:GITHUB_OUTPUT
"sdk=$($env:WindowsSDKVersion.TrimEnd('\'))" >> $env:GITHUB_OUTPUT
- name: Cache Installed Dependencies
id: msvc-deps
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5
with:
path: ${{ env.MSVC_DEPS_PREFIX }}
key: msvc-deps-${{ matrix.os }}-${{ matrix.ARCH }}-${{ steps.msvc-version.outputs.version }}-${{ steps.msvc-version.outputs.sdk }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('subprojects/**/*.wrap', 'subprojects/packagefiles/**', '.ci/msvc-deps/**', '.ci/requirements.txt') }}
- name: Build Dependencies
if: steps.msvc-deps.outputs.cache-hit != 'true'
run: |
$source = Join-Path $env:RUNNER_TEMP harfbuzz-msvc-deps
Copy-Item .ci/msvc-deps $source -Recurse
New-Item -ItemType Directory "$source/subprojects"
Copy-Item subprojects/*.wrap "$source/subprojects"
if (Test-Path subprojects/packagefiles) {
Copy-Item subprojects/packagefiles "$source/subprojects/packagefiles" -Recurse
}
# Keep dependency build options in .ci/msvc-deps so the cache key tracks them.
meson setup build-msvc-deps $source --prefix="$env:MSVC_DEPS_PREFIX" --wrap-mode=forcefallback
meson compile -Cbuild-msvc-deps
meson install -Cbuild-msvc-deps --no-rebuild
- name: Use Installed Dependencies
run: |
"$env:MSVC_DEPS_PREFIX/bin" >> $env:GITHUB_PATH
"PKG_CONFIG_PATH=$env:MSVC_DEPS_PREFIX/lib/pkgconfig" >> $env:GITHUB_ENV
- name: Setup Meson
run: |
sccache --version
pkg-config --modversion glib-2.0 freetype2
meson setup build `
--wrap-mode=nofallback `
--buildtype=release `
-Doptimization=${{ matrix.OPTIMIZATION }} `
-Db_ndebug=true `
-Dglib=enabled `
-Dcairo=disabled `
-Dicu=disabled `
-Dfreetype=enabled `
-Dgdi=enabled `
-Ddirectwrite=enabled `
-Dgpu_demo=disabled
- name: Build
run: meson compile -Cbuild
- name: Test
run: meson test --print-errorlogs --suite=harfbuzz -Cbuild
- name: Save Compiler Cache
if: ${{ !cancelled() && steps.compiler-cache.outcome == 'success' }}
uses: ./.github/actions/save-compiler-cache
with:
key: ${{ steps.compiler-cache.outputs.key }}
variant: ${{ steps.compiler-cache.outputs.variant }}
start: ${{ steps.compiler-cache.outputs.start }}