summaryrefslogtreecommitdiff
path: root/.github/scripts/select-linux-ccache-save.sh
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2026-09-26 23:24:03 +0200
committerChristoph Berg <myon@debian.org>2026-09-26 23:24:03 +0200
commit059831534c7e884f0a607ed86b582fd00d821731 (patch)
tree76bcb67a78f8aa2654fd34c2ad801a62136b0170 /.github/scripts/select-linux-ccache-save.sh
parentd83a420f0517d7fc47aeb288a6a0cf4891784fcc (diff)
New upstream version 3.2.0~rc1+dfsgupstream/3.2.0_rc1+dfsg
Diffstat (limited to '.github/scripts/select-linux-ccache-save.sh')
-rwxr-xr-x.github/scripts/select-linux-ccache-save.sh70
1 files changed, 70 insertions, 0 deletions
diff --git a/.github/scripts/select-linux-ccache-save.sh b/.github/scripts/select-linux-ccache-save.sh
new file mode 100755
index 00000000..730c3a2e
--- /dev/null
+++ b/.github/scripts/select-linux-ccache-save.sh
@@ -0,0 +1,70 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+# Base-branch caches are visible to pull requests. Keep publication limited to
+# automatic develop builds and explicit maintainer requests on develop.
+should_save_linux_ccache() {
+ local event_name=$1
+ local ref=$2
+ local requested_save=$3
+ local recache=$4
+
+ if [ "$ref" != "refs/heads/develop" ]; then
+ return 1
+ fi
+
+ case "$event_name" in
+ push)
+ return 0
+ ;;
+ workflow_dispatch)
+ [ "$requested_save" = true ] || [ "$recache" = true ]
+ ;;
+ *)
+ return 1
+ ;;
+ esac
+}
+
+expect_save() {
+ if ! should_save_linux_ccache "$@"; then
+ echo "self-test failed: expected cache save for $*" >&2
+ exit 1
+ fi
+}
+
+expect_no_save() {
+ if should_save_linux_ccache "$@"; then
+ echo "self-test failed: expected no cache save for $*" >&2
+ exit 1
+ fi
+}
+
+if [ "${1:-}" = --self-test ]; then
+ expect_save push refs/heads/develop false false
+ expect_save workflow_dispatch refs/heads/develop true false
+ expect_save workflow_dispatch refs/heads/develop false true
+ expect_save workflow_dispatch refs/heads/develop true true
+
+ expect_no_save pull_request refs/pull/421/merge true true
+ expect_no_save workflow_dispatch refs/heads/topic true false
+ expect_no_save workflow_dispatch refs/heads/develop false false
+ expect_no_save schedule refs/heads/develop true true
+
+ echo "select-linux-ccache-save.sh self-test passed"
+ exit 0
+fi
+
+save_ccache=false
+if should_save_linux_ccache \
+ "${EVENT_NAME:-}" \
+ "${GITHUB_REF:-}" \
+ "${REQUEST_SAVE_CCACHE:-false}" \
+ "${RECACHE:-false}"; then
+ save_ccache=true
+fi
+
+echo "Linux ccache save: $save_ccache"
+if [ -n "${GITHUB_OUTPUT:-}" ]; then
+ echo "save_ccache=$save_ccache" >> "$GITHUB_OUTPUT"
+fi