Skip to content

test(bats): add detect-changes image_flavors tests; wire bats into CI#259

Merged
castrojo merged 8 commits into
mainfrom
fix/coverage-quality
Jun 22, 2026
Merged

test(bats): add detect-changes image_flavors tests; wire bats into CI#259
castrojo merged 8 commits into
mainfrom
fix/coverage-quality

Conversation

@castrojo

Copy link
Copy Markdown
Contributor

Closes #224. Also closes #205 (already fixed by PR #217bootc-build/chunka added to --cov paths; inject-xattrs.py now at 97%).

Changes

tests/bats/test_detect_changes.bats (new, 8 tests)
Tests the image_flavors computation shell snippet from detect-changes/action.yml:

  • nvidia_changed=false["main"]
  • nvidia_changed=true["main","nvidia"]
  • Empty / uppercase NVIDIA_CHANGED edge cases
  • GITHUB_OUTPUT format correctness (key=value, single line)

.github/workflows/unit-tests.yml

  • Add bats job — the full bats suite was never wired into CI; 89 tests were running locally-only
  • 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 to existing entries
  • Fix bats job description (job now actually exists in CI)

Verification

All 89 bats tests pass locally:

bats tests/bats/   # 1..89, all ok

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

@castrojo castrojo requested a review from p5 as a code owner June 18, 2026 14:08
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions github-actions Bot added the pr/needs-review Awaiting human review label Jun 18, 2026

@hanthor hanthor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Jorge Castro and others added 2 commits June 21, 2026 22:43
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>
@castrojo castrojo force-pushed the fix/coverage-quality branch from 87eceaf to 3dfec31 Compare June 22, 2026 02:43
Jorge Castro and others added 6 commits June 21, 2026 22:54
…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>
@castrojo castrojo merged commit fc0df6f into main Jun 22, 2026
7 checks passed
@castrojo castrojo deleted the fix/coverage-quality branch June 22, 2026 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr/needs-review Awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] Add unit test for detect-changes image_flavors computation [quality] inject-xattrs.py excluded from coverage reporting

2 participants