diff --git a/.github/workflows/actions.lock b/.github/workflows/actions.lock index 24f2fcd..2b2591d 100644 --- a/.github/workflows/actions.lock +++ b/.github/workflows/actions.lock @@ -6,9 +6,9 @@ workflows: '.github/workflows/build-notification.yml': - 'actions/checkout@v7.0.1' '.github/workflows/ci-gate-tamper-guard-caller.yml': - - 'hyperpolymath/proven-cicd-and-workflows@4e9e680b0dfd842a457cf23271f9e005a88f766c' + - 'hyperpolymath/proven-cicd-and-workflows@a0760cea695a815a96b3944f3d03ee015da856d0' '.github/workflows/ci-gate.yml': - - 'hyperpolymath/proven-cicd-and-workflows@4e9e680b0dfd842a457cf23271f9e005a88f766c' + - 'hyperpolymath/proven-cicd-and-workflows@a0760cea695a815a96b3944f3d03ee015da856d0' '.github/workflows/codeql.yml': - 'actions/checkout@v7.0.1' - 'github/codeql-action@9b3254085494b55a0f7c4c2b3d2d52cc712ce370' @@ -198,9 +198,9 @@ dependencies: commit: 'sha1-0f8e8c99d88aeb3fbfd523f1ef2c6f762d10d64d' owner_id: 75048950 repo_id: 623796603 - 'hyperpolymath/proven-cicd-and-workflows@4e9e680b0dfd842a457cf23271f9e005a88f766c': + 'hyperpolymath/proven-cicd-and-workflows@a0760cea695a815a96b3944f3d03ee015da856d0': ref: 'main' - commit: 'sha1-4e9e680b0dfd842a457cf23271f9e005a88f766c' + commit: 'sha1-a0760cea695a815a96b3944f3d03ee015da856d0' owner_id: 6759885 repo_id: 1326697643 'hyperpolymath/smtp-notify-action@v0.5.1': diff --git a/.github/workflows/ci-gate-tamper-guard-caller.yml b/.github/workflows/ci-gate-tamper-guard-caller.yml index 2b46979..fa527ab 100644 --- a/.github/workflows/ci-gate-tamper-guard-caller.yml +++ b/.github/workflows/ci-gate-tamper-guard-caller.yml @@ -17,4 +17,4 @@ permissions: jobs: guard: - uses: hyperpolymath/proven-cicd-and-workflows/.github/workflows/ci-gate-tamper-guard.yml@4e9e680b0dfd842a457cf23271f9e005a88f766c # cicd-suite tamper guard + uses: hyperpolymath/proven-cicd-and-workflows/.github/workflows/ci-gate-tamper-guard.yml@a0760cea695a815a96b3944f3d03ee015da856d0 # cicd-suite tamper guard diff --git a/.github/workflows/ci-gate.yml b/.github/workflows/ci-gate.yml index 7abe988..656a0f2 100644 --- a/.github/workflows/ci-gate.yml +++ b/.github/workflows/ci-gate.yml @@ -68,7 +68,7 @@ permissions: jobs: gate: if: github.event_name != 'pull_request' && (github.event_name != 'workflow_run' || github.event.workflow_run.name != 'CI gate') - uses: hyperpolymath/proven-cicd-and-workflows/.github/workflows/ci-gate.yml@4e9e680b0dfd842a457cf23271f9e005a88f766c # cicd-suite ci-gate + uses: hyperpolymath/proven-cicd-and-workflows/.github/workflows/ci-gate.yml@a0760cea695a815a96b3944f3d03ee015da856d0 # cicd-suite ci-gate with: context: "CI/gate" # timeout_minutes: 180 # how long a missing check keeps the gate pending @@ -83,6 +83,6 @@ jobs: # the default branch) fails a pull request that touches gate files unless the owner has approved it. gate-pr: if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository - uses: hyperpolymath/proven-cicd-and-workflows/.github/workflows/ci-gate.yml@4e9e680b0dfd842a457cf23271f9e005a88f766c # cicd-suite ci-gate + uses: hyperpolymath/proven-cicd-and-workflows/.github/workflows/ci-gate.yml@a0760cea695a815a96b3944f3d03ee015da856d0 # cicd-suite ci-gate with: context: "CI/gate" diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index cc3c54a..6c34f17 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -149,8 +149,8 @@ `pull_request_target`: a pull request that touches a gate file fails `guard / check` until the owner applies the label `gate-change-approved`. The guard is not a required context yet. Both callers pin - hyperpolymath/proven-cicd-and-workflows at `4e9e680b0dfd842a457cf23271f9e005a88f766c`, - the squash commit of hyperpolymath/proven-cicd-and-workflows#139 on its `main`; + hyperpolymath/proven-cicd-and-workflows at `a0760cea695a815a96b3944f3d03ee015da856d0`, + a commit on the suite's `main` (hyperpolymath/proven-cicd-and-workflows#164: emoji-safe status descriptions, retry with back-off on API rate limits, a per-commit concurrency group, a sweep that stops when limited); `actions.lock` is edited by hand to match (`gh actions-lock` v0.2.0 cannot lock cross-repository reusable workflows) and `scripts/check-lock-sync.sh` is the authority. `tests/workflows/squabble_gate_test.sh` section 5b asserts the new diff --git a/scripts/check-required-contexts.sh b/scripts/check-required-contexts.sh index 0a52d5c..41ffe16 100644 --- a/scripts/check-required-contexts.sh +++ b/scripts/check-required-contexts.sh @@ -157,6 +157,12 @@ function localTargetError(uses, fullWf) { : onBlock && typeof onBlock === "object" ? "workflow_call" in onBlock : false; if (!callable) return `'${uses}' does not declare on.workflow_call, so GitHub cannot run it as a reusable workflow`; + // The caller passes with.context, and GitHub refuses an input the called workflow does not + // declare, so the target must declare on.workflow_call.inputs.context as a string input. + const call = onBlock && typeof onBlock === "object" && !Array.isArray(onBlock) ? onBlock.workflow_call : undefined; + const ctxInput = call && typeof call === "object" ? call.inputs?.context : undefined; + if (!ctxInput || typeof ctxInput !== "object" || ctxInput.type !== "string") + return `'${uses}' does not declare on.workflow_call.inputs.context with type: string, so GitHub refuses the caller's with.context`; return null; } diff --git a/tests/workflows/actions_lock_sha_refs_test.sh b/tests/workflows/actions_lock_sha_refs_test.sh index 7f9d98c..5e6d22b 100755 --- a/tests/workflows/actions_lock_sha_refs_test.sh +++ b/tests/workflows/actions_lock_sha_refs_test.sh @@ -188,7 +188,7 @@ actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9|v7.0.2|44036562 dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98|v3.1.0|27347476|371068214|- editorconfig-checker/action-editorconfig-checker@51f63319f592f97930c73d9c46184d20bd206393|v3.0.0|26415196|297874902|- erlef/setup-beam@54075bcc5e249e4758d363f27d099f55d843f124|v1.24.1|47606891|331103973|- -hyperpolymath/proven-cicd-and-workflows@4e9e680b0dfd842a457cf23271f9e005a88f766c|main|6759885|1326697643|- +hyperpolymath/proven-cicd-and-workflows@a0760cea695a815a96b3944f3d03ee015da856d0|main|6759885|1326697643|- github/codeql-action@9b3254085494b55a0f7c4c2b3d2d52cc712ce370|v4.39.1|9919|259445878|- ossf/scorecard-action@fa7117db83c52d787ae5a89f350999701505d78e|v2.5.0|67707773|421101922|- oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6|v2.2.0|108928776|512644635|- diff --git a/tests/workflows/squabble_gate_test.sh b/tests/workflows/squabble_gate_test.sh index c75d0d4..59b2827 100644 --- a/tests/workflows/squabble_gate_test.sh +++ b/tests/workflows/squabble_gate_test.sh @@ -311,7 +311,7 @@ assert_rc 2 'missing workflow directory is setup failure' bash "$REPO_ROOT/scrip echo "=== 5b. Typed status mapping: a workflow_run commit-status publisher ===" # `CI/gate => status:` is certified as a publisher, never as a job name. SUITE_REUSABLE='hyperpolymath/proven-cicd-and-workflows/.github/workflows/ci-gate.yml' -SUITE_PIN='4e9e680b0dfd842a457cf23271f9e005a88f766c' +SUITE_PIN='a0760cea695a815a96b3944f3d03ee015da856d0' status_tree="$WORK/status-publisher" fresh_status() { # fresh_status [uses] [context] [on-block] local uses="${1:-$SUITE_REUSABLE@$SUITE_PIN}" ctx="${2:-CI/gate}" @@ -343,12 +343,27 @@ fresh_local() { # fresh_local fi } LOCAL_TARGET='./.github/workflows/ci-gate.yml' +GOOD_CALL=$'on:\n workflow_call:\n inputs:\n context: {type: string}' +fresh_local "$LOCAL_TARGET" "$GOOD_CALL" +assert_rc 0 'status mapping: a separate caller whose local target declares workflow_call with a string context input passes' check_status +fresh_local "$LOCAL_TARGET" $'on:\n workflow_call:\n inputs:\n context: {type: string, required: true}\n workflow_dispatch:' +assert_rc 0 'status mapping: a required string context input beside another trigger passes' check_status +# The caller passes with.context; GitHub refuses an input the called workflow does not declare. fresh_local "$LOCAL_TARGET" $'on:\n workflow_call:' -assert_rc 0 'status mapping: a separate caller whose local target declares workflow_call passes' check_status -fresh_local "$LOCAL_TARGET" $'on:\n workflow_call:\n inputs:\n context: {type: string}' -assert_rc 0 'status mapping: a local target with workflow_call inputs passes' check_status +assert_rc 1 'status mapping: a local target whose workflow_call declares no inputs fails' check_status +fresh_local "$LOCAL_TARGET" $'on:\n workflow_call:' +check_status >"$WORK/status-msg" 2>&1 || true +assert_rc 0 'status mapping message: names the missing context input' grep -qF 'inputs.context with type: string' "$WORK/status-msg" fresh_local "$LOCAL_TARGET" 'on: [workflow_call]' -assert_rc 0 'status mapping: a local target with a workflow_call list passes' check_status +assert_rc 1 'status mapping: a workflow_call list (which cannot declare inputs) fails' check_status +fresh_local "$LOCAL_TARGET" 'on: workflow_call' +assert_rc 1 'status mapping: a bare workflow_call string (which cannot declare inputs) fails' check_status +fresh_local "$LOCAL_TARGET" $'on:\n workflow_call:\n inputs:\n other: {type: string}' +assert_rc 1 'status mapping: inputs without context fails' check_status +fresh_local "$LOCAL_TARGET" $'on:\n workflow_call:\n inputs:\n context: {type: number}' +assert_rc 1 'status mapping: a non-string context input fails' check_status +fresh_local "$LOCAL_TARGET" $'on:\n workflow_call:\n inputs:\n context:' +assert_rc 1 'status mapping: a context input with no type fails' check_status fresh_local "$LOCAL_TARGET" $'on:\n push:' assert_rc 1 'status mapping: a local target without workflow_call fails' check_status fresh_local "$LOCAL_TARGET" $'on:\n push:' @@ -359,14 +374,14 @@ assert_rc 1 'status mapping: a missing local target file fails' check_status fresh_local "$LOCAL_TARGET" - check_status >"$WORK/status-msg" 2>&1 || true assert_rc 0 'status mapping message: names the missing target file' grep -qF 'names a file that does not exist' "$WORK/status-msg" -fresh_local './.github/workflows/../workflows/ci-gate.yml' $'on:\n workflow_call:' +fresh_local './.github/workflows/../workflows/ci-gate.yml' "$GOOD_CALL" assert_rc 1 'status mapping: a local target path with .. fails even though the file exists' check_status -fresh_local './.github/workflows/../workflows/ci-gate.yml' $'on:\n workflow_call:' +fresh_local './.github/workflows/../workflows/ci-gate.yml' "$GOOD_CALL" check_status >"$WORK/status-msg" 2>&1 || true assert_rc 0 'status mapping message: names the path traversal' grep -qF "contains '..' path traversal" "$WORK/status-msg" -fresh_local '/etc/ci-gate.yml' $'on:\n workflow_call:' +fresh_local '/etc/ci-gate.yml' "$GOOD_CALL" assert_rc 1 'status mapping: an absolute local target fails' check_status -fresh_local "$LOCAL_TARGET" $'on:\n workflow_call:' +fresh_local "$LOCAL_TARGET" "$GOOD_CALL" sed -i 's|^ uses: .*| uses: ./.github/workflows/ci-gate.yml|' "$status_tree/.github/workflows/gate-caller.yml" printf ' other:\n uses: ./../outside/ci-gate.yml\n with: {context: "CI/gate"}\n' >> "$status_tree/.github/workflows/gate-caller.yml" assert_rc 1 'status mapping: a second, bad local job fails beside a valid local job' check_status