#!/bin/sh # script/cibuild: run the CI build. The Dockerfile runs `make check`, # so a successful build implies all checks pass. The Gitea workflow # runs this on push. # # That implication only holds because of CHECK_EPOCH. Docker keys the # `RUN make check` layer on content, so on an unchanged tree it is # served from cache: the checks never execute and the build still exits # 0. Passing a value that differs on every invocation invalidates that # layer and everything below it, while the script/bootstrap toolchain # layer above it keeps caching. set -eu ROOT="$(cd "$(dirname "$0")/.." && pwd -P)" main() { cd "$ROOT" # Assigned to a variable rather than substituted inline in the # argument list: a command substitution that fails inside an # argument does not trip `set -e`, so the inline form would quietly # pass an empty string and restore the cached false green. As the # whole of an assignment its exit status is the command's, so # `set -e` catches it. `%N` keeps two invocations within the same # second distinct; busybox date silently drops `%N` and still exits # 0, so `$$` is appended to cover that degradation. epoch="$(date +%s%N)$$" docker build --build-arg CHECK_EPOCH="$epoch" . } main "$@"