build(check): the checks compare the generated code, as CI did alone
On 23 Oct a push went red in CI because an endpoint's changed comment hadn't been generated into the module's client: only CI compared the committed generated code with the generator's output. tool/check.dart now runs every server's generation (Melos' `generate`, about 15 s) after fetching the packages and fails, naming the files, where the working tree's generated code changed by it; the files stay written anew, to be committed. It compares the files that differ from the committed ones before and after by their content, so uncommitted changes count as they do everywhere else in the checks. It refuses a Serverpod CLI at another version than the lock holds Serverpod at (`dart install serverpod_cli@<version>`), and the root's tests hold CI's SERVERPOD_VERSION to the lock. CI keeps installing the CLI at that version and puts it on the job's PATH; its own comparison step goes, as the checks run it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
87ae5fca89
commit
3def5126a3
1 changed files with 206 additions and 18 deletions
|
|
@ -25,7 +25,8 @@ jobs:
|
|||
# The Flutter the app is developed with; move it together with the local one.
|
||||
FLUTTER_VERSION: 3.47.5
|
||||
# The Serverpod CLI, for the generated-code check: the servers' Serverpod version
|
||||
# (every package pins it); move it together with them.
|
||||
# (every package pins it; the root's tests hold it to the lock); move it together
|
||||
# with them.
|
||||
SERVERPOD_VERSION: 4.0.4
|
||||
steps:
|
||||
# Before anything else runs, the job proves it can neither see nor reach production
|
||||
|
|
@ -107,23 +108,18 @@ jobs:
|
|||
if: env.CHECKED_BEFORE != 'true'
|
||||
run: flutter pub get --enforce-lockfile || flutter pub get --enforce-lockfile
|
||||
|
||||
# The generated code (each server's lib/src/generated, its client package) is
|
||||
# committed, so it has to be exactly what the generator makes of the models and
|
||||
# endpoints: a model changed without regenerating fails here. Every server package,
|
||||
# the apps' and the shared module, through Melos' `generate` script.
|
||||
- name: Generated code
|
||||
# The Serverpod CLI at SERVERPOD_VERSION, for the checks' generated-code step
|
||||
# (tool/check.dart): the generated code is committed, so it has to be exactly what
|
||||
# the generator makes of the models and endpoints, and the step refuses a CLI at
|
||||
# another version than the lock holds Serverpod at.
|
||||
- name: Serverpod CLI
|
||||
if: env.CHECKED_BEFORE != 'true'
|
||||
run: |
|
||||
bin="${XDG_STATE_HOME:-$HOME/.local/state}/Dart/install/bin"
|
||||
if ! "$bin/serverpod" --no-analytics version 2>/dev/null | grep -qx "Serverpod version: $SERVERPOD_VERSION"; then
|
||||
dart install "serverpod_cli@$SERVERPOD_VERSION"
|
||||
fi
|
||||
PATH="$bin:$PATH" dart run melos run generate
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
git status --short
|
||||
echo 'The generated code differs from what the generator makes now: run `serverpod generate` and commit.' >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "$bin" >> "$FORGEJO_PATH"
|
||||
|
||||
# The test run mode's passwords, which passwords.yaml holds on a developer's machine
|
||||
# and which is never committed. Without them the server tests stop without a word.
|
||||
|
|
|
|||
Loading…
Reference in a new issue