[llvm] workflows/premerge: Generate a ccache artifact for each pull request (PR #124311)
Tom Stellard via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 24 15:20:11 PST 2025
https://github.com/tstellar updated https://github.com/llvm/llvm-project/pull/124311
>From 4c444dd73636b7628d17fef5ed689d4f8fcd5115 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Fri, 24 Jan 2025 08:57:23 -0800
Subject: [PATCH 1/5] 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.
---
.../workflows/pr-ccache-restore/action.yml | 25 +++++++++++++++++++
.github/workflows/pr-ccache-save/action.yml | 25 +++++++++++++++++++
.github/workflows/premerge.yaml | 10 ++++++++
3 files changed, 60 insertions(+)
create mode 100644 .github/workflows/pr-ccache-restore/action.yml
create mode 100644 .github/workflows/pr-ccache-save/action.yml
diff --git a/.github/workflows/pr-ccache-restore/action.yml b/.github/workflows/pr-ccache-restore/action.yml
new file mode 100644
index 00000000000000..0630d5033b1865
--- /dev/null
+++ b/.github/workflows/pr-ccache-restore/action.yml
@@ -0,0 +1,25 @@
+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/
+ unzip ${{ steps.download-artifact.outputs.filename }}
+ rm ${{ steps.download-artifact.outputs.filename }}
+ tar --zstd -xf ccache.tar.zst
+ rm ccache.tar.zst
+ ls -altr
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..14d0230b3a4e1d 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -27,6 +27,10 @@ jobs:
uses: hendrikmuhs/ccache-action at v1.2.14
with:
max-size: "2000M"
+ - 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 +74,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
>From 2e4bd05402f6e1e2e173905a9de43e4a446c390d Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Fri, 24 Jan 2025 09:11:00 -0800
Subject: [PATCH 2/5] Install zstd
---
.github/workflows/premerge.yaml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 14d0230b3a4e1d..976ac17224bb4b 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -27,6 +27,9 @@ jobs:
uses: hendrikmuhs/ccache-action at v1.2.14
with:
max-size: "2000M"
+ - name: Install zstd
+ run: |
+ sudo apt-get install zstd
- name: Restore ccache from previous PR run
uses: ./.github/workflows/pr-ccache-restore
with:
>From fd8f0f5f5bc79bd442b90190e1ff68121fc2daec Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Fri, 24 Jan 2025 09:47:00 -0800
Subject: [PATCH 3/5] Install unzip
---
.github/workflows/premerge.yaml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 976ac17224bb4b..c10e8d17f75979 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -27,9 +27,9 @@ jobs:
uses: hendrikmuhs/ccache-action at v1.2.14
with:
max-size: "2000M"
- - name: Install zstd
+ - name: Install dependencies for pr-ccache-restore
run: |
- sudo apt-get install zstd
+ sudo apt-get install zstd unzip
- name: Restore ccache from previous PR run
uses: ./.github/workflows/pr-ccache-restore
with:
>From 739015e5a3f0c4a4203d68ee400dffc4cdd09aa7 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Fri, 24 Jan 2025 14:51:43 -0800
Subject: [PATCH 4/5] Fix cache restore
---
.github/workflows/pr-ccache-restore/action.yml | 1 -
1 file changed, 1 deletion(-)
diff --git a/.github/workflows/pr-ccache-restore/action.yml b/.github/workflows/pr-ccache-restore/action.yml
index 0630d5033b1865..4c3508071ffc49 100644
--- a/.github/workflows/pr-ccache-restore/action.yml
+++ b/.github/workflows/pr-ccache-restore/action.yml
@@ -18,7 +18,6 @@ runs:
run: |
# Is this the best way to clear the cache?
rm -Rf .ccache/
- unzip ${{ steps.download-artifact.outputs.filename }}
rm ${{ steps.download-artifact.outputs.filename }}
tar --zstd -xf ccache.tar.zst
rm ccache.tar.zst
>From ae2c605ae3f65483dc89e950dea57a1d6cd07b5e Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Fri, 24 Jan 2025 15:18:02 -0800
Subject: [PATCH 5/5] Remove deugging
---
.github/workflows/pr-ccache-restore/action.yml | 1 -
1 file changed, 1 deletion(-)
diff --git a/.github/workflows/pr-ccache-restore/action.yml b/.github/workflows/pr-ccache-restore/action.yml
index 4c3508071ffc49..9ae25b446f9909 100644
--- a/.github/workflows/pr-ccache-restore/action.yml
+++ b/.github/workflows/pr-ccache-restore/action.yml
@@ -21,4 +21,3 @@ runs:
rm ${{ steps.download-artifact.outputs.filename }}
tar --zstd -xf ccache.tar.zst
rm ccache.tar.zst
- ls -altr
More information about the llvm-commits
mailing list