Unit tests for the shell scripts that power the GitHub Actions in this repository.
Tests are written using bats-core — the Bash Automated Testing System.
Tests are organised per-action, mirroring the mono-repo structure of the actions themselves.
Each action that contains testable shell scripts has a corresponding directory under tests/unit/.
tests/
├── unit/
│ ├── promote-ecr-image/
│ │ ├── test_aws_unset.bats # Tests for the shared aws_unset.sh utility
│ │ ├── test_options_helpers.bats # Tests for the shared options_helpers.sh utility
│ │ └── test_promote_image.bats # Tests for promote_image.sh
│ ├── test-python/
│ │ └── test_configure_pip.bats # Tests for configure_pip.sh
│ ├── update-aws-ecs/
│ │ └── test_update_ecs.bats # Tests for update_ecs.sh
│ └── update-aws-lambda/
│ └── test_update_lambda.bats # Tests for update_lambda.sh
└── helpers/
└── mock_helpers.bash # Shared mock creation and assertion utilities
| Action | Script | Tests |
|---|---|---|
promote-ecr-image |
options_helpers.sh |
has_argument() and extract_argument() parsing logic |
promote-ecr-image |
aws_unset.sh |
All four AWS credential env vars are cleared |
promote-ecr-image |
promote_image.sh |
Env var validation (exits 1 for each missing required var) |
test-python |
configure_pip.sh |
Correct pip config set calls for each env var; no-op when unset |
update-aws-ecs |
update_ecs.sh |
AWS CLI invocation, --force-new-deployment, empty-response failure |
update-aws-lambda |
update_lambda.sh |
AWS CLI invocation, function name + image URL propagation, failure |
- Composite action YAML — action
.ymlfiles use GitHub Actions expression syntax (${{ inputs.xxx }}) that cannot run outside of a GitHub Actions runner. - Live AWS calls — tests that require actual AWS credentials are integration tests and must run in a real CI environment with OIDC or stored secrets.
# via npm (recommended)
npm install -g bats
# via Homebrew
brew install bats-core# From the repo root
bats tests/unit/update-aws-ecs/for dir in tests/unit/*/; do bats --verbose-run "$dir"; donebats --verbose-run tests/unit/promote-ecr-image/- Create
tests/unit/<action-name>/test_<script_name>.bats - Set
REPO_ROOTrelative toBATS_TEST_DIRNAME— tests are three levels deep, so use:REPO_ROOT="$(cd "$BATS_TEST_DIRNAME/../../.." && pwd)" - Mock external commands (
aws,docker,pip) usingMOCK_DIRin PATH - Use
run bash -c "..."for tests that expectexit 1from the script under test
See existing test files and tests/helpers/mock_helpers.bash for patterns.