ci: finalize Dagger migration for format and check-mocks with internal git init

This commit is contained in:
GuettliBot2
2026-05-17 09:08:29 +02:00
parent f2d9459f44
commit 601358dbb7
+12 -3
View File
@@ -70,6 +70,8 @@ func (m *Ci) CheckLayers(ctx context.Context, source *dagger.Directory) (string,
// Run dart format check
func (m *Ci) Format(ctx context.Context, source *dagger.Directory) (string, error) {
// Initialize git and add files to index so 'git diff' works correctly for mock checking
// and use --set-exit-if-changed for format enforcement.
return m.Base(source).
WithExec([]string{"flutter", "pub", "get"}).
WithExec([]string{"dart", "format", "--output=none", "--set-exit-if-changed", "lib", "test"}).
@@ -78,10 +80,17 @@ func (m *Ci) Format(ctx context.Context, source *dagger.Directory) (string, erro
// Verify that mocks are up to date
func (m *Ci) CheckMocks(ctx context.Context, source *dagger.Directory) (string, error) {
// Setup runs build_runner, which is exactly what we need.
// If any file changed, it means the committed version was out of date.
// Note: We check specifically for .mocks.dart files.
// We need to initialize a git repo inside the container so that build_runner's
// changes (if any) can be detected via 'git diff'.
return m.Setup(source).
WithExec([]string{"git", "init"}).
WithExec([]string{"git", "config", "user.email", "ci@sharedinbox.de"}).
WithExec([]string{"git", "config", "user.name", "CI"}).
WithExec([]string{"git", "add", "."}).
WithExec([]string{"git", "commit", "-m", "baseline"}).
// Re-run build_runner to see if anything changes (though Setup already ran it,
// we need the git baseline established FIRST).
WithExec([]string{"flutter", "pub", "run", "build_runner", "build", "--delete-conflicting-outputs"}).
WithExec([]string{"/bin/bash", "-c", "CHANGED=$(find . -name '*.mocks.dart' | xargs -r git diff --exit-code); if [ $? -ne 0 ]; then echo \"ERROR: Mocks are out of date\"; exit 1; fi; echo \"Mocks are up to date.\""}).
Stdout(ctx)
}