-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Workflows: Add composite actions for managing sccache caches for a PR #101578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
These actions allow you to create and reusue an sccache cache that is unique to a PR. This way each time you update a PR you will be able to resuse the sccache cache from the previous PR build. This will help increase the cache hit rate vs trying to use a global cache that is share amongst several PRs.
@llvm/pr-subscribers-github-workflow Author: Tom Stellard (tstellar) ChangesThese actions allow you to create and reusue an sccache cache that is unique to a PR. This way each time you update a PR you will be able to resuse the sccache cache from the previous PR build. This will help increase the cache hit rate vs trying to use a global cache that is share amongst several PRs. Full diff: https://github.com/llvm/llvm-project/pull/101578.diff 2 Files Affected:
diff --git a/.github/workflows/pr-sccache-restore/action.yml b/.github/workflows/pr-sccache-restore/action.yml
new file mode 100644
index 0000000000000..8aa87025ba54b
--- /dev/null
+++ b/.github/workflows/pr-sccache-restore/action.yml
@@ -0,0 +1,26 @@
+name: PR sccache restore
+
+inputs:
+ artifact-name-suffix:
+ desciption: The suffix to append to the artifict name (sccache-pr#)
+ required: true
+
+runs:
+ using: "composite"
+ steps:
+ - uses: ./.github/workflows/unprivileged-download-artifact
+ id: download-artifact
+ with:
+ artifact-name: sccache-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 .sccache/
+ unzip ${{ steps.download-artifact.outputs.filename }}
+ rm ${{ steps.download-artifact.outputs.filename }}
+ tar --zstd -xf sccache.tar.zst
+ rm sccache.tar.zst
+ ls -altr
+
diff --git a/.github/workflows/pr-sccache-save/action.yml b/.github/workflows/pr-sccache-save/action.yml
new file mode 100644
index 0000000000000..badf623d32d5e
--- /dev/null
+++ b/.github/workflows/pr-sccache-save/action.yml
@@ -0,0 +1,27 @@
+name: PR sccache save
+inputs:
+ artifact-name-suffix:
+ desciption: The suffix to append to the artifict name (sccache-pr#)
+ required: true
+
+runs:
+ using: "composite"
+ steps:
+ - name: Package sccache Directory
+ shell: bash
+ run: |
+ # Dereference symlinks so that this works on Windows.
+ tar -h -c .sccache | zstd -T0 -c > sccache.tar.zst
+
+ - uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
+ with:
+ name: 'sccache-pr${{ github.event.number }}-${{ inputs.artifact-name-suffix }}'
+ path: sccache.tar.zst
+ retention-days: 7
+ overwrite: true
+
+ - shell: bash
+ run: |
+ rm sccache.tar.zst
+ sccache --show-stats
+
|
Will the cache always be empty the first time we build a PR? Shouldn't we want a cache from whatever basenline as a fallback so that we can get some cache hits when we build the PR the first time? |
In the first run, this action will do nothing, so whatever cache you had in place when you ran the ccache-action step will still be there. Here is an example usage: llvm-project/.github/workflows/ci-tests.yml Line 135 in 2ab4497
In this example we have the ccache-action configured to use a cache shared by other PRs (and potentially pushes to main if we wanted to set it up that way). |
These actions allow you to create and reusue an sccache cache that is unique to a PR. This way each time you update a PR you will be able to resuse the sccache cache from the previous PR build. This will help increase the cache hit rate vs trying to use a global cache that is share amongst several PRs.