diff --git a/.github/workflows/pr-ccache-restore/action.yml b/.github/workflows/pr-ccache-restore/action.yml new file mode 100644 index 0000000000000..9ae25b446f990 --- /dev/null +++ b/.github/workflows/pr-ccache-restore/action.yml @@ -0,0 +1,23 @@ +name: PR ccache restore + +inputs: + artifact-name-suffix: + desciption: The suffix to append to the artifict name (ccache-pr#) + required: true + +runs: + using: "composite" + steps: + - uses: ./.github/workflows/unprivileged-download-artifact + id: download-artifact + with: + artifact-name: ccache-pr${{ github.event.pull_request.number }}-${{ inputs.artifact-name-suffix }} + + - shell: bash + if: steps.download-artifact.outputs.filename != '' + run: | + # Is this the best way to clear the cache? + rm -Rf .ccache/ + rm ${{ steps.download-artifact.outputs.filename }} + tar --zstd -xf ccache.tar.zst + rm ccache.tar.zst diff --git a/.github/workflows/pr-ccache-save/action.yml b/.github/workflows/pr-ccache-save/action.yml new file mode 100644 index 0000000000000..b88f511d75179 --- /dev/null +++ b/.github/workflows/pr-ccache-save/action.yml @@ -0,0 +1,25 @@ +name: PR ccache save +inputs: + artifact-name-suffix: + desciption: The suffix to append to the artifict name (ccache-pr#) + required: true + +runs: + using: "composite" + steps: + - name: Package ccache Directory + shell: bash + run: | + # Dereference symlinks so that this works on Windows. + tar -h -c .ccache | zstd -T0 -c > ccache.tar.zst + - uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 + with: + name: 'ccache-pr${{ github.event.number }}-${{ inputs.artifact-name-suffix }}' + path: ccache.tar.zst + retention-days: 7 + overwrite: true + + - shell: bash + run: | + rm ccache.tar.zst + ccache --show-stats diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml index 30f4fc807f3a5..c10e8d17f7597 100644 --- a/.github/workflows/premerge.yaml +++ b/.github/workflows/premerge.yaml @@ -27,6 +27,13 @@ jobs: uses: hendrikmuhs/ccache-action@v1.2.14 with: max-size: "2000M" + - name: Install dependencies for pr-ccache-restore + run: | + sudo apt-get install zstd unzip + - name: Restore ccache from previous PR run + uses: ./.github/workflows/pr-ccache-restore + with: + artifact-name-suffix: Linux-x86 - name: Build and Test # Mark the job as a success even if the step fails so that people do # not get notified while the new premerge pipeline is in an @@ -70,3 +77,9 @@ jobs: export CXX=/opt/llvm/bin/clang++ ./.ci/monolithic-linux.sh "$(echo ${linux_projects} | tr ' ' ';')" "$(echo ${linux_check_targets})" "$(echo ${linux_runtimes} | tr ' ' ';')" "$(echo ${linux_runtime_check_targets})" + + - name: Save ccache for next PR run + if: always() + uses: ./.github/workflows/pr-ccache-save + with: + artifact-name-suffix: Linux-x86