@m4ss/pi-skills 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/package.json +4 -3
- package/skills/repo-maintenance/SKILL.md +251 -0
- package/skills/repo-maintenance/references/changelogs.md +164 -0
- package/skills/repo-maintenance/references/ci-audit.md +329 -0
- package/skills/repo-maintenance/references/containers.md +287 -0
- package/skills/repo-maintenance/references/forgejo.md +162 -0
- package/skills/repo-maintenance/references/node.md +376 -0
- package/skills/repo-maintenance/references/rust.md +567 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
# CI audit
|
|
2
|
+
|
|
3
|
+
This file covers general CI rules and GitHub Actions. Forgejo Actions and
|
|
4
|
+
`code.m4ss.net` are in `references/forgejo.md`.
|
|
5
|
+
|
|
6
|
+
Fix clear issues directly (one commit per concern) and propose changes that
|
|
7
|
+
are a matter of preference. Write commit bodies that state what was wrong or
|
|
8
|
+
what a hardening pass changed:
|
|
9
|
+
|
|
10
|
+
```text
|
|
11
|
+
chore(ci): harden CI workflow
|
|
12
|
+
|
|
13
|
+
Restrict the token to read access, pin actions to verified commit SHAs
|
|
14
|
+
and check out without persisted credentials. Add a concurrency group
|
|
15
|
+
and per-job timeouts.
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
chore(ci): keep testing the other platforms when one fails
|
|
20
|
+
|
|
21
|
+
A failure on one platform cancelled the test jobs of the others, so
|
|
22
|
+
it wasn't known whether they passed.
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Checklist
|
|
26
|
+
|
|
27
|
+
### Triggers and runs
|
|
28
|
+
|
|
29
|
+
- **Duplicate branch runs**: When `pull_request` is present and `push` is
|
|
30
|
+
unrestricted, propose (do not change unasked) restricting `push` to `main` so
|
|
31
|
+
PR branch pushes do not run CI twice.
|
|
32
|
+
- **Concurrency**: Cancel superseded runs with
|
|
33
|
+
`group: ${{ github.workflow }}-${{ github.ref }}` and
|
|
34
|
+
`cancel-in-progress: true`.
|
|
35
|
+
- **Timeouts**: Set `timeout-minutes` on every job.
|
|
36
|
+
- **Matrix `fail-fast`**: Set `fail-fast: false` on platform matrices so one
|
|
37
|
+
platform failure does not cancel the others.
|
|
38
|
+
- **Privileged triggers**: Flag `pull_request_target`, `workflow_run` and
|
|
39
|
+
`issue_comment` triggers that run with secrets on untrusted code or input.
|
|
40
|
+
|
|
41
|
+
### Token and credentials
|
|
42
|
+
|
|
43
|
+
- **Permissions**: Set top-level `permissions: contents: read`. Grant broader
|
|
44
|
+
permissions only per-job (or workflow-wide if every job requires it) with a
|
|
45
|
+
comment explaining why (e.g., `id-token: write` for npm trusted publishing).
|
|
46
|
+
- **Checkout credentials**: Set `persist-credentials: false` on
|
|
47
|
+
`actions/checkout` unless a subsequent step pushes using the job token.
|
|
48
|
+
- **Secrets**: Pass secrets individually (`secrets.FOO`), never with
|
|
49
|
+
`secrets: inherit` or `toJSON(secrets)`.
|
|
50
|
+
- **Script injection**: Never interpolate untrusted context values (PR titles,
|
|
51
|
+
branch names, issue bodies) via `${{ }}` inside `run:`; pass them through
|
|
52
|
+
`env:` variables instead.
|
|
53
|
+
|
|
54
|
+
### Pinning
|
|
55
|
+
|
|
56
|
+
- **Actions**: Pin every `uses:` to a full 40-character commit SHA followed by
|
|
57
|
+
a comment with the most specific release tag (`# v7.0.1`, not `# v7`), or the
|
|
58
|
+
branch name if the action makes no releases
|
|
59
|
+
(`dtolnay/rust-toolchain@<sha> # master`).
|
|
60
|
+
- **Verify existing action pins**: Resolve each tag (see "Refreshing pinned
|
|
61
|
+
actions", step 2) and confirm the pinned SHA is the dereferenced commit and is
|
|
62
|
+
the same in `.github/` and `.forgejo/` twins, except where the
|
|
63
|
+
"`.github/` and `.forgejo/` twins" rule in `references/forgejo.md` lets them
|
|
64
|
+
differ. For branch pins on GitHub, verify the commit belongs to the upstream
|
|
65
|
+
branch rather than a fork:
|
|
66
|
+
`curl -sS https://api.github.com/repos/<owner>/<repo>/compare/<sha>...<branch> | jq -r .status`
|
|
67
|
+
must return `ahead` or `identical`. On `code.m4ss.net`, mirrors only hold
|
|
68
|
+
upstream commits, so checking HTTP 200 is sufficient:
|
|
69
|
+
`curl -sS -o /dev/null -w '%{http_code}' https://code.m4ss.net/api/v1/repos/Actions/<repo>/git/commits/<sha>`.
|
|
70
|
+
- **Installed tools**: Pin tool versions (`tool: cargo-hack@0.6.39`). Use
|
|
71
|
+
`curl -fsSL` for downloads (without `-f`, HTTP error pages are saved as 0-exit
|
|
72
|
+
files) and verify checksums when published.
|
|
73
|
+
- **Downloaded tools**: Cache every binary or archive a workflow downloads
|
|
74
|
+
with `curl`, so CI does not fetch it from an external service on every run
|
|
75
|
+
and keeps working during that service's downtime while the cache is warm:
|
|
76
|
+
1. Put the version and its SHA256 together in `env:`, with a comment saying
|
|
77
|
+
where the checksum comes from.
|
|
78
|
+
2. Restore the file with the cache action (`actions/cache` on GitHub,
|
|
79
|
+
`Actions/cache` on `code.m4ss.net`), with the version in the `key`.
|
|
80
|
+
3. Run `curl -fsSL` only when the file is missing, then always check it with
|
|
81
|
+
`sha256sum -c`, whether it came from the cache or the network.
|
|
82
|
+
|
|
83
|
+
When bumping the version, update the SHA256 in the same commit. Example
|
|
84
|
+
(in a `.forgejo/workflows/` file of our repositories, write `uses:` as
|
|
85
|
+
`https://code.m4ss.net/Actions/cache@<sha>` instead):
|
|
86
|
+
|
|
87
|
+
```yaml
|
|
88
|
+
env:
|
|
89
|
+
NIX_INSTALLER_VERSION: 2.35.3
|
|
90
|
+
# sha256 of nix-installer-x86_64-linux, from the digest GitHub shows
|
|
91
|
+
# for the release asset.
|
|
92
|
+
NIX_INSTALLER_SHA256: 59a1841db7d41d5127163cc8acad45a04b0d73e95a022269d4b9e7ae2ad7fab2
|
|
93
|
+
steps:
|
|
94
|
+
- name: Cache nix-installer
|
|
95
|
+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
96
|
+
with:
|
|
97
|
+
path: /tmp/nix-installer
|
|
98
|
+
key: nix-installer-x86_64-linux-${{ env.NIX_INSTALLER_VERSION }}
|
|
99
|
+
- name: Install Nix
|
|
100
|
+
run: |
|
|
101
|
+
if [ ! -f /tmp/nix-installer ]; then
|
|
102
|
+
curl -fsSL -o /tmp/nix-installer "https://github.com/NixOS/nix-installer/releases/download/${NIX_INSTALLER_VERSION}/nix-installer-x86_64-linux"
|
|
103
|
+
fi
|
|
104
|
+
echo "${NIX_INSTALLER_SHA256} /tmp/nix-installer" | sha256sum -c -
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
- **Containers**: Pin `container:`, `services:` and `docker run` images by
|
|
108
|
+
digest (`image:tag@sha256:...` or `image@sha256:... # tag`). Choose and
|
|
109
|
+
upgrade their tags with `references/containers.md`; only workflow images
|
|
110
|
+
get a digest added where there is none.
|
|
111
|
+
- **Rust toolchains**: Pin the Rust version (see "Toolchains").
|
|
112
|
+
|
|
113
|
+
### Runners
|
|
114
|
+
|
|
115
|
+
- Pin explicit OS versions (`ubuntu-26.04`, `macos-26`, `windows-2025` at the
|
|
116
|
+
time of writing; check the `actions/runner-images` README for current
|
|
117
|
+
labels). Never use moving `-latest` labels (`ubuntu-latest`, `macos-latest`,
|
|
118
|
+
`windows-latest`).
|
|
119
|
+
- **Ask before upgrading Ubuntu on jobs that build release binaries:** Linux
|
|
120
|
+
binaries require at least the build host's glibc at runtime. At the time of
|
|
121
|
+
writing, targeting Debian 13 "trixie" (glibc 2.41) requires staying on
|
|
122
|
+
`ubuntu-24.04` (glibc 2.39) rather than `ubuntu-26.04` (glibc 2.43) until
|
|
123
|
+
Debian 14 "forky" is stable.
|
|
124
|
+
|
|
125
|
+
### What the jobs run
|
|
126
|
+
|
|
127
|
+
- Pass `--locked` to every Cargo build/test command and `--frozen-lockfile` to
|
|
128
|
+
`pnpm install`.
|
|
129
|
+
- Run `clippy` with `--all-targets` and relevant feature combinations on the
|
|
130
|
+
pinned Rust toolchain (see "Toolchains"). Library crates published to
|
|
131
|
+
crates.io (crates with a library target, even if they also ship a binary)
|
|
132
|
+
also need an MSRV job with the `rust-version` toolchain; binary-only and
|
|
133
|
+
unpublished crates do not, even when a binary is published for
|
|
134
|
+
`cargo install`.
|
|
135
|
+
- Run `cargo-deny` when `deny.toml` exists, and verify `[graph] targets` in
|
|
136
|
+
`deny.toml`:
|
|
137
|
+
- Library: omit `targets` so `cargo-deny` checks all targets.
|
|
138
|
+
- Binary or container image: `targets` must match the exact target triples CI
|
|
139
|
+
builds (from `--target <triple>`, `Dockerfile`s, or the builder image's own
|
|
140
|
+
triple when `cargo build` runs without `--target`, e.g.
|
|
141
|
+
`x86_64-unknown-linux-musl` on `amd64` Alpine). Watch for stale `-musl` or
|
|
142
|
+
`aarch64` triples after CI changes. If `deny.toml` is updated, re-run
|
|
143
|
+
`cargo deny --workspace --all-features check` to catch newly exposed
|
|
144
|
+
advisories/licenses or unused `allow`/`ignore` entries.
|
|
145
|
+
- Keep Node.js matrix versions aligned with maintained releases from
|
|
146
|
+
`nodejs/Release` (drop EOL majors, add new LTS).
|
|
147
|
+
- Give every job or matrix entry that caches build outputs (such as Cargo's
|
|
148
|
+
`target/`) its own `actions/cache` `key`, built from the job or build
|
|
149
|
+
profile, toolchain, runner OS/arch or target triple, and matrix dimensions
|
|
150
|
+
plus `hashFiles('Cargo.lock')`. With a shared key, one job either cannot
|
|
151
|
+
save its cache or overwrites it with another build's output. Common
|
|
152
|
+
collisions: `test` and a release `build` on different Ubuntu versions, a
|
|
153
|
+
`live` job and `test`, and an `msrv` job whose key uses
|
|
154
|
+
`${{ env.RUST_VERSION }}`. Package-store caches (`setup-node` with
|
|
155
|
+
`cache: pnpm`) may share a key.
|
|
156
|
+
|
|
157
|
+
### Publishing
|
|
158
|
+
|
|
159
|
+
- Mark every package or crate not meant for registry publication so a stray
|
|
160
|
+
`cargo publish` or `pnpm publish -r` cannot release it:
|
|
161
|
+
- Rust: `publish = false` in `Cargo.toml` (or `publish.workspace = true`).
|
|
162
|
+
`cargo-deny` also requires this marker for
|
|
163
|
+
`[licenses.private] ignore = true`.
|
|
164
|
+
- Node.js: `"private": true` in `package.json` (including the workspace root,
|
|
165
|
+
apps, examples and internal tools).
|
|
166
|
+
- Compare local manifests against the registries:
|
|
167
|
+
|
|
168
|
+
```sh
|
|
169
|
+
cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | [.name, (.publish | tostring)] | @tsv' # [] means publish = false
|
|
170
|
+
git ls-files '*package.json' | while read -r f; do jq -r --arg f "$f" '[$f, .name, (.private // false)] | @tsv' "$f"; done
|
|
171
|
+
cargo info -q <crate> --registry crates-io | grep '^repository:'
|
|
172
|
+
npm view <name> repository.url
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Verify the registry entry's `repository` URL points to this repository (not
|
|
176
|
+
an unrelated package with the same name). If a crate or package is neither
|
|
177
|
+
marked private nor published from this repository, ask before adding the
|
|
178
|
+
marker (in case a first release is planned), then commit as `build: ...`.
|
|
179
|
+
|
|
180
|
+
- In published Rust crates, exclude CI configs from the crate tarball
|
|
181
|
+
(`exclude = [".github/", ".forgejo/", "deny.toml"]`; verify with
|
|
182
|
+
`cargo package --list`).
|
|
183
|
+
|
|
184
|
+
### Other CI files and tools
|
|
185
|
+
|
|
186
|
+
- **`.gitlab-ci.yml` in our repositories**: Our repositories migrated from
|
|
187
|
+
GitLab CI to Forgejo Actions; flag any leftover `.gitlab-ci.yml` and ask.
|
|
188
|
+
- **`.github/dependabot.yml`**: Check for open Dependabot PRs before bumping
|
|
189
|
+
actions manually, and mirror any Dependabot action bumps into
|
|
190
|
+
`.forgejo/workflows/` by hand.
|
|
191
|
+
- **Static analysis tools**:
|
|
192
|
+
- Run `zizmor --pedantic .github/workflows` (set `GH_TOKEN` to enable online
|
|
193
|
+
checks like `impostor-commit` and `known-vulnerable-actions`). Run it
|
|
194
|
+
without installing via `uvx zizmor` or `pipx run zizmor`, or install it
|
|
195
|
+
with `cargo install --locked zizmor`.
|
|
196
|
+
- Run `actionlint` on `.github/workflows/`.
|
|
197
|
+
- In pnpm workspaces, `pnpm outdated --include-github-actions` and
|
|
198
|
+
`pnpm update --include-github-actions` list and update `.github/workflows/`
|
|
199
|
+
action pins; still verify tags and commit SHAs as below.
|
|
200
|
+
|
|
201
|
+
## Refreshing pinned actions
|
|
202
|
+
|
|
203
|
+
Check when action pins were last updated:
|
|
204
|
+
`git log -5 --format='%cs %s' -G'@[0-9a-f]{40}' -- .github .forgejo`. Refresh
|
|
205
|
+
them every couple of months, or immediately for security fixes or breakages:
|
|
206
|
+
|
|
207
|
+
1. List the latest full version tags:
|
|
208
|
+
`git ls-remote --tags --refs https://github.com/<owner>/<repo> | sed 's|.*refs/tags/||' | grep -E '^v?[0-9]+(\.[0-9]+)+$' | sort -V | tail -3`.
|
|
209
|
+
2. Resolve the tag's commit SHA directly from the upstream repository (for
|
|
210
|
+
annotated tags, use the dereferenced `^{}` commit SHA, never the tag object
|
|
211
|
+
SHA):
|
|
212
|
+
`git ls-remote https://github.com/<owner>/<repo> 'refs/tags/<tag>' 'refs/tags/<tag>^{}'`.
|
|
213
|
+
3. Read the release notes between the old and new versions for breaking input,
|
|
214
|
+
default or Node.js runtime changes.
|
|
215
|
+
4. Update the SHA and version comment across `.github/workflows/` and
|
|
216
|
+
`.forgejo/workflows/` (after confirming the `code.m4ss.net` mirror has the
|
|
217
|
+
commit; see `references/forgejo.md`).
|
|
218
|
+
5. If an action was pinned to an unreleased branch commit (`# main`), check
|
|
219
|
+
whether a tagged release now includes that commit. The repository you are
|
|
220
|
+
auditing does not have the action's commits, so clone the action first:
|
|
221
|
+
|
|
222
|
+
```sh
|
|
223
|
+
git clone -q --bare --filter=blob:limit=1m https://github.com/<owner>/<repo> <scratch>/<repo>-action.git
|
|
224
|
+
git -C <scratch>/<repo>-action.git merge-base --is-ancestor <sha> <tag> && echo "included in <tag>"
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
If it prints "included", switch the pin to the release tag.
|
|
228
|
+
|
|
229
|
+
Use the subjects in `SKILL.md`, "Commit subjects", noting any security fixes,
|
|
230
|
+
runtime changes or workflow adjustments in the body. Put major action upgrades
|
|
231
|
+
requiring workflow edits in their own commit.
|
|
232
|
+
|
|
233
|
+
## Toolchains
|
|
234
|
+
|
|
235
|
+
CI must pin the Rust version (`RUST_VERSION: 1.NN.P` in top-level `env:` and
|
|
236
|
+
`FROM docker.io/library/rust:1.NN-...` in Containerfiles used only by CI) for
|
|
237
|
+
`rustfmt`, `clippy`, `cargo-hack`, `doc` and `build`, rather than using floating
|
|
238
|
+
`stable`.
|
|
239
|
+
|
|
240
|
+
Verify every job that runs `cargo clippy` (dedicated `clippy` jobs, combined
|
|
241
|
+
`test` jobs, or cross-platform `build` jobs):
|
|
242
|
+
|
|
243
|
+
- It sets `toolchain: ${{ env.RUST_VERSION }}` on `dtolnay/rust-toolchain`
|
|
244
|
+
(pinned to a `# master` commit), never `@stable`, `toolchain: stable`,
|
|
245
|
+
`rustup update ... stable`, or an omitted `toolchain:` input.
|
|
246
|
+
- It sets `components: clippy` on `rust-toolchain` (required when
|
|
247
|
+
`RUST_VERSION` differs from the runner image's preinstalled toolchain and
|
|
248
|
+
installs with `--profile minimal`).
|
|
249
|
+
- Moving channel names (`stable`, `beta`, `nightly`) appear only in `test`
|
|
250
|
+
matrices that run `cargo test` without `cargo clippy`.
|
|
251
|
+
|
|
252
|
+
Compare pinned toolchains against current upstream releases:
|
|
253
|
+
|
|
254
|
+
```sh
|
|
255
|
+
for c in stable beta nightly; do
|
|
256
|
+
curl -sSf "https://static.rust-lang.org/dist/channel-rust-$c.toml" | awk '/^\[pkg\.rust\]/{getline; print}'
|
|
257
|
+
done
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
- **Stable** (`1.NN.P`): Bump to the latest stable release, however recent:
|
|
261
|
+
Rust releases have no release-age gate.
|
|
262
|
+
- **Beta** (a workflow may pin it as `beta-YYYY-MM-DD` or `1.NN.0-beta.N`;
|
|
263
|
+
the channel file above prints the `1.NN.0-beta.N` form): Bump if it
|
|
264
|
+
predates the latest stable cycle.
|
|
265
|
+
- **Nightly** (`nightly-YYYY-MM-DD`): Bump when it predates the latest stable
|
|
266
|
+
release (~6 weeks) or when needed sooner. Verify the target date includes all
|
|
267
|
+
required components (`clippy`, `rustfmt`, `miri`, etc.) with:
|
|
268
|
+
`rustup toolchain install nightly-YYYY-MM-DD --profile minimal -c <component>`.
|
|
269
|
+
|
|
270
|
+
To bump a pinned toolchain:
|
|
271
|
+
|
|
272
|
+
1. Install it locally:
|
|
273
|
+
`rustup toolchain install <new> --profile minimal -c clippy -c rustfmt`.
|
|
274
|
+
2. Run CI's commands with `cargo +<new>`. If new clippy warnings appear, fix
|
|
275
|
+
them first in a separate `style(clippy): ...` commit. If a dependency no
|
|
276
|
+
longer compiles on the new toolchain, keep the old one, then find the first
|
|
277
|
+
release of that crate that compiles: add only the crate at its newest
|
|
278
|
+
version to an empty project in `<scratch>` (`cargo new --lib`) and run
|
|
279
|
+
`cargo +<new> check` there. Report the result as "Rust 1.NN needs <crate>
|
|
280
|
+
vX", or as "no release of <crate> compiles on 1.NN yet" only if the newest
|
|
281
|
+
one fails too. Do not rely on issue threads or changelogs alone for this.
|
|
282
|
+
3. Update the version string everywhere it appears: `RUST_VERSION`,
|
|
283
|
+
`toolchain:` inputs, job `name` strings (e.g., `clippy / 1.NN.P`) and
|
|
284
|
+
cache keys, in both `.github/workflows/` and `.forgejo/workflows/`, and
|
|
285
|
+
`channel` in `rust-toolchain.toml` if it pins the same version. Then check
|
|
286
|
+
that no occurrence is left; this must print nothing:
|
|
287
|
+
`git grep -n -F '<old 1.NN.P>' -- .github .forgejo ':(glob)**/rust-toolchain*'`.
|
|
288
|
+
4. Containerfiles used only by CI are the ones a workflow builds only to run
|
|
289
|
+
CI jobs in, not ones it publishes or deploys. Find the Containerfiles the
|
|
290
|
+
workflows build with
|
|
291
|
+
`git grep -n -E '(podman|docker) build|file:|context:' -- .github .forgejo`.
|
|
292
|
+
They carry only `1.NN` (in the `FROM` tag or an `ARG` default), so skip
|
|
293
|
+
this item when the minor version is unchanged. Otherwise update them in
|
|
294
|
+
this same commit, then check that none is left; this must print nothing:
|
|
295
|
+
`git grep -n -w -F '<old 1.NN>' -- <each CI-only Containerfile>`.
|
|
296
|
+
Bump the Rust image in the other Containerfiles in a separate commit
|
|
297
|
+
(`references/containers.md`).
|
|
298
|
+
5. Commit as `chore(ci): upgrade Rust to v1.NN.P` (or `... Rust beta to ...` /
|
|
299
|
+
`... Rust nightly to YYYY-MM-DD`).
|
|
300
|
+
|
|
301
|
+
## Keeping our repositories alike
|
|
302
|
+
|
|
303
|
+
Before changing `deny.toml` or CI in our repositories, compare with siblings:
|
|
304
|
+
|
|
305
|
+
1. **Fetch 3–4 recently updated sibling repositories** of the same project type
|
|
306
|
+
(Rust library, Rust binary, or pnpm app):
|
|
307
|
+
- Public siblings on GitHub (excluding forks):
|
|
308
|
+
`curl -sS 'https://api.github.com/orgs/M4SS-Code/repos?type=sources&per_page=100&sort=pushed' | jq -r '.[] | [.name, .pushed_at, .language] | @tsv'`
|
|
309
|
+
- Private siblings on `code.m4ss.net` (requires `$FORGEJO_TOKEN`; ask for one
|
|
310
|
+
if needed):
|
|
311
|
+
`curl -sS -H "Authorization: token $FORGEJO_TOKEN" 'https://code.m4ss.net/api/v1/repos/search?mode=source&sort=updated&order=desc&limit=50'`
|
|
312
|
+
- Read files from
|
|
313
|
+
`https://raw.githubusercontent.com/M4SS-Code/<repo>/HEAD/<path>`,
|
|
314
|
+
`https://code.m4ss.net/Mirror/<repo>/raw/branch/main/<path>`, or
|
|
315
|
+
`https://code.m4ss.net/<owner>/<repo>/raw/branch/<branch>/<path>`.
|
|
316
|
+
2. **Identify the canonical template**: Follow the structure and conventions
|
|
317
|
+
used by the most recently maintained siblings.
|
|
318
|
+
3. **Compare section by section**:
|
|
319
|
+
- `deny.toml`: Match section order and settings; only `[graph] targets`,
|
|
320
|
+
`[licenses] allow` and `[advisories] ignore` should differ based on the
|
|
321
|
+
project.
|
|
322
|
+
- Workflows: Match triggers, concurrency, permissions, job/step names,
|
|
323
|
+
pinned action SHAs and toolchain pins; keep only project-specific features,
|
|
324
|
+
services, or intentional differences (such as `ubuntu-24.04` release binary
|
|
325
|
+
builds).
|
|
326
|
+
4. **Align unintended drift**, one concern per commit.
|
|
327
|
+
5. **Propagate improvements**: If the shared template itself has a flaw (missing
|
|
328
|
+
hardening, outdated pin, better setting), fix it in this repository and list
|
|
329
|
+
every sibling repository that needs the same fix in the report.
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
# Container images
|
|
2
|
+
|
|
3
|
+
Upgrade the images in a repository's Containerfiles (including `Dockerfile`s)
|
|
4
|
+
and Compose files. Use `podman` and `skopeo` for every command below; fall
|
|
5
|
+
back to `docker` only when `podman` is not installed.
|
|
6
|
+
|
|
7
|
+
Two kinds of Containerfile are handled elsewhere:
|
|
8
|
+
|
|
9
|
+
- `Actions/ci-images`: follow `references/forgejo.md` ("Maintaining
|
|
10
|
+
`Actions/ci-images`").
|
|
11
|
+
- Containerfiles used only by CI: bump their Rust image in the same commit as
|
|
12
|
+
`RUST_VERSION` (`references/ci-audit.md`, "Toolchains").
|
|
13
|
+
|
|
14
|
+
Images have no release-age gate: take the newest tag that matches the rules
|
|
15
|
+
below, however recent it is.
|
|
16
|
+
|
|
17
|
+
## 1. Find the files, their images and their versions
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
# Containerfiles: every FROM, every ARG (an ARG above FROM can hold the tag),
|
|
21
|
+
# and images used by COPY --from= or RUN --mount=...,from=
|
|
22
|
+
git ls-files | grep -E '(^|/)(Dockerfile|Containerfile)([.-][^/]*)?$|\.(Dockerfile|Containerfile)$' \
|
|
23
|
+
| while read -r f; do grep -n -H -E '^\s*(ARG|FROM)\b|--from=[^ ]*[/:]|from=[^ ,]*[/:]' "$f"; done
|
|
24
|
+
# Compose files: every image line
|
|
25
|
+
git ls-files | grep -E '(^|/)(docker-)?compose([.-][^/]*)?\.ya?ml$' \
|
|
26
|
+
| while read -r f; do grep -n -H -E '^\s*image:' "$f"; done
|
|
27
|
+
# Variables inside image lines, such as ${NATS_TAG:-2.12-alpine}
|
|
28
|
+
git ls-files | grep -E '(^|/)(docker-)?compose([.-][^/]*)?\.ya?ml$' \
|
|
29
|
+
| while read -r f; do grep -n -H -E '^\s*image:.*\$\{' "$f"; done
|
|
30
|
+
# CI workflows: job containers and service containers
|
|
31
|
+
git grep -n -E '^\s*(image|container):' -- .github .forgejo
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
If the third search (variables inside image lines) prints anything, look the
|
|
35
|
+
variable up in the repository's `.env` files
|
|
36
|
+
(`git grep -n '^NATS_TAG=' -- '*.env*'`, with the variable's name).
|
|
37
|
+
|
|
38
|
+
Workflow images follow the same tag rules as the rest of this file, and are
|
|
39
|
+
also pinned by digest (`references/ci-audit.md`, "Pinning"). Containerfiles
|
|
40
|
+
and Compose files get a digest only if they already have one.
|
|
41
|
+
|
|
42
|
+
For each image, note:
|
|
43
|
+
|
|
44
|
+
- **The full reference:** registry, namespace, name, tag and any `@sha256:`
|
|
45
|
+
digest.
|
|
46
|
+
- **Where its version lives:** in the `FROM` or `image:` line, in an `ARG`
|
|
47
|
+
default (`ARG RUST_VERSION=1.96` with `FROM ...:${RUST_VERSION}-alpine3.24`),
|
|
48
|
+
or in a Compose variable (`${NATS_TAG:-2.12-alpine}`, or a `.env` file).
|
|
49
|
+
If an `ARG` has no default, its value comes from a `--build-arg` in a CI
|
|
50
|
+
workflow or from `args:` under a Compose service's `build:`. Change the
|
|
51
|
+
version where it is defined.
|
|
52
|
+
- **Its registry:** for a private registry (such as `code.m4ss.net`),
|
|
53
|
+
`podman search` and `skopeo inspect` need a login. If you have none, list
|
|
54
|
+
the image in the report instead of guessing its tags.
|
|
55
|
+
- **Its role**, from the table in section 3.
|
|
56
|
+
- **In a multi-stage Containerfile:** which stages build a binary and which
|
|
57
|
+
stage runs it.
|
|
58
|
+
|
|
59
|
+
A Compose service with `build:` instead of `image:` uses a Containerfile, which
|
|
60
|
+
the first search already covers.
|
|
61
|
+
|
|
62
|
+
## 2. Look up the current versions
|
|
63
|
+
|
|
64
|
+
Query these on every run; do not rely on versions written in this file.
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
# Rust stable
|
|
68
|
+
curl -fsSL https://static.rust-lang.org/dist/channel-rust-stable.toml | awk '/^\[pkg\.rust\]/{getline; print}'
|
|
69
|
+
# Alpine Linux stable (use it as 3.NN)
|
|
70
|
+
curl -fsSL https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/x86_64/latest-releases.yaml | awk '/version:/{print $2; exit}'
|
|
71
|
+
# Debian stable codename
|
|
72
|
+
curl -fsSL https://deb.debian.org/debian/dists/stable/Release | awk '/^Codename:/{print $2}'
|
|
73
|
+
# Node.js: the newest LTS release (major and full version)
|
|
74
|
+
curl -fsSL https://nodejs.org/dist/index.json | jq -r '[.[] | select(.lts != false)][0].version'
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
To find the newest tag of an image, list its tags and keep only the stable
|
|
78
|
+
ones that have the shape you need. For example, the newest NATS 2.15 on Alpine:
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
podman search --list-tags --limit 10000 docker.io/library/nats \
|
|
82
|
+
| awk 'NR > 1 {print $2}' \
|
|
83
|
+
| grep -E '^2\.15\.[0-9]+-alpine3\.[0-9]+$' \
|
|
84
|
+
| sort -V | tail -1
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Write the `grep -E` pattern with digits only (`[0-9]+`), so release
|
|
88
|
+
candidates and betas (`19rc2`, `-beta`) never match. Before editing a file,
|
|
89
|
+
check that every tag you are about to write appears in this list.
|
|
90
|
+
|
|
91
|
+
To update a digest, take the multi-arch digest of the new tag:
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
skopeo inspect --format '{{.Digest}}' docker://docker.io/library/nats:2.15.3-alpine3.22
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## 3. Upgrade each image
|
|
98
|
+
|
|
99
|
+
**Always write the full image name:** `docker.io/library/<image>` for Docker
|
|
100
|
+
Official Images, `docker.io/<namespace>/<image>` for other Docker Hub images,
|
|
101
|
+
and the registry's own name elsewhere (`quay.io/podman/stable`,
|
|
102
|
+
`ghcr.io/<org>/<image>`). Rewrite short names such as `FROM alpine:3.24` to
|
|
103
|
+
`FROM docker.io/library/alpine:3.24`, keeping the version (the upgrade is a
|
|
104
|
+
separate commit), unless the repository's README, contributing guide or a
|
|
105
|
+
comment in the file asks for short names; then leave them and say so in the
|
|
106
|
+
report. Prefer Docker Official Images and images maintained by the upstream
|
|
107
|
+
project (`docker.io/natsio/nats-box`, `quay.io/skopeo/stable`); if a file uses
|
|
108
|
+
a third-party image for something an official image provides, report it and ask
|
|
109
|
+
before replacing it.
|
|
110
|
+
|
|
111
|
+
**Never use a floating tag.** A tag is floating when it lacks any part of its
|
|
112
|
+
shape in the table below: `latest`, `lts`, `stable`, `mainline`, `edge`,
|
|
113
|
+
`alpine`, `slim`, `rust:slim-trixie` (no version), `postgres:19-alpine3.24`
|
|
114
|
+
(no minor) and `nginx:1.30-alpine3.24` (no patch) are all floating;
|
|
115
|
+
`rust:1.100-slim-trixie` and `alpine:3.24` are complete. Pin both the software
|
|
116
|
+
version and the distro version wherever the image publishes distro variants.
|
|
117
|
+
If a reference pins a digest, update the tag and the digest together; do not
|
|
118
|
+
add digests where there are none (workflow images are the exception, see
|
|
119
|
+
section 1).
|
|
120
|
+
|
|
121
|
+
Each official image names its tags differently. Use exactly these shapes:
|
|
122
|
+
|
|
123
|
+
| Role | Image | Tag shape | Example |
|
|
124
|
+
| ------------------ | ---------------------------- | ----------------------------------------- | ------------------------- |
|
|
125
|
+
| Base OS | `docker.io/library/alpine` | `3.NN` | `alpine:3.24` |
|
|
126
|
+
| Base OS | `docker.io/library/debian` | `<codename>-slim` | `debian:trixie-slim` |
|
|
127
|
+
| Toolchain | `docker.io/library/rust` | `1.NN-alpine3.NN`, `1.NN-slim-<codename>` | `rust:1.100-slim-trixie` |
|
|
128
|
+
| Toolchain | `docker.io/library/node` | `NN-alpine3.NN`, `NN-<codename>-slim` | `node:26-trixie-slim` |
|
|
129
|
+
| Stateless service | `docker.io/library/nginx` | `X.Y.Z-alpine3.NN`, `X.Y.Z-<codename>` | `nginx:1.30.7-alpine3.24` |
|
|
130
|
+
| Stateless tool | `docker.io/natsio/nats-box` | `X.Y.Z` | `natsio/nats-box:0.20.2` |
|
|
131
|
+
| Database or broker | `docker.io/library/postgres` | `X.Y-alpine3.NN`, `X.Y-<codename>` | `postgres:19.0-trixie` |
|
|
132
|
+
| Database or broker | `docker.io/library/nats` | `X.Y.Z-alpine3.NN` | `nats:2.15.3-alpine3.22` |
|
|
133
|
+
|
|
134
|
+
The examples omit the `docker.io/library/` prefix only to fit the table. Note
|
|
135
|
+
that `node` puts `slim` after the codename and `rust` puts it before, and that
|
|
136
|
+
`postgres` has no `slim` at all. Not every image publishes the newest Alpine
|
|
137
|
+
version: at the time of writing, `nats` 2.15 has only `alpine3.22` tags, so
|
|
138
|
+
check the tag list (section 2) instead of assuming `alpine3.24`. For an image
|
|
139
|
+
not in the table, list its tags and copy the shape of the tag it already uses.
|
|
140
|
+
|
|
141
|
+
### Toolchains (Rust, Node.js) and base OS images
|
|
142
|
+
|
|
143
|
+
- **Rust:** Use the same `1.NN` as `RUST_VERSION` in CI, without the patch
|
|
144
|
+
version. If CI is behind the latest stable, bump both; if CI does not pin
|
|
145
|
+
Rust, use the latest stable. If the project no longer compiles on the new
|
|
146
|
+
Rust, keep the old version and follow `references/ci-audit.md`
|
|
147
|
+
("Toolchains") to find which release of the failing crate fixes it.
|
|
148
|
+
- **Node.js:** Use the Node.js major that CI uses (`node-version:`), or the one
|
|
149
|
+
in `.nvmrc`, `.node-version`, or `engines.node` or `devEngines` in
|
|
150
|
+
`package.json`. If none of them pins it, use the newest LTS major. A new major
|
|
151
|
+
goes in its own commit, and the project's Node.js checks (`check`, `lint`,
|
|
152
|
+
`test` and `build`, as CI runs them) must pass, as well as the image build.
|
|
153
|
+
- **Alpine Linux and Debian:** In a multi-stage Containerfile, every stage that
|
|
154
|
+
builds a binary and the stage that runs it must use the same Alpine version
|
|
155
|
+
or Debian codename: a binary built against a newer musl or glibc does not
|
|
156
|
+
run on an older one. Use the newest version that every image in those stages
|
|
157
|
+
publishes. When moving to a new Debian codename, check that every package in
|
|
158
|
+
`apt-get install` still exists in it
|
|
159
|
+
(`https://packages.debian.org/<codename>/<package>`).
|
|
160
|
+
|
|
161
|
+
### Stateless services and tools (nginx, caddy, nats-box, ...)
|
|
162
|
+
|
|
163
|
+
Upgrade to the newest release in the same major, pinned to the newest distro
|
|
164
|
+
version published for it (`nginx:1.30.7-alpine3.24`). Stop and ask before
|
|
165
|
+
changing the major version.
|
|
166
|
+
|
|
167
|
+
For nginx, an even second number (`1.30`) is the stable branch and an odd one
|
|
168
|
+
(`1.31`) is mainline. Stay on the branch the file uses: upgrade `1.30.x` only
|
|
169
|
+
to a newer `1.30.x` (`grep -E '^1\.30\.[0-9]+-alpine3\.[0-9]+$'`), or to the
|
|
170
|
+
next even branch once it exists. Never move from an even branch to an odd one.
|
|
171
|
+
|
|
172
|
+
### Databases and brokers (postgres, nats, redis, valkey, mariadb, ...)
|
|
173
|
+
|
|
174
|
+
These images either deploy the service or stand in for the production one in
|
|
175
|
+
development and tests. Their version has to match production, and changing
|
|
176
|
+
their distro can corrupt existing data: PostgreSQL text indexes depend on the
|
|
177
|
+
collation of the distro's C library and ICU, and a different glibc, musl or
|
|
178
|
+
ICU version can make index scans miss rows or accept duplicate keys.
|
|
179
|
+
|
|
180
|
+
If the image uses a floating tag (`postgres:19-alpine`), first pin it to the
|
|
181
|
+
exact tag it points to today: the tag with the same digest. Compare the
|
|
182
|
+
floating tag's digest with the tags of its series, newest first, and stop at
|
|
183
|
+
the first match:
|
|
184
|
+
|
|
185
|
+
```sh
|
|
186
|
+
want=$(skopeo inspect --format '{{.Digest}}' docker://docker.io/library/postgres:19-alpine)
|
|
187
|
+
podman search --list-tags --limit 10000 docker.io/library/postgres \
|
|
188
|
+
| awk 'NR > 1 {print $2}' \
|
|
189
|
+
| grep -E '^19\.[0-9]+-alpine3\.[0-9]+$' \
|
|
190
|
+
| sort -rV \
|
|
191
|
+
| while read -r t; do
|
|
192
|
+
if [ "$(skopeo inspect --format '{{.Digest}}' "docker://docker.io/library/postgres:$t")" = "$want" ]; then
|
|
193
|
+
echo "$t"
|
|
194
|
+
break
|
|
195
|
+
fi
|
|
196
|
+
done
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Adapt the `grep -E` pattern to the floating tag. For a Debian-based tag such
|
|
200
|
+
as `postgres:19` use `'^19\.[0-9]+-[a-z]+$'` (codename variants like
|
|
201
|
+
`19.0-trixie`); if the major is unknown, as with `postgres:latest`, use
|
|
202
|
+
`'^[0-9]+\.[0-9]+-[a-z]+$'`. Use these two patterns only for Debian-based
|
|
203
|
+
tags: for an Alpine tag keep the `-alpine3\.[0-9]+` pattern above, or the loop
|
|
204
|
+
prints `19.0-alpine`, which is still floating. Within a Debian tag, other
|
|
205
|
+
codenames the pattern lets through do no harm, because only a tag with the
|
|
206
|
+
same digest is printed.
|
|
207
|
+
|
|
208
|
+
If it prints a tag, pinning to it changes nothing that runs, so it needs no
|
|
209
|
+
production check. Commit it on its own with `pin` in the subject, not
|
|
210
|
+
`upgrade`. If it prints nothing, no tag matches: stop and ask, and do not pin
|
|
211
|
+
to the newest tag, because that would change the version that runs. Upgrade a
|
|
212
|
+
pinned image, if at all, with the steps below.
|
|
213
|
+
|
|
214
|
+
1. Find the version that runs in production: search the repository's deployment
|
|
215
|
+
files (Ansible, NixOS, Terraform, Helm, Kustomize, production Compose and
|
|
216
|
+
`.env` files), the database and broker containers its CI starts (`services:`
|
|
217
|
+
in `.github/workflows/` and `.forgejo/workflows/`), and its documentation. If
|
|
218
|
+
the repository does not say, stop and ask which version runs in production.
|
|
219
|
+
2. Upgrade only to that version, or to the newest patch release of the same
|
|
220
|
+
series. The series depends on the tag shape: for `X.Y.Z` images such as
|
|
221
|
+
`nats`, the series is `X.Y` and patches change `Z` (`2.15.1` to `2.15.3`);
|
|
222
|
+
for `X.Y` images such as `postgres`, the series is `X` and patches change
|
|
223
|
+
`Y` (`17.11` to `17.12`).
|
|
224
|
+
3. Keep the distro exactly as it is (`17.12-bookworm` stays on `bookworm`,
|
|
225
|
+
`17.12-alpine3.21` stays on `alpine3.21`), even when the rest of the
|
|
226
|
+
repository moves to a newer Debian or Alpine. Changing it, or switching
|
|
227
|
+
between Debian and Alpine, needs the user's confirmation and a planned
|
|
228
|
+
`REINDEX`.
|
|
229
|
+
|
|
230
|
+
## 4. Verify
|
|
231
|
+
|
|
232
|
+
Before each commit, build every Containerfile you changed. These commands run
|
|
233
|
+
from the repository root, which is where `COPY` paths usually start; if a
|
|
234
|
+
Containerfile's `COPY` paths start elsewhere, build that one from there.
|
|
235
|
+
|
|
236
|
+
```sh
|
|
237
|
+
git diff --name-only HEAD \
|
|
238
|
+
| grep -E '(^|/)(Dockerfile|Containerfile)([.-][^/]*)?$|\.(Dockerfile|Containerfile)$' \
|
|
239
|
+
| while read -r f; do
|
|
240
|
+
log="<scratch>/build-$(echo "$f" | tr / _).log"
|
|
241
|
+
if podman build -f "$f" -t repo-maintenance-check . > "$log" 2>&1 < /dev/null; then
|
|
242
|
+
echo "$f: built"
|
|
243
|
+
else
|
|
244
|
+
echo "$f: FAILED, see $log"
|
|
245
|
+
fi
|
|
246
|
+
podman image rm -f repo-maintenance-check > /dev/null 2>&1
|
|
247
|
+
done
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
A failing `apk add` or `apt-get install` means a package was renamed or
|
|
251
|
+
removed in the new release: find its new name and fix it in the same commit.
|
|
252
|
+
If a build needs secrets or services that are not available locally, list it in
|
|
253
|
+
the report instead.
|
|
254
|
+
|
|
255
|
+
Check that every Compose file you changed is still valid and that its images
|
|
256
|
+
can be pulled (`pull` skips the services that have `build:`):
|
|
257
|
+
|
|
258
|
+
```sh
|
|
259
|
+
git diff --name-only HEAD \
|
|
260
|
+
| grep -E '(^|/)(docker-)?compose([.-][^/]*)?\.ya?ml$' \
|
|
261
|
+
| while read -r f; do
|
|
262
|
+
podman compose -f "$f" config -q < /dev/null \
|
|
263
|
+
&& podman compose -f "$f" pull < /dev/null \
|
|
264
|
+
&& echo "$f: valid, images pulled"
|
|
265
|
+
done
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## 5. Commit
|
|
269
|
+
|
|
270
|
+
Follow the scope the repository's history uses for these commits
|
|
271
|
+
(`git log --format=%s -- '*Dockerfile*' '*Containerfile*' '*compose*.y*ml'`),
|
|
272
|
+
usually `build(docker):`. One commit per kind of change, naming every version
|
|
273
|
+
that changed:
|
|
274
|
+
|
|
275
|
+
```text
|
|
276
|
+
build(docker): upgrade Rust to v1.100
|
|
277
|
+
build(docker): upgrade Alpine Linux to v3.24 / Rust to v1.100
|
|
278
|
+
build(docker): upgrade Debian to Trixie
|
|
279
|
+
build(docker): upgrade Node.js to v26
|
|
280
|
+
build(docker): upgrade nginx to v1.30.7
|
|
281
|
+
build(docker): pin Postgres to v19.0
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Put the switch to full image names in its own commit
|
|
285
|
+
(`build(docker): use fully qualified image names`) before the upgrades. In the
|
|
286
|
+
body, mention packages that had to be renamed and anything that changed for
|
|
287
|
+
the image at runtime.
|