Skip to content

Commit e0809c6

Browse files
authored
Merge pull request #206 from ekalinin/chore/update-ci-bats
chore(ci): update bats to 1.14.0 and checkout to v7
2 parents 5e8f57f + 72f8c58 commit e0809c6

5 files changed

Lines changed: 210 additions & 3 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,17 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: Setup bats
20-
uses: mig4/setup-bats@v1
20+
uses: bats-core/bats-action@4.1.0
2121
with:
22-
bats-version: 1.6.0
22+
bats-version: 1.14.0
23+
support-install: false
24+
assert-install: false
25+
detik-install: false
26+
file-install: false
27+
github-token: ${{ secrets.GITHUB_TOKEN }}
2328

2429
- name: Check out code
25-
uses: actions/checkout@v2
30+
uses: actions/checkout@v7
2631

2732
- name: Run tests
2833
run: make test
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
schema: spec-driven
2+
created: 2026-11-08
3+
skip_specs: true
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Proposal
2+
3+
## Why
4+
5+
CI runs the tests with bats 1.6.0, installed by `mig4/setup-bats@v1` (#176). The latest
6+
bats-core release is 1.14.0 (2026-07-21), and Homebrew installs 1.14.0, so local runs and
7+
CI use different bats versions. All 76 tests pass locally with bats 1.14.0 (macOS).
8+
9+
`mig4/setup-bats` had its last release (`v1.2.0`) in 2020. Every CI run has the warning
10+
`Node.js 20 is deprecated. The following actions target Node.js 20 but are being forced
11+
to run on Node.js 24: actions/checkout@v2, mig4/setup-bats@v1.`
12+
13+
## What Changes
14+
15+
- `.github/workflows/ci.yml`, step "Setup bats": `mig4/setup-bats@v1` with
16+
`bats-version: 1.6.0` is replaced with `bats-core/bats-action@4.1.0` with
17+
`bats-version: 1.14.0`. The bats libraries that the action installs by default
18+
(bats-support, bats-assert, bats-detik, bats-file) are not installed: the tests use
19+
their own `tests/test_helper.bash`. The action gets `github-token`.
20+
- `.github/workflows/ci.yml`, step "Check out code": `actions/checkout@v2` is replaced
21+
with `actions/checkout@v7`, the version `pages.yml` already uses.
22+
23+
The tests, `gh-md-toc` and the other workflows do not change.
24+
25+
Non-goals:
26+
27+
- `.github/workflows/dockerimage.yml` (`actions/checkout@v2`,
28+
`docker/build-push-action@v1`): another workflow, and `docker/build-push-action` has a
29+
different API in its later versions.
30+
- Taking the latest bats in CI on every run instead of a fixed version.
31+
- Automatic updates of the actions and the bats version (Dependabot).
32+
- The remote tests that fail now and then on github.com pages (#179, the HTTP status of
33+
a remote URL is not checked).
34+
35+
## Capabilities
36+
37+
### New Capabilities
38+
39+
None.
40+
41+
### Modified Capabilities
42+
43+
None. The change is in CI only; the behavior of `gh-md-toc` does not change, so
44+
`skip_specs: true` is set in `.openspec.yaml`.
45+
46+
## Impact
47+
48+
- `.github/workflows/ci.yml`: the "Setup bats" and "Check out code" steps.
49+
- CI: bats 1.14.0 instead of 1.6.0, the same version as Homebrew. No Node.js 20 warning
50+
from this workflow.
51+
- Closes #176.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Tasks
2+
3+
## 1. Workflow
4+
5+
- [x] 1.1 `.github/workflows/ci.yml`, step "Setup bats": replace `mig4/setup-bats@v1`
6+
and `bats-version: 1.6.0` with the `bats-core/bats-action@4.1.0` step from design.md
7+
(`bats-version: 1.14.0`, the four `*-install: false`, `github-token`); verify
8+
`yamllint -d relaxed .github/workflows/ci.yml` passes
9+
- [x] 1.2 `.github/workflows/ci.yml`, step "Check out code": replace `actions/checkout@v2`
10+
with `actions/checkout@v7`; verify
11+
`docker run --rm -i rhysd/actionlint:1.7.12 -color=false - < .github/workflows/ci.yml`
12+
reports nothing, and `git diff` changes only these two steps
13+
14+
## 2. Verification
15+
16+
- [x] 2.1 Run `make test` locally with bats 1.14.0 and `GH_TOC_TOKEN` set; verify all
17+
tests pass
18+
- [x] 2.2 After the branch is pushed and the PR is opened (each step on request), check
19+
its CI run: "Setup bats" has `bats-version: 1.14.0` in its inputs and installs bats
20+
1.14.0, the run has no Node.js 20 annotation for `actions/checkout` or the bats step,
21+
and all tests pass

0 commit comments

Comments
 (0)