# HG changeset patch # User Patric Stout # Date 2023-12-30 16:58:18 # Node ID bb1633c752358ed462b7fc2e1dc42b11d27b227b # Parent 28c861a561805d421d6dfbd0af04a111c479a8ab Change: [CI] use vcpkg built-in caching mechanism diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -108,6 +108,14 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Setup vcpkg caching + uses: actions/github-script@v6 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite') + - name: Install dependencies run: | echo "::group::Update apt" @@ -192,18 +200,13 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Prepare cache key - id: key - run: | - echo "image=$ImageOS-$ImageVersion" >> $GITHUB_OUTPUT - - - name: Enable vcpkg cache - uses: actions/cache@v3 + - name: Setup vcpkg caching + uses: actions/github-script@v6 with: - path: /usr/local/share/vcpkg/installed - key: ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }}-1 # Increase the number whenever dependencies are modified - restore-keys: | - ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }} + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite') - name: Prepare vcpkg run: | @@ -272,22 +275,13 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Prepare cache key - id: key - shell: powershell - run: | - # Work around caching failure with GNU tar - New-Item -Type Junction -Path vcpkg -Target c:\vcpkg - - Write-Output "image=$env:ImageOS-$env:ImageVersion" >> $env:GITHUB_OUTPUT - - - name: Enable vcpkg cache - uses: actions/cache@v3 + - name: Setup vcpkg caching + uses: actions/github-script@v6 with: - path: vcpkg/installed - key: ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }}-1 # Increase the number whenever dependencies are modified - restore-keys: | - ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }} + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite') - name: Prepare vcpkg shell: bash diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml --- a/.github/workflows/release-linux.yml +++ b/.github/workflows/release-linux.yml @@ -17,11 +17,6 @@ jobs: # manylinux2014 is based on CentOS 7, but already has a lot of things # installed and preconfigured. It makes it easier to build OpenTTD. image: quay.io/pypa/manylinux2014_x86_64 - volumes: - - /usr/local/share/vcpkg:/vcpkg - env: - ImageOS: ${{ env.ImageOS }} - ImageVersion: ${{ env.ImageVersion }} steps: - name: Download source @@ -57,18 +52,13 @@ jobs: - name: Enable Rust cache uses: Swatinem/rust-cache@v2 - - name: Prepare cache key - id: key - run: | - echo "image=$ImageOS-$ImageVersion" >> $GITHUB_OUTPUT - - - name: Enable vcpkg cache - uses: actions/cache@v3 + - name: Setup vcpkg caching + uses: actions/github-script@v6 with: - path: /vcpkg/installed - key: ${{ steps.key.outputs.image }}-vcpkg-release-1 # Increase the number whenever dependencies are modified - restore-keys: | - ${{ steps.key.outputs.image }}-vcpkg-release + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite') - name: Install dependencies run: | @@ -132,7 +122,16 @@ jobs: # We use vcpkg for our dependencies, to get more up-to-date version. echo "::group::Install vcpkg and dependencies" - # Make Python3 available for other packages. + git clone https://github.com/microsoft/vcpkg /vcpkg + + ( + cd /vcpkg + ./bootstrap-vcpkg.sh -disableMetrics + ) + + # Make Python3 available for other packages. This needs to be done + # first, as otherwise dependencies fail to build because Python3 is + # not available. /vcpkg/vcpkg install python3 ln -sf /vcpkg/installed/x64-linux/tools/python3/python3.[0-9][0-9] /usr/bin/python3 diff --git a/.github/workflows/release-macos.yml b/.github/workflows/release-macos.yml --- a/.github/workflows/release-macos.yml +++ b/.github/workflows/release-macos.yml @@ -32,6 +32,14 @@ jobs: - name: Enable Rust cache uses: Swatinem/rust-cache@v2 + - name: Setup vcpkg caching + uses: actions/github-script@v6 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite') + - name: Install dependencies env: HOMEBREW_NO_AUTO_UPDATE: 1 @@ -47,20 +55,6 @@ jobs: cargo install dump_syms echo "::endgroup::" - - name: Prepare cache key - id: key - run: | - echo "image=$ImageOS-$ImageVersion" >> $GITHUB_OUTPUT - - - name: Enable vcpkg cache - uses: actions/cache@v3 - with: - path: /usr/local/share/vcpkg/installed - key: ${{ steps.key.outputs.image }}-vcpkg-release-1 # Increase the number whenever dependencies are modified - restore-keys: | - ${{ steps.key.outputs.image }}-vcpkg-release - ${{ steps.key.outputs.image }}-vcpkg-x64 - - name: Prepare vcpkg run: | vcpkg install \ diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml --- a/.github/workflows/release-windows.yml +++ b/.github/workflows/release-windows.yml @@ -45,6 +45,14 @@ jobs: - name: Enable Rust cache uses: Swatinem/rust-cache@v2 + - name: Setup vcpkg caching + uses: actions/github-script@v6 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite') + - name: Install dependencies shell: bash run: | @@ -56,23 +64,6 @@ jobs: cargo install dump_syms echo "::endgroup::" - - name: Prepare cache key - id: key - shell: powershell - run: | - # Work around caching failure with GNU tar - New-Item -Type Junction -Path vcpkg -Target c:\vcpkg - - Write-Output "image=$env:ImageOS-$env:ImageVersion" >> $env:GITHUB_OUTPUT - - - name: Enable vcpkg cache - uses: actions/cache@v3 - with: - path: vcpkg/installed - key: ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }}-1 # Increase the number whenever dependencies are modified - restore-keys: | - ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }} - - name: Prepare vcpkg shell: bash run: |