From c008503d224ee989634bddd71ad974accab11245 Mon Sep 17 00:00:00 2001 From: George Evmenov Date: Sun, 25 Oct 2026 01:01:43 +0300 Subject: [PATCH 1/2] Restore CI binary caching and retry vcpkg downloads --- .github/actions/setup-vcpkg/action.yml | 43 ++++++++++++++++++++++++++ .github/workflows/linux.yaml | 13 ++------ .github/workflows/macos.yaml | 13 ++------ .github/workflows/windows.yaml | 25 +++++---------- 4 files changed, 57 insertions(+), 37 deletions(-) create mode 100644 .github/actions/setup-vcpkg/action.yml diff --git a/.github/actions/setup-vcpkg/action.yml b/.github/actions/setup-vcpkg/action.yml new file mode 100644 index 00000000..6d7264af --- /dev/null +++ b/.github/actions/setup-vcpkg/action.yml @@ -0,0 +1,43 @@ +name: Set up vcpkg +description: Set up vcpkg with a persistent binary cache and download retries. + +inputs: + cache-key: + description: Matrix configuration (compiler, standard, format, and build variant). + required: true + +runs: + using: composite + steps: + - uses: lukka/run-vcpkg@v11 + with: + binaryCachePath: ${{ runner.temp }}/vcpkg-binary-cache + + - name: Configure caching and download retries + id: config + shell: bash + env: + # vcpkg quotes {url} and {dst} itself, including paths containing spaces. + # Retry individual downloads, including DNS errors, rather than builds. + X_VCPKG_ASSET_SOURCES: >- + x-script,curl --fail --location --retry 2 --retry-all-errors + --retry-delay 10 --connect-timeout 30 --output {dst} {url} + run: | + cache_dir="${RUNNER_TEMP//\\//}/vcpkg-binary-cache" + mkdir -p "$cache_dir" + echo "VCPKG_BINARY_SOURCES=clear;files,$cache_dir,readwrite" >> "$GITHUB_ENV" + echo "X_VCPKG_ASSET_SOURCES=$X_VCPKG_ASSET_SOURCES" >> "$GITHUB_ENV" + echo "cache-path=$cache_dir" >> "$GITHUB_OUTPUT" + echo "vcpkg-revision=$(git rev-parse HEAD:vcpkg)" >> "$GITHUB_OUTPUT" + echo "image-version=${ImageVersion:-unknown}" >> "$GITHUB_OUTPUT" + + - name: Cache vcpkg binaries + uses: actions/cache@v4 + with: + path: ${{ steps.config.outputs.cache-path }} + # Separate matrix jobs to avoid competing to save different package sets. + # A new runner image may change the compiler and therefore package ABIs. + key: vcpkg-v1-${{ runner.os }}-${{ runner.arch }}-${{ inputs.cache-key }}-${{ steps.config.outputs.image-version }}-${{ steps.config.outputs.vcpkg-revision }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json', 'CMakeLists.txt', 'cmake/**') }} + # vcpkg validates package ABIs when reusing an older dependency cache. + restore-keys: | + vcpkg-v1-${{ runner.os }}-${{ runner.arch }}-${{ inputs.cache-key }}-${{ steps.config.outputs.image-version }}- diff --git a/.github/workflows/linux.yaml b/.github/workflows/linux.yaml index 219f2bc0..82807af9 100644 --- a/.github/workflows/linux.yaml +++ b/.github/workflows/linux.yaml @@ -2,9 +2,6 @@ name: linux on: [ push, pull_request ] -env: - VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" - jobs: linux: strategy: @@ -65,14 +62,10 @@ jobs: with: submodules: recursive fetch-depth: 0 - - name: Export GitHub Actions cache environment variables - uses: actions/github-script@v7 + - name: Set up vcpkg + uses: ./.github/actions/setup-vcpkg with: - script: | - core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); - core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - - name: Run vcpkg - uses: lukka/run-vcpkg@v11 + cache-key: ${{ github.job }}-${{ matrix.compiler }}-${{ matrix.compiler-version }}-cxx${{ matrix.cxx }}-${{ matrix.format }} - name: Install dependencies run: | sudo apt update diff --git a/.github/workflows/macos.yaml b/.github/workflows/macos.yaml index 8c2e4da2..2f5fba43 100644 --- a/.github/workflows/macos.yaml +++ b/.github/workflows/macos.yaml @@ -2,9 +2,6 @@ name: macos on: [ push, pull_request ] -env: - VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" - jobs: macos-clang: strategy: @@ -23,14 +20,10 @@ jobs: with: submodules: recursive fetch-depth: 0 - - name: Export GitHub Actions cache environment variables - uses: actions/github-script@v7 + - name: Set up vcpkg + uses: ./.github/actions/setup-vcpkg with: - script: | - core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); - core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - - name: Run vcpkg - uses: lukka/run-vcpkg@v11 + cache-key: ${{ matrix.os }}-${{ matrix.format }} - name: Install bison run: brew install bison openssl@3 - name: Install ninja diff --git a/.github/workflows/windows.yaml b/.github/workflows/windows.yaml index 27dc497f..8b4af4ad 100644 --- a/.github/workflows/windows.yaml +++ b/.github/workflows/windows.yaml @@ -2,9 +2,6 @@ name: windows on: [ push, pull_request ] -env: - VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" - jobs: windows-msvc: strategy: @@ -22,14 +19,11 @@ jobs: with: submodules: recursive fetch-depth: 0 - - name: Export GitHub Actions cache environment variables - uses: actions/github-script@v7 - with: - script: | - core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); - core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - uses: ilammy/msvc-dev-cmd@v1 - - uses: lukka/run-vcpkg@v11 + - name: Set up vcpkg + uses: ./.github/actions/setup-vcpkg + with: + cache-key: ${{ github.job }}-${{ matrix.format }} - name: Compile benchmarks if: matrix.format == 'benchmarks' run: | @@ -91,14 +85,11 @@ jobs: with: submodules: recursive fetch-depth: 0 - - name: Export GitHub Actions cache environment variables - uses: actions/github-script@v7 - with: - script: | - core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); - core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - uses: ilammy/msvc-dev-cmd@v1 - - uses: lukka/run-vcpkg@v11 + - name: Set up vcpkg + uses: ./.github/actions/setup-vcpkg + with: + cache-key: ${{ github.job }}-${{ matrix.format }} - name: Compile tests (JSON) if: matrix.format == 'JSON' run: | From f80d840c0c92f56d05f7b0f459db752ad8edad3d Mon Sep 17 00:00:00 2001 From: George Evmenov Date: Sun, 25 Oct 2026 01:35:28 +0300 Subject: [PATCH 2/2] Create the binary cache directory before setting up vcpkg --- .github/actions/setup-vcpkg/action.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/actions/setup-vcpkg/action.yml b/.github/actions/setup-vcpkg/action.yml index 6d7264af..65292cb2 100644 --- a/.github/actions/setup-vcpkg/action.yml +++ b/.github/actions/setup-vcpkg/action.yml @@ -9,10 +9,6 @@ inputs: runs: using: composite steps: - - uses: lukka/run-vcpkg@v11 - with: - binaryCachePath: ${{ runner.temp }}/vcpkg-binary-cache - - name: Configure caching and download retries id: config shell: bash @@ -31,6 +27,11 @@ runs: echo "vcpkg-revision=$(git rev-parse HEAD:vcpkg)" >> "$GITHUB_OUTPUT" echo "image-version=${ImageVersion:-unknown}" >> "$GITHUB_OUTPUT" + # run-vcpkg requires binaryCachePath to exist before the action starts. + - uses: lukka/run-vcpkg@v11 + with: + binaryCachePath: ${{ steps.config.outputs.cache-path }} + - name: Cache vcpkg binaries uses: actions/cache@v4 with: