diff --git a/.github/workflows/ci-esp32.yml b/.github/workflows/ci-esp32.yml index 4b12890873..6b37b2aeff 100644 --- a/.github/workflows/ci-esp32.yml +++ b/.github/workflows/ci-esp32.yml @@ -86,8 +86,9 @@ jobs: . Tools/ci/setenv.ps1 Tools/ci/install.cmd - - name: Compiler Cache - uses: actions/cache@v4 + - name: Restore Compiler Cache + id: ccache + uses: actions/cache/restore@v4 with: path: .ccache key: ${{ matrix.os }}-ccache-${{ matrix.variant }}-${{ matrix.idf_version }} @@ -106,3 +107,19 @@ jobs: - name: Compiler Cache stats run: ccache -sv + + - name: Delete Previous Compiler Cache + if: github.ref_name == github.event.repository.default_branch && steps.ccache.outputs.cache-hit + continue-on-error: true + run: | + gh extension install actions/gh-actions-cache + gh actions-cache delete "${{ steps.ccache.outputs.cache-primary-key }}" --branch ${{ github.ref_name }} --confirm + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Save Compiler Cache + if: github.ref_name == github.event.repository.default_branch || !steps.ccache.outputs.cache-hit + uses: actions/cache/save@v4 + with: + path: .ccache + key: ${{ steps.ccache.outputs.cache-primary-key }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a639444de..536ab4e988 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,8 +75,9 @@ jobs: . Tools/ci/setenv.ps1 Tools/ci/install.cmd - - name: Compiler Cache - uses: actions/cache@v4 + - name: Restore Compiler Cache + id: ccache + uses: actions/cache/restore@v4 with: path: .ccache key: ${{ matrix.os }}-ccache-${{ matrix.toolchain }}-${{ matrix.variant }} @@ -97,3 +98,19 @@ jobs: - name: Compiler Cache stats run: ccache -sv + + - name: Delete Previous Compiler Cache + if: github.ref_name == github.event.repository.default_branch && steps.ccache.outputs.cache-hit + continue-on-error: true + run: | + gh extension install actions/gh-actions-cache + gh actions-cache delete "${{ steps.ccache.outputs.cache-primary-key }}" --branch ${{ github.ref_name }} --confirm + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Save Compiler Cache + if: github.ref_name == github.event.repository.default_branch || !steps.ccache.outputs.cache-hit + uses: actions/cache/save@v4 + with: + path: .ccache + key: ${{ steps.ccache.outputs.cache-primary-key }} diff --git a/.github/workflows/library.yml b/.github/workflows/library.yml index 126d3699ed..b01b4dbdd8 100644 --- a/.github/workflows/library.yml +++ b/.github/workflows/library.yml @@ -133,8 +133,9 @@ jobs: . Tools/ci/setenv.ps1 Tools/ci/install.cmd - - name: Compiler Cache - uses: actions/cache@v4 + - name: Restore Compiler Cache + id: ccache + uses: actions/cache/restore@v4 with: path: .ccache key: ${{ matrix.os }}-ccache-${{ matrix.variant }}-${{ matrix.arch == 'Esp32' && env.INSTALL_IDF_VER || '' }} @@ -155,3 +156,19 @@ jobs: - name: Compiler Cache stats run: ccache -sv + + - name: Delete Previous Compiler Cache + if: github.ref_name == github.event.repository.default_branch && steps.ccache.outputs.cache-hit + continue-on-error: true + run: | + gh extension install actions/gh-actions-cache + gh actions-cache delete "${{ steps.ccache.outputs.cache-primary-key }}" --branch ${{ github.ref_name }} --confirm + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Save Compiler Cache + if: github.ref_name == github.event.repository.default_branch || !steps.ccache.outputs.cache-hit + uses: actions/cache/save@v4 + with: + path: .ccache + key: ${{ steps.ccache.outputs.cache-primary-key }}