The hand-written port of antigua's router role predates the installer and the web UI; the router is configured through settings.json now. Its flake outputs (the home configuration, installer-home, the home check) go too. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeFqV9dZrK6nipHkPfyM4F
59 lines
2.1 KiB
Bash
59 lines
2.1 KiB
Bash
# The quick checks: no VM boots. Catches what most failed runs of the VM tests
|
|
# were about (Go and Nix errors, shellcheck, type errors in the test scripts,
|
|
# assertions). Evaluating NixOS is the cost: about a minute for the default.
|
|
# router-fast Go checks; the installer and a settings-built router
|
|
# (via the release) build
|
|
# router-fast --drivers also build every VM test's driver (type-checks the
|
|
# test scripts, builds the VMs' systems): minutes
|
|
# router-fast --all also every flake check without VMs (assertions,
|
|
# lib) and `nix flake check --no-build`: many minutes
|
|
root=$(git rev-parse --show-toplevel)
|
|
cd "$root"
|
|
drivers=0 all=0
|
|
case ${1:-} in
|
|
--drivers) drivers=1 ;;
|
|
--all) drivers=1 all=1 ;;
|
|
"") ;;
|
|
*) echo "usage: router-fast [--drivers | --all]" >&2; exit 2 ;;
|
|
esac
|
|
start=$SECONDS
|
|
last=$SECONDS
|
|
step() {
|
|
printf '\n\033[1m== %s\033[0m (previous step: %ds)\n' "$*" $((SECONDS - last))
|
|
last=$SECONDS
|
|
}
|
|
|
|
step "web UI: gofmt, vet, tests"
|
|
(
|
|
cd pkgs/router-webui
|
|
if [ -n "$(gofmt -l .)" ]; then echo "gofmt wants to change:"; gofmt -l .; exit 1; fi
|
|
go vet ./...
|
|
go test ./...
|
|
)
|
|
|
|
# New files must be known to git for a flake to see them.
|
|
untracked=$(git ls-files --others --exclude-standard)
|
|
if [ -n "$untracked" ]; then
|
|
printf '\nwarning: not known to git, so the flake ignores them (git add):\n%s\n' "$untracked"
|
|
fi
|
|
|
|
step "systems build (shellcheck of the scripts, units, firewall rules)"
|
|
nix build --no-link --max-jobs 1 \
|
|
.#nixosConfigurations.installer.config.system.build.toplevel \
|
|
.#release
|
|
|
|
if [ "$drivers" = 1 ]; then
|
|
step "VM test drivers build (type check)"
|
|
for t in basic pppoe vlans onestick rollback dns installer apply setup update image wireguard; do
|
|
echo " $t"
|
|
nix build --no-link --max-jobs 1 ".#checks.x86_64-linux.$t.driver"
|
|
done
|
|
fi
|
|
if [ "$all" = 1 ]; then
|
|
step "the checks that need no VM"
|
|
nix build --no-link --max-jobs 1 .#checks.x86_64-linux.{lib,assertions,example}
|
|
step "everything evaluates"
|
|
nix flake check --no-build
|
|
fi
|
|
printf '\n\033[1mok\033[0m (%ds)\n' $((SECONDS - start))
|