Skip to content
Closed
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
11 changes: 11 additions & 0 deletions .github/workflows/_probe-empty-stack-command.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: _probe-empty-stack-command
on:
pull_request:
branches: [main]
jobs:
probe:
uses: ./.github/workflows/stack-tests.yml
with:
gate-name: probe
compose-file: probe-compose.yaml
stack-command: ""
11 changes: 11 additions & 0 deletions .github/workflows/stack-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ jobs:
shell: bash
run: ${{ inputs.ready-command }}

- name: Reject an empty stack-command
shell: bash
env:
STACK_COMMAND: ${{ inputs.stack-command }}
run: |
set -euo pipefail
if [[ -z "${STACK_COMMAND// /}" ]]; then
echo "::error::stack-command must not be empty or blank -- an empty run: step succeeds having run no ${{ inputs.gate-name }} gate (FR-017: a gate must fail visibly, never pass silently)"
exit 1
fi

- name: Run ${{ inputs.gate-name }} gate
shell: bash
run: ${{ inputs.stack-command }}
Expand Down
3 changes: 3 additions & 0 deletions probe-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
services:
redis:
image: redis:7-alpine
22 changes: 22 additions & 0 deletions tests/workflows/stack-tests-contract.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Contract test for the reusable stack-tests workflow (gitops spec 007 T027).
# Same grep-the-contract style as tests/workflows/reusable-workflow-contract.bats.
# stack-command is required: true with no default, exactly like ci.yml's
# test-command was before gitops spec 003 T024 found it could be silently
# satisfied by an empty string -- this guards the same failure mode here.
set -euo pipefail

root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
stack_tests="$root/.github/workflows/stack-tests.yml"

fail() { echo "stack-tests-contract: $*" >&2; exit 1; }
have() { grep -Fq -- "$2" "$1" || fail "$3"; }

[[ -f "$stack_tests" ]] || fail "missing required file: $stack_tests"

have "$stack_tests" "workflow_call" "stack-tests.yml must be a reusable workflow"
have "$stack_tests" "stack-command:" "stack-tests.yml must take a required stack-command gate"
have "$stack_tests" "stack-command must not be empty or blank" \
"stack-tests.yml must fail visibly on an empty stack-command, never pass having run no gate (FR-017, gitops spec 007 T027)"

echo "stack-tests-contract: OK -- stack-tests.yml is a reusable workflow that fails visibly on an empty stack-command."
Loading