ci(molecule): fail the Molecule result when select's output is lost
An empty select output meant "nothing selected", so an output lost on the way from select to result also passed the required check. select now writes `none` for an empty selection; scenarios runs for neither `none` nor an empty output, and result passes a skipped scenarios only for `none`. The result-logic test runs under sh, as act runs a job container's step without a shell, and a new test parses what select writes to GITHUB_OUTPUT. The fork-guard test compares each job with the literal guard. Assisted-by: Claude Code
This commit is contained in:
1 parent
2d1f142662
commit
479efe1ddc
3 files changed
+61
-23
No files matched your search
@@ -110,19 +110,18 @@ jobs:
|
||||
echo "::notice::no base copy of $sel; running this checkout's copy"
|
||||
fi
|
||||
selected="$(python3 -I "$sel" "$BASE_REF")" || exit 1
|
||||
# One directory per line. A random delimiter, so no line of the list can end the value;
|
||||
# an empty selection writes no line, so the output is the empty string.
|
||||
# `none` marks an empty selection, so a lost or empty output fails result, never passes.
|
||||
if [ -z "$selected" ]; then selected=none; fi
|
||||
# One directory per line; a random delimiter, so no line of the list can end the value.
|
||||
delim="scenarios-$(od -An -N16 -tx1 /dev/urandom | tr -d ' \n')"
|
||||
{
|
||||
echo "scenarios<<$delim"
|
||||
if [ -n "$selected" ]; then printf '%s\n' "$selected"; fi
|
||||
echo "$delim"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
printf 'scenarios<<%s\n%s\n%s\n' "$delim" "$selected" "$delim" >> "$GITHUB_OUTPUT"
|
||||
|
||||
scenarios:
|
||||
needs: select
|
||||
# Skipped, not failed, when select fails or selects nothing; result tells the two apart.
|
||||
# Skipped, not failed, when select fails, selects nothing (`none`) or loses its output (empty);
|
||||
# result passes only the second.
|
||||
if: >-
|
||||
needs.select.outputs.scenarios != 'none' &&
|
||||
needs.select.outputs.scenarios != '' &&
|
||||
github.repository == 'mortis/kamino' &&
|
||||
(github.event_name != 'pull_request' ||
|
||||
@@ -248,7 +247,7 @@ jobs:
|
||||
github.event.pull_request.head.repo.full_name == github.repository)
|
||||
runs-on: kamino-docker
|
||||
timeout-minutes: 5
|
||||
# Any small image does; the controller pin is reused so there is no other pin to bump.
|
||||
# The controller pin again, so this job adds no pin of its own to bump.
|
||||
container:
|
||||
image: git.rkdr.net/mortis/molecule-controller:0.1.1@sha256:94af071ecae858016f9a61afa6e45f8344f8fef7d22d1fe899e05f5f48f756e8
|
||||
steps:
|
||||
@@ -261,8 +260,8 @@ jobs:
|
||||
if [ "$SELECT_RESULT" != success ]; then
|
||||
echo "::error::select ended as $SELECT_RESULT"; exit 1
|
||||
fi
|
||||
# A skip is a pass only for an empty selection: a cancelled or failed run is not.
|
||||
if [ "$SCENARIOS_RESULT" = skipped ] && [ -z "$SELECTED" ]; then
|
||||
# A skip is a pass only for select's `none`: an empty output means it was lost.
|
||||
if [ "$SCENARIOS_RESULT" = skipped ] && [ "$SELECTED" = none ]; then
|
||||
echo "No scenario selected."
|
||||
elif [ "$SCENARIOS_RESULT" != success ]; then
|
||||
echo "::error::scenarios ended as $SCENARIOS_RESULT"; exit 1
|
||||
|
||||
Reference in new issue
Block a user