Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Tests

# Runs every bats suite listed under "Running Tests" in docs/development.md.
# The guard job always runs tests/ci-workflow.bats; the bats job runs every
# other suite from its matrix. Adding a suite means adding it to both that
# list and the matrix below; tests/ci-workflow.bats fails when they differ.
# That suite also requires this file to match EXPECTED in
# tests/ci-workflow-check.py, apart from the suite list and the action commit
# SHAs. Any other change to this file needs the same change there.

on:
# No branch filter: pull requests into any base branch run the suites.
pull_request:
push:
branches: [main]

permissions:
contents: read

# Runs for one pull request share a group, so a new commit cancels the
# superseded run. Each push to main gets its own group, keyed by run ID: in a
# shared group, a later push would cancel a push run still waiting in the queue.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
Comment thread
prometheas marked this conversation as resolved.
Resolved
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
# A fixed job rather than a matrix entry, so a change to the matrix cannot
# drop the check that compares the matrix with the docs.
guard:
name: bats tests/ci-workflow.bats
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: cachix/install-nix-action@382a9ed9481c7c1f94f68b72ef105b3417c73877 # v32.1.0
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Run suite
run: nix develop -c bats tests/ci-workflow.bats

bats:
name: bats ${{ matrix.suite }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
suite:
- tests/marketplace-package.bats
- plugins/product-development/tests/plugin-package.bats
- plugins/product-development/skills/product-development/tests/init.bats
- plugins/delivery-engineering/tests/plugin-package.bats
- plugins/okf-bundle/tests/plugin-package.bats
- plugins/branch-guard/tests
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: cachix/install-nix-action@382a9ed9481c7c1f94f68b72ef105b3417c73877 # v32.1.0
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Run suite
env:
SUITE: ${{ matrix.suite }}
run: nix develop -c bats "$SUITE"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.direnv/

__pycache__/
*.pyc
38 changes: 37 additions & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ should reflect the target project's domain.

```bash
nix develop -c bats tests/marketplace-package.bats
nix develop -c bats tests/ci-workflow.bats
nix develop -c bats plugins/product-development/tests/plugin-package.bats
nix develop -c bats plugins/product-development/skills/product-development/tests/init.bats
nix develop -c bats plugins/delivery-engineering/tests/plugin-package.bats
Expand All @@ -136,6 +137,37 @@ nix develop -c bats plugins/branch-guard/tests
git diff --check
```

### Continuous Integration

`.github/workflows/tests.yml` runs every bats suite above on each pull request,
whatever its base branch, and on each push to `main`. It installs Nix and runs
each suite in its own job with the same `nix develop -c bats <suite>` command,
so CI uses the flake's pinned tool versions and a failing job names its suite.
`git diff --check` runs locally only. A new commit on a pull request cancels
that pull request's running checks; runs for pushes to `main` never cancel or
replace each other.

`tests/ci-workflow.bats` runs in its own `guard` job instead of the matrix, so
an edit to the matrix cannot drop it. When you add a suite, add it to both the
list above and the `suite` matrix in the workflow. `tests/ci-workflow.bats`
fails when the list differs from the guard job's suite plus the matrix, when
this section holds more than one code block, and when the block holds a command
other than `nix develop -c bats <path>` or `git diff --check`. Each suite path
must be a repository-relative `.bats` file, or a directory with `.bats` files
directly inside, and must not start with `-`. Its checks live in
`tests/ci-workflow-check.py`.

The guard also requires the workflow to match `EXPECTED` in
`tests/ci-workflow-check.py` exactly, apart from the suite list and the action
commit SHAs. It compares triggers, concurrency, permissions, the job and its
steps as written instead of interpreting them. Any other change to the
workflow, such as a new trigger setting or step, needs the same change to
`EXPECTED`.

Third-party actions in the workflow are pinned to full commit SHAs, with the
release tag in a trailing comment. To update one, look up the new release's
commit with `gh api repos/<owner>/<action>/commits/<tag> --jq .sha`.

## Repository Structure

```text
Expand All @@ -144,8 +176,12 @@ agent-plugins/
├── .agents/plugins/marketplace.json
├── .claude-plugin/marketplace.json
├── .github/plugin/marketplace.json
├── .github/workflows/tests.yml
├── docs/
├── tests/marketplace-package.bats
├── tests/
│ ├── ci-workflow-check.py
│ ├── ci-workflow.bats
│ └── marketplace-package.bats
└── plugins/
├── product-development/
│ ├── plugin.json
Expand Down
Loading