[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 09:02:40 PST 2025
https://github.com/tstellar created https://github.com/llvm/llvm-project/pull/124311
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.
>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] 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
More information about the llvm-commits
mailing list