From 45083a20804893232634ae64641e4d4aad45ac34 Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Wed, 27 Nov 2024 04:53:09 -0700 Subject: [PATCH 1/7] Use GitHub Actions Cache support in `vcpkg` Replace the Nuget package caching for binary packages with the GitHub Actions Cache support. --- .github/workflows/build.yml | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6bfe9ae5..282a4d3d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: PLATFORM: ${{ matrix.platform }} BUILD_CONFIGURATION: Release SOLUTION_FILE_PATH: . - VCPKG_BINARY_SOURCES: 'clear;nuget,GitHub,readwrite' + VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite' steps: - uses: actions/checkout@v4 @@ -23,20 +23,12 @@ jobs: - name: Add MSBuild to PATH uses: microsoft/setup-msbuild@v1.3.2 - - name: Setup NuGet credentials - shell: bash - run: | - $(vcpkg fetch nuget | tail -n1) \ - sources add \ - -source "https://nuget.pkg.github.com/lairworks/index.json" \ - -storepasswordincleartext \ - -name "GitHub" \ - -username "lairworks" \ - -password "${{ secrets.GITHUB_TOKEN }}" - - $(vcpkg fetch nuget | tail -n1) \ - setApiKey "${{ secrets.GITHUB_TOKEN }}" \ - -source "https://nuget.pkg.github.com/lairworks/index.json" + - 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 || ''); - name: Restore vcpkg dependency cache uses: actions/cache@v4 From dada8b16cd4fe494b477c3da7b228bbcd256428c Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Wed, 27 Nov 2024 04:55:47 -0700 Subject: [PATCH 2/7] Empty commit to test cache performance From b4363504b4224487345f3ae2ac647968ef3aa8ed Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Wed, 27 Nov 2024 05:00:37 -0700 Subject: [PATCH 3/7] Remove overall vcpkg cache of all installed packages This means we rely on the caches of each individual binary package, rather than the entire collection of all of them. --- .github/workflows/build.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 282a4d3d..e4abd623 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,13 +30,6 @@ jobs: core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - - name: Restore vcpkg dependency cache - uses: actions/cache@v4 - id: cache - with: - path: vcpkg_installed - key: ${{ runner.os }}-${{ matrix.platform }}-${{ hashFiles('vcpkg.json') }} - - name: Restore incremental build cache uses: actions/cache/restore@v4 if: github.ref != format('refs/heads/{0}', github.event.repository.default_branch) From 95f5ba658d4ab91dfe454a0ffe32069ea1691ea6 Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Wed, 27 Nov 2024 05:05:04 -0700 Subject: [PATCH 4/7] Empty commit to test cache performance From d9c8d8847b5db301ed07f0a1fef0286d58b73b8a Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Wed, 27 Nov 2024 05:08:44 -0700 Subject: [PATCH 5/7] Revert "Remove overall vcpkg cache of all installed packages" This reverts commit b4363504b4224487345f3ae2ac647968ef3aa8ed. It appears there is a significant speed advantage to caching all packages as a whole. --- .github/workflows/build.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e4abd623..282a4d3d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,6 +30,13 @@ jobs: core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + - name: Restore vcpkg dependency cache + uses: actions/cache@v4 + id: cache + with: + path: vcpkg_installed + key: ${{ runner.os }}-${{ matrix.platform }}-${{ hashFiles('vcpkg.json') }} + - name: Restore incremental build cache uses: actions/cache/restore@v4 if: github.ref != format('refs/heads/{0}', github.event.repository.default_branch) From 9bfd6016184b663d1a9398148a5c01b2160cb08d Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Wed, 27 Nov 2024 05:09:36 -0700 Subject: [PATCH 6/7] Add `vcpkgCache-` prefix to cache `key` This makes the `key` more consistent with the `buildCachei-` prefixed `key`. This should make it easier to see the purpose of the cache entry on the caches page: https://github.com/lairworks/nas2d-core/actions/caches --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 282a4d3d..9656b4b8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,7 +35,7 @@ jobs: id: cache with: path: vcpkg_installed - key: ${{ runner.os }}-${{ matrix.platform }}-${{ hashFiles('vcpkg.json') }} + key: vcpkgCache-${{ runner.os }}-${{ matrix.platform }}-${{ hashFiles('vcpkg.json') }} - name: Restore incremental build cache uses: actions/cache/restore@v4 From b85e7e36b573a84fd11d4f7b23072eb1435d90f2 Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Wed, 27 Nov 2024 05:17:02 -0700 Subject: [PATCH 7/7] Empty commit to test cache performance