halkyon/tool/check.sh

45 lines
1.5 KiB
Shell
Raw Normal View History

#!/usr/bin/env bash
# The checks every push has to pass: formatting, static analysis (infos are fatal too), and
# the server's and the app's tests. The pre-push hook runs this script, and a CI runner can
# run it later.
#
# Install the hook in a fresh clone: ln -s ../../tool/check.sh .git/hooks/pre-push
# Skip it for one push: git push --no-verify
#
# It checks the working tree, so uncommitted changes count as well.
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
if ! git diff --quiet HEAD; then
echo 'Note: the working tree has uncommitted changes; they are checked too.'
fi
# Our own Dart files. Generated code is left out: the client package as a whole, and the
# server's generated sources and test tools. (A loop instead of mapfile: macOS ships bash 3.)
own=()
while IFS= read -r file; do own+=("$file"); done < <(
git ls-files '*.dart' |
grep -v -E '^halkyon_learn_client/|/lib/src/generated/|/serverpod_test_tools\.dart$'
)
echo '▸ Formatting'
if [ ${#own[@]} -gt 0 ]; then
dart format --output=none --set-exit-if-changed "${own[@]}"
fi
echo '▸ Analysis'
dart analyze --fatal-infos
echo '▸ Server tests'
if git ls-files 'halkyon_learn_server/test/*_test.dart' | grep -q .; then
(cd halkyon_learn_server && dart test)
else
echo 'No server tests yet.'
fi
echo '▸ App tests'
test(app): studysets synced against a running server The first tests that need serverpod start running (ADR 0001, rule 9: the client's and the server's sync engines can't share one process), tagged requires-server: tool/check.sh skips them, flutter test -t requires-server runs them. Every device is its own client and local database with the app's real gateway and repository, and syncs only when a test says so. They state: two devices of one person end up with the same studysets; a deleted studyset leaves the other devices, and its payload is blank on the server, checked with SQL against the development database because the engine keeps deleted rows; a studyset written into another person's space never reaches them; claiming another person's space shows none of their studysets, since the server sends only the spaces the signed-in person has access to. As written here, the forgery test also expects the server to refuse and log the write, and the SQL checks connect over TCP; the first run against the server corrected both (see the commit "the sync tests pass against the running server"). They live in the app package: the server's Docker build resolves its dependencies with only the server package present, so a dev dependency on the client package would break it. They never initialize a Flutter test binding, which would replace real HTTP with a mock. Without a server they fail at sign-in with "connection refused". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-09-30 12:15:30 +02:00
# The sync tests need `serverpod start` running; run them by hand with
# `flutter test -t requires-server` in the app package.
(cd halkyon_learn_flutter && flutter test -x requires-server)
echo '✓ All checks passed.'