From 897613e8377db824d47b32a5d4b27e599280fb9d Mon Sep 17 00:00:00 2001 From: mmetc <92726601+mmetc@users.noreply.github.com> Date: Wed, 25 Sep 2024 09:02:53 +0200 Subject: [PATCH] CI: check generated code in test workflow (#3261) --- .github/workflows/go-tests.yml | 12 ++++++++++++ pkg/database/ent/machine.go | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml index d4e3a3d843a..a6c72a91af6 100644 --- a/.github/workflows/go-tests.yml +++ b/.github/workflows/go-tests.yml @@ -128,6 +128,18 @@ jobs: with: go-version: "1.22" + - name: Run "make generate" and check for changes + run: | + set -e + make generate 2>/dev/null + if [[ $(git status --porcelain) ]]; then + echo "Error: Uncommitted changes found after running 'make generate'. Please commit all generated code." + git diff + exit 1 + else + echo "No changes detected after running 'make generate'." + fi + - name: Create localstack streams run: | aws --endpoint-url=http://127.0.0.1:4566 --region us-east-1 kinesis create-stream --stream-name stream-1-shard --shard-count 1 diff --git a/pkg/database/ent/machine.go b/pkg/database/ent/machine.go index 1b8122060d1..76127065791 100644 --- a/pkg/database/ent/machine.go +++ b/pkg/database/ent/machine.go @@ -202,7 +202,7 @@ func (m *Machine) assignValues(columns []string, values []any) error { return fmt.Errorf("unexpected type %T for field hubstate", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &m.Hubstate); err != nil { - return fmt.Errorf("parsing field hubstate: %w", err) + return fmt.Errorf("unmarshal field hubstate: %w", err) } } case machine.FieldDatasources: @@ -210,7 +210,7 @@ func (m *Machine) assignValues(columns []string, values []any) error { return fmt.Errorf("unexpected type %T for field datasources", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &m.Datasources); err != nil { - return fmt.Errorf("parsing field datasources: %w", err) + return fmt.Errorf("unmarshal field datasources: %w", err) } } default: