Skip to content

Commit 454ef3d

Browse files
locus313Copilot
andcommitted
docs: add bats test suite documentation to README.md
- Add Unit Tests subsection after Pre-commit Hooks: install instructions for macOS/Ubuntu, bats tests/ run command, test-file table, note that CI runs bats on every PR - Update Contributing checklist: add 'add test section to test_script_validation.bats' to step 3, add step 6 'bats tests/' before the test-on-non-prod-org step Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9e34f1a commit 454ef3d

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,28 @@ brew install gitleaks shellcheck
112112
> [!TIP]
113113
> To bypass the hooks in an emergency: `git commit --no-verify`. Use sparingly — the hooks exist to prevent secrets from reaching the remote.
114114
115+
### Unit Tests
116+
117+
The repository includes a [bats](https://github.com/bats-core/bats-core) unit-test suite in `tests/`. Install bats and run the full suite:
118+
119+
```bash
120+
# macOS
121+
brew install bats-core
122+
123+
# Ubuntu / Debian
124+
sudo apt-get install -y bats
125+
126+
# Run all tests
127+
bats tests/
128+
```
129+
130+
| File | What it covers |
131+
|------|----------------|
132+
| `tests/test_common.bats` | `lib/github-common.sh` functions (`validate_slug`, `require_env_var`, `gh_api` sentinels, `gh_api_paginate`, etc.) |
133+
| `tests/test_script_validation.bats` | Every script — missing required env vars, invalid CLI args, `--help`, and script-specific guards |
134+
135+
CI runs `bats tests/` on every pull request alongside shellcheck.
136+
115137
## Scripts
116138

117139
Each script is a self-contained utility designed for a specific task. Navigate to the script's directory, set the required environment variables, and execute.
@@ -1159,8 +1181,10 @@ Contributions are welcome! Please follow these steps:
11591181
- Start with the `# ===` header and `set -euo pipefail`
11601182
- Source `lib/github-common.sh` and validate all inputs
11611183
- Create `action.yml` in the same directory (see existing actions for the pattern)
1184+
- Add a test section for the new script in `tests/test_script_validation.bats`
11621185
4. **Update README.md** with the env var table, usage example, and a row in the Available Actions table
11631186
5. **Run shellcheck:** `shellcheck --severity=warning --exclude=SC2034,SC1091 --shell=bash your-script.sh`
1164-
6. **Test on a non-production org** before submitting
1187+
6. **Run the test suite:** `bats tests/`
1188+
7. **Test on a non-production org** before submitting
11651189
7. **Commit using [Conventional Commits](https://www.conventionalcommits.org/)** — `CHANGELOG.md` is auto-generated from commit messages; do not edit it manually
11661190
8. **Open a PR** — the PR template will guide you through the checklist

0 commit comments

Comments
 (0)