From 18ee6e457dda39901d230be7a42b1fee3e3a78d6 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Sat, 27 May 2023 17:00:00 +0200 Subject: [PATCH] CI: Update `actions/cache` to v3 This version now natively supports read-only caches (`cache/restore@v3`) so we no longer need to pin the version to a commit in actions/cache#489 which is an unmerged PR. The update is mostly mechanical: - Steps with `CACHE_SKIP_SAVE` not set can use the plain `cache@v3` action. - Steps with `CACHE_SKIP_SAVE` set to a constant `true` are changed to `cache/restore@v3`. - Steps with saving disabled when running on a pull request are changed to a pair of `cache/restore@v3` and `cache/save@v3`. This setup is used for the large (100s of MB) ccache and Toolchain caches. As caches saved in pull requests can only be utilized from within the same PR, uploading these would only waste time and our storage quote. Therefore, we skip the `save` steps if running on a PR. Co-authored-by: Cameron Youell --- .github/workflows/cmake.yml | 38 ++++++++++++------- .github/workflows/libjs-test262.yml | 9 ++--- .../workflows/pvs-studio-static-analysis.yml | 17 +++------ .github/workflows/serenity-js-artifacts.yml | 9 ++--- .../workflows/sonar-cloud-static-analysis.yml | 17 +++------ .github/workflows/wasm.yml | 6 +-- 6 files changed, 43 insertions(+), 53 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 575f5522527..51f2c1fc7f1 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -83,10 +83,8 @@ jobs: message("::set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/Patches/gcc/*.patch', 'Toolchain/BuildIt.sh') }}") - name: Toolchain cache - # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b - env: - CACHE_SKIP_SAVE: ${{ github.event_name == 'pull_request' }} + uses: actions/cache/restore@v3 + id: toolchain-cache with: path: ${{ github.workspace }}/Toolchain/Cache/ # This assumes that *ALL* LibC and LibPthread headers have an impact on the Toolchain. @@ -97,12 +95,19 @@ jobs: - name: Restore or regenerate Toolchain run: TRY_USE_LOCAL_TOOLCHAIN=y ARCH="${{ matrix.arch }}" ${{ github.workspace }}/Toolchain/BuildIt.sh + - name: Update toolchain cache + uses: actions/cache/save@v3 + # Do not waste time and storage space by updating the toolchain cache from a PR, + # as it would be discarded after being merged anyway. + if: ${{ github.event_name != 'pull_request' && !steps.toolchain-cache.outputs.cache-hit }} + with: + path: ${{ github.workspace }}/Toolchain/Cache/ + key: ${{ steps.toolchain-cache.outputs.cache-primary-key }} + - name: ccache(1) cache # Pull the ccache *after* building the toolchain, in case building the Toolchain somehow interferes. - # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b - env: - CACHE_SKIP_SAVE: ${{ github.event_name == 'pull_request' }} + uses: actions/cache/restore@v3 + id: ccache with: path: ${{ github.workspace }}/.ccache # If you're here because ccache broke (it never should), increment matrix.ccache-mark. @@ -131,20 +136,17 @@ jobs: mkdir -p ${{ github.workspace }}/Build/caches/UCD mkdir -p ${{ github.workspace }}/Build/caches/CLDR - name: TimeZoneData cache - # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b + uses: actions/cache@v3 with: path: ${{ github.workspace }}/Build/caches/TZDB key: TimeZoneData-${{ hashFiles('Meta/CMake/time_zone_data.cmake') }} - name: UnicodeData cache - # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b + uses: actions/cache@v3 with: path: ${{ github.workspace }}/Build/caches/UCD key: UnicodeData-${{ hashFiles('Meta/CMake/unicode_data.cmake') }} - name: UnicodeLocale Cache - # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b + uses: actions/cache@v3 with: path: ${{ github.workspace }}/Build/caches/CLDR key: UnicodeLocale-${{ hashFiles('Meta/CMake/locale_data.cmake') }} @@ -185,6 +187,14 @@ jobs: run: cmake --build . - name: Show ccache stats after build run: ccache -s + + - name: Update ccache(1) cache + uses: actions/cache/save@v3 + if: ${{ github.event_name != 'pull_request' }} + with: + path: ${{ github.workspace }}/.ccache + key: ${{ steps.ccache.outputs.cache-primary-key }} + - name: Lint (Phase 2/2) working-directory: ${{ github.workspace }}/Meta env: diff --git a/.github/workflows/libjs-test262.yml b/.github/workflows/libjs-test262.yml index a470fe99f4e..2569a21fe5b 100644 --- a/.github/workflows/libjs-test262.yml +++ b/.github/workflows/libjs-test262.yml @@ -77,22 +77,19 @@ jobs: mkdir -p libjs-test262/Build/CLDR - name: TimeZoneData cache - # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b + uses: actions/cache@v3 with: path: ${{ github.workspace }}/libjs-test262/Build/TZDB key: TimeZoneData-${{ hashFiles('Meta/CMake/time_zone_data.cmake') }} - name: UnicodeData cache - # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b + uses: actions/cache@v3 with: path: ${{ github.workspace }}/libjs-test262/Build/UCD key: UnicodeData-${{ hashFiles('Meta/CMake/unicode_data.cmake') }} - name: UnicodeLocale cache - # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b + uses: actions/cache@v3 with: path: ${{ github.workspace }}/libjs-test262/Build/CLDR key: UnicodeLocale-${{ hashFiles('Meta/CMake/locale_data.cmake') }} diff --git a/.github/workflows/pvs-studio-static-analysis.yml b/.github/workflows/pvs-studio-static-analysis.yml index ed3a175255f..e03afbf0bb9 100644 --- a/.github/workflows/pvs-studio-static-analysis.yml +++ b/.github/workflows/pvs-studio-static-analysis.yml @@ -46,12 +46,8 @@ jobs: message("::set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/Patches/gcc/*.patch', 'Toolchain/BuildIt.sh') }}") - name: Toolchain cache - # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b - env: - # This job should always read the cache, never populate it. - CACHE_SKIP_SAVE: true - + # This job should always read the cache, never populate it. + uses: actions/cache/restore@v3 with: path: ${{ github.workspace }}/Toolchain/Cache/ # This assumes that *ALL* LibC and LibPthread headers have an impact on the Toolchain. @@ -70,20 +66,17 @@ jobs: mkdir -p ${{ github.workspace }}/Build/caches/CLDR - name: TimeZoneData cache - # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b + uses: actions/cache@v3 with: path: ${{ github.workspace }}/Build/caches/TZDB key: TimeZoneData-${{ hashFiles('Meta/CMake/time_zone_data.cmake') }} - name: UnicodeData cache - # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b + uses: actions/cache@v3 with: path: ${{ github.workspace }}/Build/caches/UCD key: UnicodeData-${{ hashFiles('Meta/CMake/unicode_data.cmake') }} - name: UnicodeLocale Cache - # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b + uses: actions/cache@v3 with: path: ${{ github.workspace }}/Build/caches/CLDR key: UnicodeLocale-${{ hashFiles('Meta/CMake/locale_data.cmake') }} diff --git a/.github/workflows/serenity-js-artifacts.yml b/.github/workflows/serenity-js-artifacts.yml index e6978733f66..4f4390ad15a 100644 --- a/.github/workflows/serenity-js-artifacts.yml +++ b/.github/workflows/serenity-js-artifacts.yml @@ -60,22 +60,19 @@ jobs: mkdir -p Build/CLDR - name: TimeZoneData cache - # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b + uses: actions/cache@v3 with: path: ${{ github.workspace }}/libjs-test262/Build/TZDB key: TimeZoneData-${{ hashFiles('Meta/CMake/time_zone_data.cmake') }} - name: UnicodeData cache - # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b + uses: actions/cache@v3 with: path: ${{ github.workspace }}/libjs-test262/Build/UCD key: UnicodeData-${{ hashFiles('Meta/CMake/unicode_data.cmake') }} - name: UnicodeLocale cache - # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b + uses: actions/cache@v3 with: path: ${{ github.workspace }}/libjs-test262/Build/CLDR key: UnicodeLocale-${{ hashFiles('Meta/CMake/locale_data.cmake') }} diff --git a/.github/workflows/sonar-cloud-static-analysis.yml b/.github/workflows/sonar-cloud-static-analysis.yml index 80b7e59bdf0..d94b3a45b94 100644 --- a/.github/workflows/sonar-cloud-static-analysis.yml +++ b/.github/workflows/sonar-cloud-static-analysis.yml @@ -78,12 +78,8 @@ jobs: message("::set-output name=libc_headers::${{ hashFiles('Userland/Libraries/LibC/**/*.h', 'Userland/Libraries/LibPthread/**/*.h', 'Toolchain/Patches/*.patch', 'Toolchain/Patches/gcc/*.patch', 'Toolchain/BuildIt.sh') }}") - name: Toolchain cache - # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b - env: - # This job should always read the cache, never populate it. - CACHE_SKIP_SAVE: true - + # This job should always read the cache, never populate it. + uses: actions/cache/restore@v3 with: path: ${{ github.workspace }}/Toolchain/Cache/ # This assumes that *ALL* LibC and LibPthread headers have an impact on the Toolchain. @@ -102,20 +98,17 @@ jobs: mkdir -p ${{ github.workspace }}/Build/caches/CLDR - name: TimeZoneData cache - # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b + uses: actions/cache@v3 with: path: ${{ github.workspace }}/Build/caches/TZDB key: TimeZoneData-${{ hashFiles('Meta/CMake/time_zone_data.cmake') }} - name: UnicodeData cache - # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b + uses: actions/cache@v3 with: path: ${{ github.workspace }}/Build/caches/UCD key: UnicodeData-${{ hashFiles('Meta/CMake/unicode_data.cmake') }} - name: UnicodeLocale Cache - # TODO: Change the version to the released version when https://github.com/actions/cache/pull/489 (or 571) is merged. - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b + uses: actions/cache@v3 with: path: ${{ github.workspace }}/Build/caches/CLDR key: UnicodeLocale-${{ hashFiles('Meta/CMake/locale_data.cmake') }} diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index a054a40bede..f4e1b11bb0d 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -37,17 +37,17 @@ jobs: mkdir -p ${{ github.workspace }}/Build/caches/UCD mkdir -p ${{ github.workspace }}/Build/caches/CLDR - name: "TimeZoneData cache" - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b + uses: actions/cache@v3 with: path: ${{ github.workspace }}/Build/caches/TZDB key: TimeZoneData-${{ hashFiles('Meta/CMake/time_zone_data.cmake') }} - name: "UnicodeData cache" - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b + uses: actions/cache@v3 with: path: ${{ github.workspace }}/Build/caches/UCD key: UnicodeData-${{ hashFiles('Meta/CMake/unicode_data.cmake') }} - name: "UnicodeLocale cache" - uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b + uses: actions/cache@v3 with: path: ${{ github.workspace }}/Build/caches/CLDR key: UnicodeLocale-${{ hashFiles('Meta/CMake/locale_data.cmake') }}