Files
gitdan-actions/.gitea/workflows/ci.yaml
T
claude 3f97d3d1e7
CI / shellcheck + selftests (pull_request) Failing after 1m36s
fix(selftest): make the two compiler-backed suites survive a CI runner
The new gate's first run went red on both suites that drive a real Cargo.
Neither failure was a defect in what they test; both were assumptions about
the machine, which had only ever been a dev box with a nightly installed and
no colour forcing. Fixed here rather than waived — turning a gate on is what
obliges fixing what it finds.

COLOUR. Every assertion in restore-mtimes-selftest.sh, and one in
hardlink-clone-selftest.sh, reads cargo's own words out of a build log
(`Compiling libdep`, `Fresh probe`). gitdan-ci's runner image forces colour, so
cargo wrote `Compiling\e[0m libdep` into the log and `grep -q "Compiling
libdep"` stopped matching. The suite then reported the opposite of what
happened — the failure printed the log, and the log plainly said `Compiling
libdep`. Both suites now pin CARGO_TERM_COLOR=never, which is the format their
assertions are written against.

Red-proven: with the export removed and CARGO_TERM_COLOR=always,
restore-mtimes-selftest reproduces the CI failure verbatim ("expected to find:
Compiling libdep"); with it, 14/14 pass under the same forced colour.

THE NIGHTLY PROBE ASKED THE WRONG QUESTION. `cargo +nightly -V` answers "did a
cargo proxy called with +nightly exit 0", which is not "will this build have
checksum freshness": `-V` short-circuits before `-Z` is validated at all. So
the probe said "on" on a runner where the flag was not in effect, and the
suite asserted the checksum-freshness mutation family against a build that
never had it — failing in the CONTROL, where a failure reads as "the hazard is
gone" rather than "the toolchain is wrong". It now probes the capability:
`cargo +nightly -Z checksum-freshness locate-project`, the narrowest command
that actually parses the flag. It rejects the stable channel and an unknown
flag name alike, needs no network and builds nothing.

Red-proven: the old channel probe, pointed at a cargo without the flag,
reproduces the CI failure exactly.

AND THE OFF PATH DID NOT WORK EITHER. The suite's header claimed that without
checksum freshness "the test still covers the build/ and *.d families". It did
not: the final scenario backdates the source to 2001 and asserts the rebuild
is not Fresh, which is checksum-freshness-only reasoning. Under Cargo's
ordinary mtime freshness a 2001 source IS older than the artifact and Fresh is
the correct answer, so the scenario asserted a bug. It is now gated on the
mode and skipped loudly, like the control's dep-* assertion already was: 5
assertions with a nightly, 3 without.

CI installs a nightly as well as stable (nightly first, so stable stays the
default) — that hazard is the one this whole scheme exists to close, and a CI
that skips it is checking the cheap half.
2026-08-26 12:46:03 -05:00

96 lines
4.6 KiB
YAML

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
# Spelled out only to keep `ready_for_review` in the list — naming any type
# replaces the whole default set, so the other three have to be restated.
# It is inert on this instance (draft state here is the `WIP:` title
# prefix, so un-drafting is a title edit and raises no
# `ready_for_review` action) and costs nothing.
#
# The consequence, which is the part that bites: the `if:` guard below is
# evaluated when a run is CREATED, and un-drafting creates no run. A PR
# opened as a draft keeps its skip decision until something else produces
# one. Push an empty commit after un-WIP'ing.
types: [opened, synchronize, reopened, ready_for_review]
# gitdan-ci runs four repos' CI on two capacity slots, and the compiler-backed
# suites below are multi-minute. A superseded run costs a slot in front of
# somebody's build, so drop it.
#
# `push` groups on `github.sha` rather than `github.ref`: a constant per-branch
# group is what let this Gitea (1.26.0) cancel two of daniel/gitdan's merge
# runs outright while `cancel-in-progress` was gated away from `push` entirely
# — see the long note in that repo's ci.yaml for the evidence. Giving every
# commit its own group leaves that behaviour nothing to act on.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }}
cancel-in-progress: true
jobs:
selftest:
name: shellcheck + selftests
# Two clauses, both load-bearing. The second skips draft PRs: Gitea sets
# draft:true when the title starts with `WIP:`, so work-in-progress pushes
# cost the shared runner nothing until the PR is un-WIP'd. The first is
# what keeps that from also skipping pushes to `main` — a `push` event has
# no `pull_request` context, so `github.event.pull_request.draft` is empty
# there and the negation alone would be unreliable. Never drop it.
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
runs-on: ubuntu-latest
timeout-minutes: 20
# Deliberately no `container.volumes:` entry, unlike every repo that
# CONSUMES this action. The suites below build throwaway workspaces under
# `mktemp -d` and want a cold target dir every time — a persistent cache
# would make "did this run rebuild?" unanswerable, which is the question
# restore-mtimes-selftest.sh exists to ask. So this job takes no share of
# the shared CI cache disk budget.
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install shellcheck
uses: taiki-e/install-action@v2
with:
tool: shellcheck
# `hardlink-clone-selftest.sh` and `restore-mtimes-selftest.sh` drive a
# real Cargo against a real scratch workspace — they are the only things
# here that verify the hardlink-aliasing and mtime-freshness behaviour
# against the compiler rather than against a fixture, and selftest.sh's
# own header says `--fast` is for iterating, not for signing off a
# change. So CI installs a toolchain and runs the full set.
#
# The scratch workspaces use path dependencies only, so nothing here
# reaches crates.io.
# Nightly first, stable second, so stable ends up the default and
# nightly is only reachable through an explicit `+nightly`.
#
# Nightly is not optional here. `hardlink-clone-selftest.sh` gates its
# two strongest assertions on `-Z checksum-freshness` — the mode where
# Cargo's dep-info file carries per-source checksums and is rewritten in
# place, which is the mutation that turns a hardlink clone into SILENT
# stale-artifact reuse rather than a slow build. Without a nightly the
# suite still runs, and skips exactly the hazard this whole scheme exists
# to close.
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
# Every script, including the suites themselves. `-x` follows the
# `. cache-lib.sh` each one sources, which is where most of the logic
# being checked actually lives; without it shellcheck reports SC1091 and
# analyses each file with a hole in it.
- name: shellcheck
run: shellcheck -x --source-path=scripts scripts/*.sh
# One command, not six: selftest.sh is the entry point a developer runs,
# so a suite added there is gated here without a matching edit in this
# file.
- name: Selftests
run: bash scripts/selftest.sh