check / check (push) Failing after 3s
script/fmt and script/fmt-check run prettier over every Markdown file again, next to gofmt. prettier is pinned by hash through package.json and yarn.lock, copied from the prompts repo with .prettierrc and .prettierignore, and is never installed on a host: a new prettier stage of the Dockerfile installs it into a digest-pinned node image, and both scripts build that stage and run it with the repository mounted. CI checks the Markdown in a markdown stage that the build stage waits on. Because make fmt-check now runs docker, the Dockerfile runs gofmt directly in its lint stage instead. All Markdown is reformatted. Model: opus-5-5
23 lines
793 B
Bash
Executable File
23 lines
793 B
Bash
Executable File
#!/bin/sh
|
|
# script/fmt: format all files (writes): the Go sources with gofmt, the
|
|
# Markdown with prettier. prettier is never installed on the host: it
|
|
# runs from the Dockerfile's prettier stage with the repository mounted,
|
|
# as the calling user so the files it rewrites keep their owner. The tag
|
|
# makes each build replace the previous image instead of leaving another
|
|
# one behind.
|
|
set -eu
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
|
|
ROOT="$(cd "$SCRIPT_DIR/.." && pwd -P)"
|
|
|
|
main() {
|
|
cd "$ROOT"
|
|
gofmt -s -w .
|
|
image="$("$SCRIPT_DIR/projectname")-prettier"
|
|
docker build -q --target prettier -t "$image" . >/dev/null
|
|
docker run --rm --user "$(id -u):$(id -g)" -v "$ROOT:/src" "$image" \
|
|
prettier --write '**/*.md' --tab-width 4 --prose-wrap always
|
|
}
|
|
|
|
main "$@"
|