Skip to content

feat: add unit tests and documentation#18

Merged
jonryser merged 5 commits intomainfrom
feature/tests-and-documentation
Mar 12, 2026
Merged

feat: add unit tests and documentation#18
jonryser merged 5 commits intomainfrom
feature/tests-and-documentation

Conversation

@genui-scotty
Copy link
Contributor

@genui-scotty genui-scotty bot commented Mar 12, 2026

Summary

Adds 60 bats unit tests and a documentation/ folder covering all 10 actions in this repo.


Tests (tests/)

Uses bats-core to unit test the bash scripts that power the actions. All 60 tests pass.

File Tests What's covered
options_helpers.bats 15 has_argument() and extract_argument() parsing logic
aws_unset.bats 7 All 4 AWS credential env vars are cleared; no-op when already unset
configure_pip.bats 10 Correct pip config set calls per env var; no-op when unset; --help
promote_image.bats 13 Every required env var validation (exits 1 for each missing var); --help
update_ecs.bats 8 --help, aws ecs update-service invocation, --force-new-deployment, failure path
update_lambda.bats 7 --help, aws lambda update-function-code invocation, failure path

Strategy: External commands (aws, pip, tput) are replaced with lightweight mock binaries that record every call to a log file. Tests assert the correct arguments were passed without hitting real cloud APIs.

CI workflow

.github/workflows/test-shell-scripts.yml runs the full suite on every push/PR touching tests/ or any .sh file under .github/actions/.


Documentation (documentation/)

Full reference docs for all 10 actions — inputs, outputs, usage examples, how-it-works descriptions, required IAM permissions, and dependency notes.

  • documentation/README.md — index with summary table
  • documentation/actions/configure-aws.md
  • documentation/actions/job-info.md (includes branch→env and tag→env mapping tables)
  • documentation/actions/lint-sql.md
  • documentation/actions/lint-terraform.md
  • documentation/actions/lint-test-yarn.md
  • documentation/actions/promote-ecr-image.md (same-account vs cross-account flows)
  • documentation/actions/test-python.md
  • documentation/actions/update-aws-ecs.md
  • documentation/actions/update-aws-lambda.md
  • documentation/actions/validate-terraform.md

What can't be unit tested

The composite action .yml files use GitHub Actions expression syntax (${{ inputs.xxx }}) that only resolves inside an actual runner. Testing those requires integration tests running in GitHub Actions itself — that's a natural next step if desired.

genui-scotty bot added 5 commits March 11, 2026 18:56
- Add 60 bats unit tests covering all testable shell scripts:
  - options_helpers.sh (has_argument, extract_argument)
  - aws_unset.sh (clears all 4 AWS credential env vars)
  - configure_pip.sh (pip config calls for each env var)
  - promote_image.sh (all 11 required env var validations)
  - update_ecs.sh (--help, AWS CLI invocation, failure path)
  - update_lambda.sh (--help, AWS CLI invocation, failure path)
- Add mock helpers for aws, pip, docker, tput
- Add .github/workflows/test-shell-scripts.yml CI workflow
- Add documentation/ folder with full reference docs for all 10 actions

All 60 tests pass locally.
- Remove redundant action docs (each action already has its own README.md)
- Move LINTING.md → documentation/LINTING.md
- Add documentation/TESTING.md with full testing guide
- Update README.md links to point to new paths
- tests/README.md: add language specifier to fenced code block (MD040)
- tests/README.md: wrap long lines to stay within 180-char limit (MD013)
- test-shell-scripts.yml: use sudo for npm install -g on Ubuntu runner (EACCES)
…ity.yml

- Move flat tests/unit/*.bats into per-action subdirectories (tests/unit/<action-name>/)
  mirroring the mono-repo structure of the actions themselves
- Update BATS_TEST_DIRNAME depth from ../.. to ../../.. in all test files
- Delete .github/workflows/test-shell-scripts.yml
- Rewrite code-quality.yml with two jobs:
  - lint-markdown: runs markdownlint when .md files change (unchanged behaviour)
  - bats-tests: matrix job using tj-actions/changed-files to run tests only for
    the specific action(s) that changed, each in an isolated job
- Update tests/README.md and documentation/TESTING.md to reflect new structure
…steps

Replaces the detect-changes + lint-markdown + bats-tests (matrix) pattern with
a single 'quality' job. Per-action test steps use tj-actions/changed-files output
with contains() checks rather than a matrix — sequential execution in one runner
is more efficient for fast-running bats suites where job startup overhead
outweighs any parallelism benefit.
@jonryser jonryser merged commit b97460f into main Mar 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant