diff options
| author | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
|---|---|---|
| committer | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
| commit | c25cbdf6fb6d946175f4335fab77bfea601b56db (patch) | |
| tree | 6f7a94b7b81f999e434f61b73d47e337dfd26bf2 /.github/scripts/select-linux-ccache-save.sh | |
| parent | 71f5689252c9f13e70e1c24856904475b2307809 (diff) | |
| parent | 0685fcada9f95fe90f70b387cd7d757da8209624 (diff) | |
Merge tag 'debian/3.2.0_rc1+dfsg-2' into debian/trixie-backportsdebian/trixie-backports
tagging wsjtx 3.2.0~rc1+dfsg-2
Diffstat (limited to '.github/scripts/select-linux-ccache-save.sh')
| -rwxr-xr-x | .github/scripts/select-linux-ccache-save.sh | 70 |
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 |
