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:28 +0200
committerChristoph Berg <myon@debian.org>2026-09-26 23:24:28 +0200
commit69344560ea394c06ca94acac46a2e4c3e8b7b229 (patch)
treeebc98370a697a9bbd6b973a14fa5113c475c6db7 /.github/scripts/select-linux-ccache-save.sh
parent3e9d10a67671d0bd5c7b8c3ca8088f1818322eff (diff)
parent059831534c7e884f0a607ed86b582fd00d821731 (diff)
Update upstream source from tag 'upstream/3.2.0_rc1+dfsg'
Update to upstream version '3.2.0~rc1+dfsg' with Debian dir dbff457fd2c3616d5c77b863c7bfb2186ed86047
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