diff --git a/.github/actions/go-linter/action.yaml b/.github/actions/go-linter/action.yaml index fd341901dc..5e10400fed 100644 --- a/.github/actions/go-linter/action.yaml +++ b/.github/actions/go-linter/action.yaml @@ -21,3 +21,16 @@ runs: version: 2025.1.1 install-go: false working-directory: ${{ inputs.working-directory }} + + - name: Check code formatting + run: | + unformatted=$(gofmt -l .) + if [ -n "$unformatted" ]; then + echo "The following files are not formatted correctly:" + echo "$unformatted" + echo "" + echo "Run 'gofmt -w .' to fix formatting." + exit 1 + fi + shell: bash + working-directory: ${{ inputs.working-directory }} diff --git a/router-tests/events/kafka_events_test.go b/router-tests/events/kafka_events_test.go index e76560a90d..dc13e10fae 100644 --- a/router-tests/events/kafka_events_test.go +++ b/router-tests/events/kafka_events_test.go @@ -20,7 +20,6 @@ import ( "github.com/wundergraph/cosmo/router/pkg/config" ) - type kafkaSubscriptionArgs struct { dataValue []byte errValue error diff --git a/router-tests/events/nats_events_test.go b/router-tests/events/nats_events_test.go index 88a46c0d77..7b3f3822b5 100644 --- a/router-tests/events/nats_events_test.go +++ b/router-tests/events/nats_events_test.go @@ -56,7 +56,6 @@ func (c *ConfigPollerMock) Stop(_ context.Context) error { return nil } - type natsSubscriptionArgs struct { dataValue []byte errValue error @@ -1432,7 +1431,6 @@ func TestNatsEvents(t *testing.T) { }) }) - t.Run("subscribe to multiple subjects", func(t *testing.T) { t.Parallel() diff --git a/router-tests/events/redis_events_test.go b/router-tests/events/redis_events_test.go index fbf126c905..a3a8eae2e5 100644 --- a/router-tests/events/redis_events_test.go +++ b/router-tests/events/redis_events_test.go @@ -18,7 +18,6 @@ import ( "github.com/wundergraph/cosmo/router/pkg/config" ) - type subscriptionArgs struct { dataValue []byte errValue error diff --git a/router-tests/lifecycle/shutdown_test.go b/router-tests/lifecycle/shutdown_test.go index 2960023bca..36691a2146 100644 --- a/router-tests/lifecycle/shutdown_test.go +++ b/router-tests/lifecycle/shutdown_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/wundergraph/cosmo/router-tests/testutils" "github.com/wundergraph/cosmo/router-tests/testenv" + "github.com/wundergraph/cosmo/router-tests/testutils" "github.com/wundergraph/cosmo/router/core" "github.com/wundergraph/cosmo/router/pkg/config" "go.uber.org/goleak" diff --git a/router-tests/modules/context_error_field_test.go b/router-tests/modules/context_error_field_test.go index 0e658cc8f2..590ae15441 100644 --- a/router-tests/modules/context_error_field_test.go +++ b/router-tests/modules/context_error_field_test.go @@ -7,9 +7,9 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/wundergraph/cosmo/router-tests/testutils" contexterror "github.com/wundergraph/cosmo/router-tests/modules/context-error" "github.com/wundergraph/cosmo/router-tests/testenv" + "github.com/wundergraph/cosmo/router-tests/testutils" "github.com/wundergraph/cosmo/router/core" "github.com/wundergraph/cosmo/router/pkg/config" ) diff --git a/router-tests/modules/set_scopes_test.go b/router-tests/modules/set_scopes_test.go index 8b907f2cb6..2ff93352be 100644 --- a/router-tests/modules/set_scopes_test.go +++ b/router-tests/modules/set_scopes_test.go @@ -8,10 +8,10 @@ import ( "time" "github.com/stretchr/testify/require" - "github.com/wundergraph/cosmo/router-tests/testutils" "github.com/wundergraph/cosmo/router-tests/jwks" setScopesModule "github.com/wundergraph/cosmo/router-tests/modules/custom-set-scopes" "github.com/wundergraph/cosmo/router-tests/testenv" + "github.com/wundergraph/cosmo/router-tests/testutils" "github.com/wundergraph/cosmo/router/cmd/custom/module" "github.com/wundergraph/cosmo/router/core" "github.com/wundergraph/cosmo/router/pkg/authentication" diff --git a/router-tests/modules/stream_receive_test.go b/router-tests/modules/stream_receive_test.go index 99584a3dba..30fb26f490 100644 --- a/router-tests/modules/stream_receive_test.go +++ b/router-tests/modules/stream_receive_test.go @@ -11,11 +11,11 @@ import ( "github.com/hasura/go-graphql-client" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/wundergraph/cosmo/router-tests/testutils" "github.com/wundergraph/cosmo/router-tests/events" "github.com/wundergraph/cosmo/router-tests/jwks" stream_receive "github.com/wundergraph/cosmo/router-tests/modules/stream-receive" "github.com/wundergraph/cosmo/router-tests/testenv" + "github.com/wundergraph/cosmo/router-tests/testutils" "github.com/wundergraph/cosmo/router/core" "github.com/wundergraph/cosmo/router/pkg/authentication" "github.com/wundergraph/cosmo/router/pkg/config" diff --git a/router-tests/observability/prometheus_test.go b/router-tests/observability/prometheus_test.go index 44c405542e..75184ffba4 100644 --- a/router-tests/observability/prometheus_test.go +++ b/router-tests/observability/prometheus_test.go @@ -5763,4 +5763,3 @@ func findCacheMetrics(mf []*io_prometheus_client.MetricFamily) []*io_prometheus_ func findEngineMetrics(mf []*io_prometheus_client.MetricFamily) []*io_prometheus_client.MetricFamily { return findMetricsWithPrefix(mf, "router_engine_") } - diff --git a/router-tests/telemetry/connection_metrics_test.go b/router-tests/telemetry/connection_metrics_test.go index 3d60186208..421c9a8664 100644 --- a/router-tests/telemetry/connection_metrics_test.go +++ b/router-tests/telemetry/connection_metrics_test.go @@ -6,8 +6,8 @@ import ( "time" "github.com/stretchr/testify/require" - "github.com/wundergraph/cosmo/router-tests/testutils" "github.com/wundergraph/cosmo/router-tests/testenv" + "github.com/wundergraph/cosmo/router-tests/testutils" "github.com/wundergraph/cosmo/router/core" "github.com/wundergraph/cosmo/router/pkg/config" "github.com/wundergraph/cosmo/router/pkg/otel" diff --git a/router-tests/telemetry/metrics_log_export_test.go b/router-tests/telemetry/metrics_log_export_test.go index cf23ece761..28ec8c484e 100644 --- a/router-tests/telemetry/metrics_log_export_test.go +++ b/router-tests/telemetry/metrics_log_export_test.go @@ -8,8 +8,8 @@ import ( "time" "github.com/stretchr/testify/require" - "github.com/wundergraph/cosmo/router-tests/testutils" "github.com/wundergraph/cosmo/router-tests/testenv" + "github.com/wundergraph/cosmo/router-tests/testutils" "go.opentelemetry.io/otel/sdk/metric" "go.opentelemetry.io/otel/sdk/metric/metricdata" "go.uber.org/zap/zapcore" diff --git a/router-tests/telemetry/stream_metrics_test.go b/router-tests/telemetry/stream_metrics_test.go index 8d3be2c076..131c57508a 100644 --- a/router-tests/telemetry/stream_metrics_test.go +++ b/router-tests/telemetry/stream_metrics_test.go @@ -10,9 +10,9 @@ import ( "github.com/hasura/go-graphql-client" "github.com/nats-io/nats.go" "github.com/stretchr/testify/require" - "github.com/wundergraph/cosmo/router-tests/testutils" "github.com/wundergraph/cosmo/router-tests/events" "github.com/wundergraph/cosmo/router-tests/testenv" + "github.com/wundergraph/cosmo/router-tests/testutils" "github.com/wundergraph/cosmo/router/pkg/config" otelattrs "github.com/wundergraph/cosmo/router/pkg/otel" "go.opentelemetry.io/otel/sdk/metric" diff --git a/router-tests/testenv/testenv.go b/router-tests/testenv/testenv.go index 81055f6b60..93da790b38 100644 --- a/router-tests/testenv/testenv.go +++ b/router-tests/testenv/testenv.go @@ -64,9 +64,9 @@ import ( "github.com/wundergraph/cosmo/router/pkg/controlplane/configpoller" "github.com/wundergraph/cosmo/router/pkg/logging" rmetric "github.com/wundergraph/cosmo/router/pkg/metric" - "github.com/wundergraph/cosmo/router/pkg/statistics" "github.com/wundergraph/cosmo/router/pkg/pubsub/datasource" pubsubNats "github.com/wundergraph/cosmo/router/pkg/pubsub/nats" + "github.com/wundergraph/cosmo/router/pkg/statistics" rtrace "github.com/wundergraph/cosmo/router/pkg/trace" ) diff --git a/router/Makefile b/router/Makefile index 6a51c0341e..d0f8230738 100644 --- a/router/Makefile +++ b/router/Makefile @@ -24,6 +24,14 @@ test-coverage: test-fresh: clean-testcache test lint: + @unformatted=$$(gofmt -l .); \ + if [ -n "$$unformatted" ]; then \ + echo "The following files are not formatted correctly:"; \ + echo "$$unformatted"; \ + echo ""; \ + echo "Run 'gofmt -w .' to fix formatting."; \ + exit 1; \ + fi go vet ./... staticcheck ./... diff --git a/router/pkg/mcpserver/server_test.go b/router/pkg/mcpserver/server_test.go index b5ecf39c00..3c18725402 100644 --- a/router/pkg/mcpserver/server_test.go +++ b/router/pkg/mcpserver/server_test.go @@ -161,7 +161,7 @@ func TestReload_PrefixModeAvoidsReservedNameCollision(t *testing.T) { tempDir := t.TempDir() writeOperationFiles(t, tempDir, map[string]string{ "GetOperationInfo.graphql": getOperationInfoOp, - "ListEmployees.graphql": listEmployeesOp, + "ListEmployees.graphql": listEmployeesOp, }) schemaDoc, report := astparser.ParseGraphqlDocumentString(testSchema) diff --git a/router/pkg/trace/meter.go b/router/pkg/trace/meter.go index 198f0bbc4f..185508c008 100644 --- a/router/pkg/trace/meter.go +++ b/router/pkg/trace/meter.go @@ -35,7 +35,6 @@ type ( } ) - func createExporter(log *zap.Logger, exp *ExporterConfig) (sdktrace.SpanExporter, error) { u, err := url.Parse(exp.Endpoint) if err != nil {