diff --git a/.github/actions/setup-vcpkg/action.yml b/.github/actions/setup-vcpkg/action.yml new file mode 100644 index 000000000..23fbe436d --- /dev/null +++ b/.github/actions/setup-vcpkg/action.yml @@ -0,0 +1,41 @@ +--- +name: Set up cached vcpkg +description: Bootstrap the pinned vcpkg checkout and restore its binary and source caches. + +inputs: + cache-key: + description: Stable compiler-family key used to separate incompatible binary archives. + required: true + vcpkg-directory: + description: Directory containing the pinned vcpkg checkout. + default: ${{ github.workspace }}/.cache/vcpkg + required: false + +runs: + using: composite + steps: + - name: Prepare vcpkg binary cache + shell: bash + run: mkdir -p "$GITHUB_WORKSPACE/.cache/vcpkg-binary-cache" + + - name: Set up pinned vcpkg + uses: lukka/run-vcpkg@b1a0dd252f06b9e25b3c022a9a03bd7a427fb6a2 # v11.6 + with: + vcpkgDirectory: ${{ inputs.vcpkg-directory }} + vcpkgJsonGlob: vcpkg.json + + - name: Restore vcpkg binary archives + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ${{ github.workspace }}/.cache/vcpkg-binary-cache + key: vcpkg-binary-v1-${{ runner.os }}-${{ inputs.cache-key }}-${{ hashFiles('vcpkg.json', 'Justfile') }} + restore-keys: | + vcpkg-binary-v1-${{ runner.os }}-${{ inputs.cache-key }}- + + - name: Restore vcpkg source archives + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ${{ inputs.vcpkg-directory }}/downloads + key: vcpkg-assets-v1-${{ runner.os }}-${{ hashFiles('vcpkg.json') }} + restore-keys: | + vcpkg-assets-v1-${{ runner.os }}- diff --git a/.github/workflows/_sanitizer.yml b/.github/workflows/_sanitizer.yml index 7ca347ecf..0cb78b274 100644 --- a/.github/workflows/_sanitizer.yml +++ b/.github/workflows/_sanitizer.yml @@ -52,6 +52,7 @@ jobs: MSAN_OPTIONS: ${{ inputs.msan_options }} TSAN_OPTIONS: ${{ inputs.tsan_options }} UBSAN_OPTIONS: ${{ inputs.ubsan_options }} + VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/.cache/vcpkg-binary-cache,readwrite steps: - name: Check out repository @@ -74,10 +75,10 @@ jobs: - name: Set up pkgx uses: pkgxdev/setup@4d4ae97af87ccb39ab8be4e073dea697fef2c6f7 # v5.0.0 - - name: Restore artifacts or set up vcpkg - uses: lukka/run-vcpkg@b1a0dd252f06b9e25b3c022a9a03bd7a427fb6a2 # v11.6 + - name: Set up cached vcpkg + uses: ./.github/actions/setup-vcpkg with: - vcpkgJsonGlob: vcpkg.json + cache-key: clang-22 - name: Build and exercise sanitizer configuration env: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a9e9a9cc..7f49d79f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,8 @@ jobs: platform: name: ${{ matrix.name }} runs-on: ${{ matrix.os }} + env: + VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/.cache/vcpkg-binary-cache,readwrite strategy: fail-fast: false @@ -34,6 +36,7 @@ jobs: compiler_cache: ccache compiler_cache_key: gcc-16 run_parallel_contract: true + vcpkg_cache_key: gcc-16 - name: Ubuntu Clang os: ubuntu-latest compiler_package: llvm.org@22 @@ -42,6 +45,7 @@ jobs: compiler_cache: ccache compiler_cache_key: clang-22 run_parallel_contract: true + vcpkg_cache_key: clang-22 - name: macOS AppleClang os: macos-latest compiler_package: "" @@ -50,6 +54,7 @@ jobs: compiler_cache: "" compiler_cache_key: none run_parallel_contract: false + vcpkg_cache_key: appleclang - name: Windows MSVC os: windows-latest compiler_package: "" @@ -58,6 +63,7 @@ jobs: compiler_cache: "" compiler_cache_key: none run_parallel_contract: false + vcpkg_cache_key: msvc steps: - name: Disable Git autocrlf on Windows @@ -163,11 +169,10 @@ jobs: shell: pwsh run: Add-Content -Path $env:GITHUB_ENV -Value 'VCPKG_DEFAULT_TRIPLET=x64-windows' - - name: Restore artifacts or set up vcpkg - uses: lukka/run-vcpkg@b1a0dd252f06b9e25b3c022a9a03bd7a427fb6a2 # v11.6 + - name: Set up cached vcpkg + uses: ./.github/actions/setup-vcpkg with: - vcpkgDirectory: ${{ github.workspace }}/.cache/vcpkg - vcpkgJsonGlob: vcpkg.json + cache-key: ${{ matrix.vcpkg_cache_key }} - name: Restore compiler cache if: matrix.compiler_cache != '' diff --git a/.github/workflows/codecov-upload.yml b/.github/workflows/codecov-upload.yml index bf66aed87..9946f85e1 100644 --- a/.github/workflows/codecov-upload.yml +++ b/.github/workflows/codecov-upload.yml @@ -21,6 +21,8 @@ jobs: permissions: contents: read id-token: write # Intentionally required for Codecov's OIDC upload. + env: + VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/.cache/vcpkg-binary-cache,readwrite steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -89,10 +91,10 @@ jobs: ninja --version gcc --version - - name: Restore artifacts or setup vcpkg - uses: lukka/run-vcpkg@b1a0dd252f06b9e25b3c022a9a03bd7a427fb6a2 # v11.6 + - name: Set up cached vcpkg + uses: ./.github/actions/setup-vcpkg with: - vcpkgJsonGlob: vcpkg.json + cache-key: gcc-16 - name: Generate coverage reports env: diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index f6aef3007..ddd65a934 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -47,6 +47,8 @@ jobs: # only required for workflows in private repositories actions: read contents: read + env: + VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/.cache/vcpkg-binary-cache,readwrite strategy: fail-fast: false @@ -72,11 +74,11 @@ jobs: if: matrix.language == 'c-cpp' uses: pkgxdev/setup@4d4ae97af87ccb39ab8be4e073dea697fef2c6f7 # v5.0.0 - - name: Restore artifacts or set up vcpkg + - name: Set up cached vcpkg if: matrix.language == 'c-cpp' - uses: lukka/run-vcpkg@b1a0dd252f06b9e25b3c022a9a03bd7a427fb6a2 # v11.6 + uses: ./.github/actions/setup-vcpkg with: - vcpkgJsonGlob: vcpkg.json + cache-key: gcc-16 - name: Prepare C++ dependencies outside CodeQL tracing if: matrix.language == 'c-cpp' diff --git a/README.md b/README.md index 75156fb14..f6e645753 100644 --- a/README.md +++ b/README.md @@ -376,9 +376,10 @@ only writes when the rendered release and hash assignments differ from the boots On Windows, invoke the synchronizer with `python.exe scripts\sync_vcpkg_tool_pins.py`; `scripts\build.bat` and `scripts\fast-build.bat` already invoke the bootstrap implementation directly. -CI uses `lukka/run-vcpkg`, which derives the vcpkg checkout commit from the same manifest baseline and supplies a -binary cache. No separately maintained checkout SHA is required; the bootstrap script retains an independent tool -release and Windows executable hashes as a supply-chain review gate. +CI uses the repository's cached-vcpkg action, which derives the vcpkg checkout commit from the same manifest baseline, +stores compiler-specific binary archives through `actions/cache`, and separately caches downloaded source archives. +No separately maintained checkout SHA is required; the bootstrap script retains an independent tool release and +Windows executable hashes as a supply-chain review gate. CodeQL keeps third-party implementation findings out of CDT++ results through a two-phase manual build. `just codeql-prepare` configures the project, installs manifest dependencies before CodeQL starts tracing, and uses a