mirror of
https://github.com/docker/docs.git
synced 2026-10-23 18:09:02 +03:00
API generation introduced in #26048 added roughly five minutes to site builds: median successful main-branch build-workflow duration rose from 4m 05s to 8m 48s across September 3–25. The pre-build command took 4m 41s–4m 53s in each of four jobs on the merge commit. Vendor the generated presentation model in `data/api-reference.json`, mark it as generated, and let Docker, Netlify, and local Hugo builds consume it directly. Keep the existing rendered-output checks. Move generator tests, strict spec validation, and a byte-for-byte regeneration check into `docker buildx bake validate-api-reference`, inheriting the shared Docker base stage. The target uses the pinned Vacuum release binary with Dockerfile ADD checksum verification and archive extraction instead of compiling Vacuum from source. The existing build workflow runs this target alongside the other validation matrix entries. Only this matrix entry is advisory; its failures do not block site builds or deployment. Validated locally with the Docker target, rejection of deliberately stale data, repeatable generation across directories, a production Hugo build and verification of 453 API HTML/Markdown page pairs, workflow syntax checks, and scoped documentation lint. The prebuilt-binary CI check passed in 1m 40s, down from 5m 15s with source compilation. Remote layer-cache settings were subsequently removed; local Go cache mounts remain. Generated by Codex
32 lines
1.2 KiB
Bash
Executable File
32 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)
|
|
cd "$ROOT"
|
|
mkdir -p "$ROOT/tmp/api-reference/reports"
|
|
export GOWORK=off
|
|
api_docs() {
|
|
(cd hack/api-docs && go run . "$@" "$ROOT")
|
|
}
|
|
policy() {
|
|
local sources
|
|
sources=$(api_docs sources)
|
|
while IFS=$'\t' read -r api source; do
|
|
vacuum lint --no-update-check --remote=false --ruleset hack/api-docs/validation/rules.yaml --fail-severity error --min-score 0 --no-banner --no-style --details "$source" > "tmp/api-reference/reports/$api-vacuum.txt" 2>&1 || {
|
|
cat "tmp/api-reference/reports/$api-vacuum.txt"; return 1;
|
|
}
|
|
done <<< "$sources"
|
|
}
|
|
case "${1:-build}" in
|
|
check|generate) policy; api_docs "$1" ;;
|
|
test) (cd hack/api-docs && go test ./...) ;;
|
|
build|serve)
|
|
hugo --destination tmp/api-reference/site --baseURL "${DOCS_URL:-http://localhost:1314}" --cleanDestinationDir
|
|
node hack/flatten-and-resolve.js tmp/api-reference/site
|
|
node hack/api-docs/verify-output.mjs tmp/api-reference/site
|
|
if [[ "${1:-build}" == serve ]]; then
|
|
exec python3 -m http.server "${DOCS_PORT:-1314}" --bind 127.0.0.1 --directory tmp/api-reference/site
|
|
fi
|
|
;;
|
|
*) printf '%s\n' 'Usage: run.sh check|generate|test|build|serve' >&2; exit 2 ;;
|
|
esac
|