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
|
|
@ -1,6 +1,8 @@
|
|||
/// What `tool/check.dart` checks, as pure functions its tests reach.
|
||||
library;
|
||||
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
/// Code generators' output, which is never formatted by hand: Serverpod's
|
||||
/// client packages from top to bottom (but for [_written]), a server's
|
||||
/// generated sources and test tools, and gen-l10n's localizations.
|
||||
|
|
@ -63,3 +65,37 @@ List<String> melosFilters({List<String>? touched}) => [
|
|||
'--include-dependents',
|
||||
],
|
||||
];
|
||||
|
||||
/// The version [package] is locked at in [lock] (a `pubspec.lock`'s text),
|
||||
/// or null where the lock doesn't name it.
|
||||
String? lockedVersion(String lock, String package) => switch (loadYaml(lock)) {
|
||||
{'packages': final Map<Object?, Object?> packages} =>
|
||||
switch (packages[package]) {
|
||||
{'version': final String version} => version,
|
||||
_ => null,
|
||||
},
|
||||
_ => null,
|
||||
};
|
||||
|
||||
/// The version of the Serverpod CLI that `serverpod version` reported in
|
||||
/// [output], or null where it reported none.
|
||||
String? serverpodCliVersion(String output) => RegExp(
|
||||
r'^Serverpod version: (\S+)$',
|
||||
multiLine: true,
|
||||
).firstMatch(output)?.group(1);
|
||||
|
||||
/// How a file absent from the working tree shows in a [differingFiles]
|
||||
/// snapshot.
|
||||
const absentFile = 'absent';
|
||||
|
||||
/// The files whose content differs between the snapshots [before] and
|
||||
/// [after], sorted. A snapshot maps each file that differs from the
|
||||
/// committed one (relative to the repository's root) to a digest of its
|
||||
/// content, or [absentFile]; a file it doesn't name is as committed.
|
||||
List<String> differingFiles(
|
||||
Map<String, String> before,
|
||||
Map<String, String> after,
|
||||
) => [
|
||||
for (final path in {...before.keys, ...after.keys})
|
||||
if (before[path] != after[path]) path,
|
||||
]..sort();
|
||||
|
|
|
|||
Loading…
Reference in a new issue