Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/actions.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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':
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-gate-tamper-guard-caller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/ci-gate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
4 changes: 2 additions & 2 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions scripts/check-required-contexts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/workflows/actions_lock_sha_refs_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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|-
Expand Down
33 changes: 24 additions & 9 deletions tests/workflows/squabble_gate_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:<file>` 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}"
Expand Down Expand Up @@ -343,12 +343,27 @@ fresh_local() { # fresh_local <uses> <target on-block, or - for no target file>
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:'
Expand All @@ -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
Expand Down