Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/actions/setup-vcpkg/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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:
- 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"

# 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:
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 }}-
13 changes: 3 additions & 10 deletions .github/workflows/linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: linux

on: [ push, pull_request ]

env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"

jobs:
linux:
strategy:
Expand Down Expand Up @@ -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
Expand Down
13 changes: 3 additions & 10 deletions .github/workflows/macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: macos

on: [ push, pull_request ]

env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"

jobs:
macos-clang:
strategy:
Expand All @@ -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
Expand Down
25 changes: 8 additions & 17 deletions .github/workflows/windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: windows

on: [ push, pull_request ]

env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"

jobs:
windows-msvc:
strategy:
Expand All @@ -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: |
Expand Down Expand Up @@ -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: |
Expand Down
Loading