Pushing from a worktree failed before any test ran: "Because halkyon_learn_flutter requires the Flutter SDK, version solving failed." Git hands a hook in a worktree an absolute GIT_DIR, which overrides the -C that pub runs git with on its git dependencies, so pub judged the workspace's resolution stale and resolved it with dart alone. The checks now clear git's variables first; git finds the repository from the folder it runs in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
62 lines
2.4 KiB
Shell
Executable file
62 lines
2.4 KiB
Shell
Executable file
#!/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 so does CI on
|
|
# every push (.forgejo/workflows/ci.yaml).
|
|
#
|
|
# 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)"
|
|
|
|
# As a hook in a worktree, git hands this its GIT_DIR, an absolute path to the worktree's
|
|
# folder in the main repository. pub runs git with -C on its git dependencies' caches, which
|
|
# GIT_DIR overrides, so it judged the workspace's resolution stale, resolved it with dart
|
|
# alone and failed ("halkyon_learn_flutter requires the Flutter SDK"; 2026-10-16). Nothing
|
|
# below needs them: git finds the repository from the folder it runs in.
|
|
unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_COMMON_DIR GIT_OBJECT_DIRECTORY GIT_PREFIX
|
|
|
|
# As the pre-push hook, first: commits going to main must be signed as deploying it requires
|
|
# (tool/check_signatures.sh), which takes a moment, where the rest takes minutes.
|
|
if [ "$(basename "$0")" = pre-push ]; then
|
|
tool/check_signatures.sh "$@"
|
|
fi
|
|
|
|
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, the
|
|
# server's generated sources and test tools, and the app's localizations (gen-l10n). (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$|/lib/l10n/app_localizations'
|
|
)
|
|
|
|
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 '▸ Curator tests'
|
|
(cd halkyon_learn_curator && dart test)
|
|
|
|
echo '▸ App tests'
|
|
# 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.'
|