#!/bin/sh
# script/lint: run the lint. This Hugo site has no dedicated linter, so
# the lint gate is a clean build that surfaces broken internal links and
# template path problems -- but where it runs is not negotiable: every
# lint run happens inside a Docker container, so this script does
# nothing except build the `lint` stage of Dockerfile.lint. The check is
# a build step there, so a successful build is a clean lint. There is
# deliberately no host fallback and no "already inside a container?"
# branch: either would be a host lint path wearing a disguise.
#
# Dockerfile.lint requires the CHECK_EPOCH build argument, generated
# here exactly as script/cibuild generates it -- see that script for why
# the check layer must not be allowed to cache, and why the value is
# built in an assignment rather than inline.
set -eu

ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"

main() {
    cd "$ROOT"
    epoch="$(date +%s%N)$$"
    docker build -f Dockerfile.lint --target lint \
        --build-arg CHECK_EPOCH="$epoch" .
}

main "$@"
