[llvm] workflows/premerge: Generate a ccache artifact for each pull request (PR #124311)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 24 15:25:30 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-github-workflow
Author: Tom Stellard (tstellar)
<details>
<summary>Changes</summary>
This allows each update for a pull request to reuse the ccache data from the previous run for that pull request. This will help improve build times since the ccache data used will be specific to the pull request and not polluted with builds of other PRs.
---
Full diff: https://github.com/llvm/llvm-project/pull/124311.diff
3 Files Affected:
- (added) .github/workflows/pr-ccache-restore/action.yml (+23)
- (added) .github/workflows/pr-ccache-save/action.yml (+25)
- (modified) .github/workflows/premerge.yaml (+13)
``````````diff
diff --git a/.github/workflows/pr-ccache-restore/action.yml b/.github/workflows/pr-ccache-restore/action.yml
new file mode 100644
index 00000000000000..9ae25b446f9909
--- /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 00000000000000..b88f511d751794
--- /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 at 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 30f4fc807f3a57..c10e8d17f75979 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -27,6 +27,13 @@ jobs:
uses: hendrikmuhs/ccache-action at 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
``````````
</details>
https://github.com/llvm/llvm-project/pull/124311
More information about the llvm-commits
mailing list