From c2ebb122b3ded14b67af6bafa45f317b6885e3ff Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Fri, 10 Jan 2025 10:12:58 -0700 Subject: [PATCH 1/2] Eliminate GitHub Actions Cache Save warning Normally when a cache is restored with a hit of the primary key, we don't expect any changes to the output, so there should be no reason to save the cache. In fact, if we try, we'll get a warning. This shows up in both the cache save step, and in an annotation on the workflow run summary page. We don't really want to see that. Hence, we disable saving the cache when we know it would produce a warning. For the OPHD incremental build cache, we skip the restore for the default branch. Hence we always want to save the cache when the restore step is skipped. That way we save a cache for branches to build incrementally from. --- .github/workflows/build.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f93e1b8fa..3bccc9f5b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,6 +35,7 @@ jobs: - name: Restore vcpkg dependency cache uses: actions/cache/restore@v4 + id: cacheRestoreVcpkg with: path: vcpkg_installed key: vcpkgCache-${{ runner.os }}-${{ matrix.platform }}-${{ hashFiles('vcpkg.json') }} @@ -45,6 +46,7 @@ jobs: - name: Save vcpkg dependency cache uses: actions/cache/save@v4 + if: steps.cacheRestoreVcpkg.outputs.cache-hit == 'false' with: path: vcpkg_installed key: vcpkgCache-${{ runner.os }}-${{ matrix.platform }}-${{ hashFiles('vcpkg.json') }} @@ -71,6 +73,7 @@ jobs: - name: Restore NAS2D cache uses: actions/cache/restore@v4 + id: cacheRestoreNas2d with: path: nas2d-core/.build/ key: nas2dCache-${{ runner.os }}-${{ matrix.platform }}-${{ env.nas2dSha }} @@ -84,12 +87,14 @@ jobs: - name: Save build cache - NAS2D uses: actions/cache/save@v4 + if: steps.cacheRestoreNas2d.outputs.cache-hit == 'false' with: path: nas2d-core/.build/ key: nas2dCache-${{ runner.os }}-${{ matrix.platform }}-${{ env.nas2dSha }} - name: Restore incremental build cache uses: actions/cache/restore@v4 + id: cacheRestoreOphd if: github.ref != format('refs/heads/{0}', github.event.repository.default_branch) with: path: .build @@ -134,6 +139,7 @@ jobs: - name: Save incremental build cache - OPHD uses: actions/cache/save@v4 + if: steps.cacheRestoreOphd.outcome == 'skipped' || steps.cacheRestoreOphd.outputs.cache-hit == 'false' with: path: .build key: buildCache-${{ runner.os }}-${{ matrix.platform }}-${{ github.sha }} From dc309524579154913ab59356c0e3aa75a06990e9 Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Fri, 10 Jan 2025 10:15:37 -0700 Subject: [PATCH 2/2] Reduce repetition of keys when saving cache Re-use the already generated primary key from when we tried to restore the cache. Don't try this for the OPHD build cache, since the restore step is skipped for the default branch, and we definitely want to save when the restore step is skipped. --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3bccc9f5b..4fa4a11d3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,7 +49,7 @@ jobs: if: steps.cacheRestoreVcpkg.outputs.cache-hit == 'false' with: path: vcpkg_installed - key: vcpkgCache-${{ runner.os }}-${{ matrix.platform }}-${{ hashFiles('vcpkg.json') }} + key: ${{ steps.cacheRestoreVcpkg.outputs.cache-primary-key }} - name: Copy vcpkg cache to NAS2D folder run: | @@ -90,7 +90,7 @@ jobs: if: steps.cacheRestoreNas2d.outputs.cache-hit == 'false' with: path: nas2d-core/.build/ - key: nas2dCache-${{ runner.os }}-${{ matrix.platform }}-${{ env.nas2dSha }} + key: ${{ steps.cacheRestoreNas2d.outputs.cache-primary-key }} - name: Restore incremental build cache uses: actions/cache/restore@v4