|
| 1 | +# Design |
| 2 | + |
| 3 | +## Context |
| 4 | + |
| 5 | +See proposal.md - Why. |
| 6 | + |
| 7 | +`.github/workflows/ci.yml` has one job on `ubuntu-latest`: |
| 8 | + |
| 9 | +``` |
| 10 | +Setup bats mig4/setup-bats@v1, bats-version: 1.6.0 |
| 11 | +Check out code actions/checkout@v2 |
| 12 | +Run tests make test, GH_TOC_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 13 | +``` |
| 14 | + |
| 15 | +It runs on `pull_request` and `push` to master, on a schedule twice a week, and by hand |
| 16 | +(`workflow_dispatch`). |
| 17 | + |
| 18 | +`bats-core/bats-action@4.1.0` (2026-11-01) is a composite action: |
| 19 | + |
| 20 | +- It downloads the bats-core tarball of `bats-version` from `api.github.com`, with the |
| 21 | + `github-token` input when it is set, and installs it into `~/.local/share/bats`. An |
| 22 | + empty version or `latest` is resolved with the GitHub API to the latest release. |
| 23 | +- It caches that directory with `actions/cache` (pinned to the commit of v6.1.0, which |
| 24 | + runs on `node24`). The cache key is |
| 25 | + `${{ runner.os }}-${{ runner.arch }}-bats-${{ inputs.bats-version }}`. |
| 26 | +- By default it also installs bats-support, bats-assert, bats-detik and bats-file into |
| 27 | + `/usr/lib/...`. |
| 28 | + |
| 29 | +The tests load only `tests/test_helper.bash`, which has its own `assert_*` functions. |
| 30 | +All 76 tests pass locally with bats 1.14.0 (macOS, Homebrew). |
| 31 | + |
| 32 | +`actionlint` 1.7.12 (run with Docker, `rhysd/actionlint`) reports the current `ci.yml`: |
| 33 | +`the runner of "actions/checkout@v2" action is too old to run on GitHub Actions`. |
| 34 | + |
| 35 | +## Goals / Non-Goals |
| 36 | + |
| 37 | +**Goals:** |
| 38 | + |
| 39 | +- The same bats version in CI as from Homebrew, set in one place. |
| 40 | +- No action in `ci.yml` that targets Node.js 20. |
| 41 | + |
| 42 | +**Non-Goals:** |
| 43 | + |
| 44 | +- Pinning the actions by commit SHA: the workflows of the project use version tags |
| 45 | + (`pages.yml`: `actions/checkout@v7`). |
| 46 | + |
| 47 | +## Decisions |
| 48 | + |
| 49 | +### `bats-core/bats-action` for bats |
| 50 | + |
| 51 | +``` |
| 52 | + bats-action@4.1.0 git clone + install.sh mig4 with 1.14.0 |
| 53 | +---------------- -------------------- ----------------------- ----------------- |
| 54 | +maintained by bats-core, 2026-11 our own script no release since 2020 |
| 55 | +Node.js 20 no (composite) no yes |
| 56 | +exact version bats-version --branch v1.14.0 bats-version |
| 57 | +extra installs 4 libraries, can be none none |
| 58 | + turned off |
| 59 | +cache yes, key by version no no |
| 60 | +``` |
| 61 | + |
| 62 | +The action is the official one and was suggested in #176. A `git clone` of the tag with |
| 63 | +`install.sh` has no dependency, but is a script of our own to keep in the workflow. |
| 64 | +`mig4` with a new version keeps the Node.js 20 warning. npm (`bats` 1.13.0) and apt on |
| 65 | +Ubuntu 24.04 (1.10.0) do not have 1.14.0. |
| 66 | + |
| 67 | +### An exact bats version, not `latest` |
| 68 | + |
| 69 | +With an empty version or `latest`, the cache key is always `...-bats-`. The first run |
| 70 | +caches the latest bats of that day, and every later run restores it. The scheduled runs |
| 71 | +keep the cache in use, so it does not expire, and CI would stay on that bats version. |
| 72 | +`bats-version: 1.14.0` gives a key per version: a new version is a one-line change that |
| 73 | +also replaces the cache. |
| 74 | + |
| 75 | +### No bats libraries |
| 76 | + |
| 77 | +`support-install`, `assert-install`, `detik-install` and `file-install` are `false`. The |
| 78 | +tests do not load them, so they would only add downloads to every run without a cache |
| 79 | +hit. |
| 80 | + |
| 81 | +### `github-token` |
| 82 | + |
| 83 | +`github-token: ${{ secrets.GITHUB_TOKEN }}`, the same secret `make test` gets as |
| 84 | +`GH_TOC_TOKEN`. Without it, the tarball is downloaded from `api.github.com` without |
| 85 | +authentication, which has a limit of 60 requests per hour per IP, shared by the jobs on |
| 86 | +the runner's IP. |
| 87 | + |
| 88 | +### `actions/checkout@v7` |
| 89 | + |
| 90 | +v5 moved to `node24` (runner 2.327.1 or newer, GitHub-hosted runners have it), v6 keeps |
| 91 | +the credentials in a separate file, v7 blocks checking out a fork PR on |
| 92 | +`pull_request_target` and `workflow_run`. `ci.yml` does not use those events, and |
| 93 | +`make test` does not use the git credentials. `pages.yml` already uses `@v7`. |
| 94 | + |
| 95 | +### The new steps |
| 96 | + |
| 97 | +```yaml |
| 98 | + - name: Setup bats |
| 99 | + uses: bats-core/bats-action@4.1.0 |
| 100 | + with: |
| 101 | + bats-version: 1.14.0 |
| 102 | + support-install: false |
| 103 | + assert-install: false |
| 104 | + detik-install: false |
| 105 | + file-install: false |
| 106 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 107 | + |
| 108 | + - name: Check out code |
| 109 | + uses: actions/checkout@v7 |
| 110 | +``` |
| 111 | +
|
| 112 | +The step names and their order stay as they are. |
| 113 | +
|
| 114 | +### Checks |
| 115 | +
|
| 116 | +Locally: `yamllint -d relaxed` and `actionlint` (Docker) on `ci.yml`. The workflow |
| 117 | +itself runs only on GitHub: the CI of the PR shows `bats-version: 1.14.0` in the inputs |
| 118 | +of "Setup bats", the installed bats, the Node.js 20 annotation without these actions, and |
| 119 | +the result of the tests. |
| 120 | + |
| 121 | +## Risks / Trade-offs |
| 122 | + |
| 123 | +- [A test passes with bats 1.6.0 and 1.14.0 on macOS but not with 1.14.0 on Linux] → |
| 124 | + The CI of the PR runs the whole suite before the merge. |
| 125 | +- [The remote tests fail now and then on github.com pages] → Not related to this change |
| 126 | + (#179); the failed job can be run again. |
| 127 | +- [bats-action changes in a later release] → It is pinned to the `4.1.0` tag. |
0 commit comments