Skip to content

Commit 4c444dd

Browse files
committed
workflows/premerge: Generate a ccache artifact for each pull request
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.
1 parent cccb554 commit 4c444dd

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: PR ccache restore
2+
3+
inputs:
4+
artifact-name-suffix:
5+
desciption: The suffix to append to the artifict name (ccache-pr#)
6+
required: true
7+
8+
runs:
9+
using: "composite"
10+
steps:
11+
- uses: ./.github/workflows/unprivileged-download-artifact
12+
id: download-artifact
13+
with:
14+
artifact-name: ccache-pr${{ github.event.pull_request.number }}-${{ inputs.artifact-name-suffix }}
15+
16+
- shell: bash
17+
if: steps.download-artifact.outputs.filename != ''
18+
run: |
19+
# Is this the best way to clear the cache?
20+
rm -Rf .ccache/
21+
unzip ${{ steps.download-artifact.outputs.filename }}
22+
rm ${{ steps.download-artifact.outputs.filename }}
23+
tar --zstd -xf ccache.tar.zst
24+
rm ccache.tar.zst
25+
ls -altr
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: PR ccache save
2+
inputs:
3+
artifact-name-suffix:
4+
desciption: The suffix to append to the artifict name (ccache-pr#)
5+
required: true
6+
7+
runs:
8+
using: "composite"
9+
steps:
10+
- name: Package ccache Directory
11+
shell: bash
12+
run: |
13+
# Dereference symlinks so that this works on Windows.
14+
tar -h -c .ccache | zstd -T0 -c > ccache.tar.zst
15+
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
16+
with:
17+
name: 'ccache-pr${{ github.event.number }}-${{ inputs.artifact-name-suffix }}'
18+
path: ccache.tar.zst
19+
retention-days: 7
20+
overwrite: true
21+
22+
- shell: bash
23+
run: |
24+
rm ccache.tar.zst
25+
ccache --show-stats

.github/workflows/premerge.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ jobs:
2727
uses: hendrikmuhs/[email protected]
2828
with:
2929
max-size: "2000M"
30+
- name: Restore ccache from previous PR run
31+
uses: ./.github/workflows/pr-ccache-restore
32+
with:
33+
artifact-name-suffix: Linux-x86
3034
- name: Build and Test
3135
# Mark the job as a success even if the step fails so that people do
3236
# not get notified while the new premerge pipeline is in an
@@ -70,3 +74,9 @@ jobs:
7074
export CXX=/opt/llvm/bin/clang++
7175
7276
./.ci/monolithic-linux.sh "$(echo ${linux_projects} | tr ' ' ';')" "$(echo ${linux_check_targets})" "$(echo ${linux_runtimes} | tr ' ' ';')" "$(echo ${linux_runtime_check_targets})"
77+
78+
- name: Save ccache for next PR run
79+
if: always()
80+
uses: ./.github/workflows/pr-ccache-save
81+
with:
82+
artifact-name-suffix: Linux-x86

0 commit comments

Comments
 (0)