test(bats): add detect-changes image_flavors tests; wire bats into CI#259
Merged
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
hanthor
suggested changes
Jun 21, 2026
hanthor
left a comment
Member
There was a problem hiding this comment.
bats CI job fails with npm EACCES: permission denied, mkdir '/usr/local/share/man/man7'. Fix: change npm install -g bats to sudo npm install -g bats in unit-tests.yml. Tests themselves are well-structured.
castrojo
added a commit
that referenced
this pull request
Jun 22, 2026
* test(bats): add push-image retry and sign-and-publish validation tests Closes #230, #231. push-image (test_push_image.bats, 16 tests): - Registry path lowercasing - Default tag selection (first tag / explicit override) - Empty TAGS guard → error exit - Successful push: digest captured from skopeo inspect, written to GITHUB_OUTPUT; buildah called with --authfile - Retry: skopeo returns null digest on first attempt, succeeds on second - Exhausted retries (MAX_ATTEMPTS): exits nonzero with ::error:: - Alias copy: skopeo copy called for each non-default tag; not called for the default tag itself; no copy when single tag - FORCE_COMPRESSION flag: present when true, absent when false sign-and-publish (test_sign_and_publish.bats, 12 tests): - Keyless: ACTIONS_ID_TOKEN_REQUEST_URL set → passes - Keyless: unset or empty → exits 1 with ::error:: citing id-token:write - Key: COSIGN_PRIVATE_KEY non-empty → passes - Key: empty or unset → exits 1 with ::error:: citing signing-key - Interaction: each snippet is independent of the other's env vars All 109 bats tests pass locally. docs(skills): register new test files in testing.md (also catches up testing.md from main with resolve_digests/verify_signatures counts, release_gate entry, and bats CI job note from pending PR #259). Assisted-by: Claude Sonnet 4.5 via pi Co-authored-by: pi <pi@earendil.works> * docs: add inline-YAML bats pattern, bats routing in SKILL.md, IMPROVEMENTS.md End-session skill-loop updates: - testing.md: new section 'Testing shell logic embedded in action YAML' captures the inline-snippet pattern used for push-image and sign-and-publish tests this session — including the pass-through sudo mock, bash -c invocation, and single-quote escaping pitfall. - SKILL.md: add two bats routing entries ('Add bats tests for a shell script or inline action shell step', 'Wire a new bats test into CI'). - docs/factory/IMPROVEMENTS.md: create file; log the three PRs and five closed issues from this session. Assisted-by: Claude Sonnet 4.5 via pi Co-authored-by: pi <pi@earendil.works> --------- Co-authored-by: Jorge Castro <jorge@castrojo.com> Co-authored-by: pi <pi@earendil.works>
Closes #224. - tests/bats/test_detect_changes.bats: 8 tests covering both branches of the image_flavors computation (nvidia/main, main-only, edge cases for empty and uppercase NVIDIA_CHANGED, GITHUB_OUTPUT format). - .github/workflows/unit-tests.yml: add bats job so the full bats suite runs in CI on every PR. Also add bootc-build/detect-changes/** to trigger paths. - docs/skills/testing.md: register test_detect_changes.bats and test_release_gate.bats; add test counts; fix bats job description. Assisted-by: Claude Sonnet 4.5 via pi Co-authored-by: pi <pi@earendil.works>
npm global install requires elevated permissions on GitHub-hosted runners. Without sudo, the job fails with: EACCES: permission denied, mkdir '/usr/local/share/man/man7' Assisted-by: Claude Sonnet 4.6 via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
87eceaf to
3dfec31
Compare
…nshot slug assertions
Bats 1.11.1 (npm-installed on GitHub runners) does not reliably set
BATS_TEST_DIRNAME at file scope (outside setup/test/teardown), causing
all tests in affected bats files to exit with status 127. Bats 1.13.0
(homebrew) sets it at file scope, hiding the issue locally.
Fix: move SCRIPT/RESOLVE_SCRIPT/VERIFY_SCRIPT declarations into setup()
where BATS_TEST_DIRNAME is guaranteed to be set in all bats versions.
Also update _screenshot_slug() assertions: the function was updated to
always return '{slug}-testing' (screenshots are captured against the
:testing image during e2e gate regardless of the tag being released).
Tests previously expected the old slugs ('bluefin', 'bluefin-stable').
Assisted-by: Claude Sonnet 4.6 via GitHub Copilot
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Assisted-by: Claude Sonnet 4.6 via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Assisted-by: Claude Sonnet 4.6 via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Assisted-by: Claude Sonnet 4.6 via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ns/ pattern) The actions/ directory is listed in .gitignore to prevent accidental worktree commits. action.yml files are tracked via git add -f but check_token_health.sh was never force-added, causing CI to fail with 'No such file or directory' when running bats tests. Assisted-by: Claude Sonnet 4.6 via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…on-failure Assisted-by: Claude Sonnet 4.6 via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #224. Also closes #205 (already fixed by PR #217 —
bootc-build/chunkaadded to--covpaths; inject-xattrs.py now at 97%).Changes
tests/bats/test_detect_changes.bats(new, 8 tests)Tests the
image_flavorscomputation shell snippet fromdetect-changes/action.yml:nvidia_changed=false→["main"]nvidia_changed=true→["main","nvidia"]GITHUB_OUTPUTformat correctness (key=value, single line).github/workflows/unit-tests.ymlbatsjob — the full bats suite was never wired into CI; 89 tests were running locally-onlybootc-build/detect-changes/**to trigger pathsdocs/skills/testing.mdtest_detect_changes.batsandtest_release_gate.batsVerification
All 89 bats tests pass locally:
Consumer validation
Consumer PR: N/A — test and docs-only, no action.yml or reusable workflow behavior changed
Consumer CI run: N/A — test and docs-only, no action.yml or reusable workflow behavior changed
Out-of-org consumer impact: N/A — no behavior change