All checks were successful
check / check (push) Successful in 59s
script/check ran script/test, script/lint and script/fmt-check. Since linting moved into Docker, script/lint is a build of Dockerfile.lint, which runs `prettier --check .` as a build step — so make check checked formatting twice over the same tree: once in the container and once on the host. script/precommit had the same pair. Drop the script/fmt-check call from both. The container keeps the check, because a successful Dockerfile.lint build is what CI treats as proof of a clean tree, and it is the stronger of the two verdicts: its prettier is digest-pinned and installed under --frozen-lockfile, while the host's is whatever the working tree happens to have. The pre-commit hook is unchanged in what it catches — script/lint still fails a badly formatted tree, and therefore the commit. script/fmt-check survives as a standalone entrypoint, as REPO_POLICIES.md requires, for asking the formatting question by itself without docker. Its verdict cannot drift from the container's: prettier is pinned to an exact version, installed from yarn.lock in both places, and reads .gitignore as its default ignore file, which is why .dockerignore keeps .gitignore in the build context. The count is asserted rather than promised. test/packaging/lint-once.test.ts walks the invocation graph from each entrypoint — through the Makefile shims, the script/ calls, the package.json scripts and the docker build into Dockerfile.lint's RUN steps — and counts prettier invocations: one per make check, one per script/precommit, and one each for make lint and make fmt-check alone, so neither can become a no-op that satisfies the count trivially. The walk also asserts which nodes it reached, so a restructure that defeats the resolver fails the test instead of quietly counting zero. Observed: 2 prettier invocations per make check before, 1 after.
27 lines
939 B
Bash
Executable File
27 lines
939 B
Bash
Executable File
#!/bin/sh
|
|
# script/precommit: run by the git pre-commit hook; fails the commit if
|
|
# checks fail. Our own extension to scripts-to-rule-them-all.
|
|
#
|
|
# Runs lint but deliberately NOT the tests, so the TDD red-phase commit
|
|
# (failing tests, no implementation yet) can land. CI runs
|
|
# script/cibuild, which builds both images and so catches any branch
|
|
# that ships red.
|
|
#
|
|
# The formatting check is still enforced here, because script/lint is a
|
|
# build of Dockerfile.lint and that runs `prettier --check .` as a build
|
|
# step: a badly formatted tree fails this hook, and therefore the
|
|
# commit. Calling script/fmt-check as well would only run prettier a
|
|
# second time over the same tree for the same verdict.
|
|
#
|
|
# script/lint is a docker build (Dockerfile.lint); docker is required to
|
|
# commit, which is the point of linting one way, everywhere.
|
|
set -eu
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
|
|
|
|
main() {
|
|
"$SCRIPT_DIR/lint"
|
|
}
|
|
|
|
main "$@"
|