#!/bin/sh
# script/cibuild: run the CI build. The Dockerfile runs script/check
# (via make check), so a successful build implies all checks pass.
# Generic: needs no adaptation. The Gitea workflow runs this on push.
set -eu

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

# A bare "docker build ." serves the check layers straight from the Docker
# layer cache when the tree has not changed, so the build exits 0 without ever
# running the checks. CHECK_EPOCH changes on every invocation and the
# Dockerfile declares it above the checks in every stage that runs one, which
# forces them to execute while leaving the dependency layers cached.
main() {
    cd "$ROOT"
    docker build --build-arg CHECK_EPOCH="$(date +%s)" .
}

main "$@"
