Skip to content

build(swagger): compile swagger UI only for dev builds#280

Merged
SantiagoDePolonia merged 4 commits into
mainfrom
build/prod-swagger-tags
Apr 26, 2026
Merged

build(swagger): compile swagger UI only for dev builds#280
SantiagoDePolonia merged 4 commits into
mainfrom
build/prod-swagger-tags

Conversation

@SantiagoDePolonia

@SantiagoDePolonia SantiagoDePolonia commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • rename dashboard JS tests to .test.cjs so production *.js embeds exclude test fixtures while keeping the embed glob simple
  • make Swagger UI/docs compile only with the swagger build tag
  • make make run opt into dev defaults with LOG_LEVEL=debug, SWAGGER_ENABLED=true, and -tags=swagger
  • default swagger_enabled to false and warn if a non-swagger build is configured to enable it

Verification

  • go test ./cmd/... ./internal/... ./config/...
  • go test -tags=swagger ./cmd/gomodel ./internal/server
  • go build -trimpath -ldflags="-s -w" ./cmd/gomodel
  • go build -tags=swagger -trimpath -ldflags="-s -w" ./cmd/gomodel

Size check

  • prod no-swagger stripped build: 31,897,442 bytes
  • dev swagger stripped build: 45,308,706 bytes

Summary by CodeRabbit

  • New Features

    • Added server.swagger_enabled configuration to control API documentation visibility.
  • Changes

    • Swagger UI and spec are disabled by default; can be enabled via config or environment when documentation support is included in the build.
    • Server startup and logs now reflect actual documentation availability and warn if requested but unavailable.
  • Chores

    • Makefile exposes LOG_LEVEL and SWAGGER_ENABLED as defaults; test discovery pattern updated to *.test.cjs; lint build tags updated.
  • Tests

    • Added/adjusted tests for both enabled and disabled documentation build scenarios.

@coderabbitai

coderabbitai Bot commented Apr 26, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Conditional Swagger support was added using Go build tags plus a runtime server.swagger_enabled flag. Build-tagged source files provide enabled/no-op implementations for Swagger wiring and availability; Makefile and config defaults were updated to support building, running, and testing with the swagger tag.

Changes

Cohort / File(s) Summary
Build / Make
Makefile
Added defaults for LOG_LEVEL and SWAGGER_ENABLED; run injects env and uses go run -tags=swagger; test-dashboard glob changed to *.test.cjs; lint build tags include swagger.
Main command
cmd/gomodel/main.go, cmd/gomodel/swagger_enabled.go, cmd/gomodel/swagger_disabled.go
Introduced configureSwaggerDocs(basePath string) and call from main; provided build-tagged enabled and no-op implementations to set Swagger base path only when swagger tag present.
Config
config/config.example.yaml, config/config.go, config/config_test.go
Added server.swagger_enabled (default false) to example and default config; tests updated to expect Swagger disabled by default.
Application init
internal/app/app.go
Swagger enablement now computed as config && server.SwaggerAvailable(); logs and startup config use the gated value and emit a warning if requested but unavailable.
Server HTTP & routing
internal/server/http.go, internal/server/...swagger_enabled.go, internal/server/...swagger_disabled.go
Centralized Swagger registration via registerSwagger(e, cfg); http.go no longer depends directly on echo-swagger; build-tagged files provide SwaggerAvailable() and register or no-op /swagger/*.
Server tests
internal/server/http_test.go, internal/server/swagger_enabled_test.go, internal/server/swagger_disabled_test.go
Removed Swagger assertions from main HTTP test; added build-tagged tests verifying 200 responses when swagger tag present and 404 when absent.

Sequence Diagram

sequenceDiagram
    participant Build as Build System
    participant Main as cmd/gomodel
    participant Config as Config Loader
    participant App as Application Init
    participant Server as HTTP Server
    participant Swagger as Swagger Registrar

    Build->>Main: Compile with or without -tags=swagger
    Main->>Config: Load configuration (server.swagger_enabled)
    Main->>Main: Call configureSwaggerDocs(basePath) [build-tagged]
    Main->>App: Initialize application
    App->>Server: Initialize server
    Server->>Server: Call SwaggerAvailable() [build-tagged]
    Server->>App: Return availability
    App->>Server: Use effective swagger_enabled = config && availability
    alt Swagger available and enabled
        Server->>Swagger: registerSwagger(e, cfg)
        Swagger-->>Server: Handler wired (echo-swagger)
    else Swagger unavailable or disabled
        Server->>Swagger: registerSwagger(e, cfg) -> no-op
    end
    Server-->>App: Server ready
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped through build tags, neat and spry,
split swagger paths beneath the sky.
One build brings docs, the other stays mute,
configs and makefiles keep both routes astute. 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: making Swagger UI compile only for dev builds using build tags, which is the core objective of this PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch build/prod-swagger-tags

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps

greptile-apps Bot commented Apr 26, 2026

Copy link
Copy Markdown

Greptile Summary

This PR gates Swagger UI compilation and registration behind a swagger build tag, defaulting swagger_enabled to false in config and wiring up proper no-op stubs for production builds. It also renames JS test fixtures from .test.js to .test.cjs so the existing static/js/modules/*.js embed glob no longer picks them up.

The refactor is clean and consistent: build-tag stub/implementation pairs are added at both the cmd/gomodel and internal/server layers, the app layer emits a helpful slog.Warn when a swagger-enabled config is used with a non-swagger binary, and the redundant SwaggerAvailable() guard in http.go provides good defense when server.New() is called directly in tests.

Confidence Score: 5/5

Safe to merge — clean conditional-compilation refactor with no logic regressions

All findings are P2 or lower. The build-tag split is correct and symmetric at both the cmd and server layers. The default-false change is intentional and tested. The JS rename cleanly excludes test fixtures from the embed glob. No security, data, or correctness issues identified.

No files require special attention

Important Files Changed

Filename Overview
internal/app/app.go Computes effective swaggerEnabled by AND-ing config flag with SwaggerAvailable(); emits slog.Warn when config requests swagger but build doesn't support it
internal/server/http.go Removes direct echoswagger import; delegates route registration to registerSwagger(); adds redundant-but-safe SwaggerAvailable() guard on auth skip-paths
internal/server/swagger_enabled.go New file: swagger build implementation; SwaggerAvailable() returns true and registerSwagger registers the echo-swagger handler
internal/server/swagger_disabled.go New file: no-op stubs for non-swagger builds; correctly returns false from SwaggerAvailable() and registers no routes
cmd/gomodel/swagger_enabled.go New file: sets SwaggerInfo.BasePath only when built with swagger tag; keeps docs import scoped to swagger builds
cmd/gomodel/swagger_disabled.go New file: no-op configureSwaggerDocs for non-swagger builds, correctly guarded with !swagger build tag
config/config.go SwaggerEnabled default changed from true to false; aligns with the new build-tag gating strategy
Makefile make run now passes LOG_LEVEL=debug, SWAGGER_ENABLED=true, and -tags=swagger for dev convenience; test-dashboard glob updated for .test.cjs

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A{Built with -tags=swagger?} -->|Yes| B[SwaggerAvailable returns true]
    A -->|No| C[SwaggerAvailable returns false]
    D{config swagger_enabled=true?} -->|Yes| E{SwaggerAvailable?}
    D -->|No| F[swaggerEnabled = false]
    E -->|Yes| G[swaggerEnabled = true]
    E -->|No| H[swaggerEnabled = false + slog.Warn emitted]
    B --> E
    C --> E
    G --> I[registerSwagger registers route]
    F --> J[registerSwagger is no-op]
    H --> J
Loading

Reviews (1): Last reviewed commit: "build(swagger): compile UI only for dev ..." | Re-trigger Greptile

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 35.71429% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/app/app.go 0.00% 6 Missing ⚠️
cmd/gomodel/main.go 0.00% 1 Missing ⚠️
cmd/gomodel/swagger_disabled.go 0.00% 1 Missing ⚠️
internal/server/http.go 50.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/server/swagger_disabled_test.go`:
- Around line 11-23: Add a fast-fail assertion in
TestSwaggerEndpoint_RequestedButNotAvailable to explicitly verify the build
constraint by calling SwaggerAvailable() and asserting it returns false before
making the HTTP request; this ensures if swagger_disabled.go gets inverted the
test fails immediately. Update the test
(TestSwaggerEndpoint_RequestedButNotAvailable) to call SwaggerAvailable() and
assert equality to false, keeping the existing Config{SwaggerEnabled: true}
setup and existing HTTP request/assertion logic intact.

In `@Makefile`:
- Line 25: The Makefile currently hard-sets LOG_LEVEL and SWAGGER_ENABLED inline
in the run recipe, preventing caller overrides; change those to default variable
assignments (use LOG_LEVEL?=debug and SWAGGER_ENABLED?=true) and update the run
target to use the variables (e.g., invoke go run with LOG_LEVEL=$(LOG_LEVEL) and
SWAGGER_ENABLED=$(SWAGGER_ENABLED)) while keeping the -tags=swagger and
./cmd/gomodel invocation so callers like LOG_LEVEL=info make run can override
defaults.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 49205e04-5723-448b-ac49-70fb895f6328

📥 Commits

Reviewing files that changed from the base of the PR and between da6e079 and 291443d.

📒 Files selected for processing (29)
  • Makefile
  • cmd/gomodel/main.go
  • cmd/gomodel/swagger_disabled.go
  • cmd/gomodel/swagger_enabled.go
  • config/config.example.yaml
  • config/config.go
  • config/config_test.go
  • internal/admin/dashboard/static/js/modules/aliases.test.cjs
  • internal/admin/dashboard/static/js/modules/audit-list.test.cjs
  • internal/admin/dashboard/static/js/modules/auth-keys.test.cjs
  • internal/admin/dashboard/static/js/modules/charts.test.cjs
  • internal/admin/dashboard/static/js/modules/dashboard-display.test.cjs
  • internal/admin/dashboard/static/js/modules/dashboard-layout.test.cjs
  • internal/admin/dashboard/static/js/modules/dashboard-paths.test.cjs
  • internal/admin/dashboard/static/js/modules/guardrails.test.cjs
  • internal/admin/dashboard/static/js/modules/providers.test.cjs
  • internal/admin/dashboard/static/js/modules/request-cancellation.test.cjs
  • internal/admin/dashboard/static/js/modules/timestamp-format.test.cjs
  • internal/admin/dashboard/static/js/modules/timezone-layout.test.cjs
  • internal/admin/dashboard/static/js/modules/timezone.test.cjs
  • internal/admin/dashboard/static/js/modules/workflows-layout.test.cjs
  • internal/admin/dashboard/static/js/modules/workflows.test.cjs
  • internal/app/app.go
  • internal/server/http.go
  • internal/server/http_test.go
  • internal/server/swagger_disabled.go
  • internal/server/swagger_disabled_test.go
  • internal/server/swagger_enabled.go
  • internal/server/swagger_enabled_test.go
💤 Files with no reviewable changes (1)
  • internal/server/http_test.go

Comment on lines +11 to +23
func TestSwaggerEndpoint_RequestedButNotAvailable(t *testing.T) {
mock := &mockProvider{}
srv := New(mock, &Config{SwaggerEnabled: true})

req := httptest.NewRequest(http.MethodGet, "/swagger/index.html", nil)
rec := httptest.NewRecorder()

srv.ServeHTTP(rec, req)

if rec.Code != http.StatusNotFound {
t.Errorf("expected status 404, got %d", rec.Code)
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Good behavioral coverage of the !swagger build.

Asserting 404 against a Config{SwaggerEnabled: true} proves the route is absent regardless of config when the binary is built without -tags=swagger. Optionally consider also asserting SwaggerAvailable() == false here to fail fast if someone accidentally inverts the build constraints in swagger_disabled.go.

♻️ Optional belt-and-suspenders assertion
 func TestSwaggerEndpoint_RequestedButNotAvailable(t *testing.T) {
+	if SwaggerAvailable() {
+		t.Fatal("SwaggerAvailable() must be false in !swagger build")
+	}
 	mock := &mockProvider{}
 	srv := New(mock, &Config{SwaggerEnabled: true})
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/server/swagger_disabled_test.go` around lines 11 - 23, Add a
fast-fail assertion in TestSwaggerEndpoint_RequestedButNotAvailable to
explicitly verify the build constraint by calling SwaggerAvailable() and
asserting it returns false before making the HTTP request; this ensures if
swagger_disabled.go gets inverted the test fails immediately. Update the test
(TestSwaggerEndpoint_RequestedButNotAvailable) to call SwaggerAvailable() and
assert equality to false, keeping the existing Config{SwaggerEnabled: true}
setup and existing HTTP request/assertion logic intact.

Comment thread Makefile Outdated
@SantiagoDePolonia SantiagoDePolonia changed the title build(swagger): compile UI only for dev builds build(swagger): compile swagger UI only for dev builds Apr 26, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Makefile (1)

111-112: ⚠️ Potential issue | 🟡 Minor

lint target is missing the swagger build tag — swagger-tagged files won't be linted.

--build-tags=e2e,integration,contract does not include swagger, so the new cmd/gomodel/swagger_enabled.go and internal/server/swagger_enabled.go (both gated by //go:build swagger) are invisible to golangci-lint. Their counterparts (*_disabled.go) are linted, but the swagger-on path silently bypasses all linters, including the echo-swagger import path. Add swagger to the tag list to keep both build variants under lint coverage:

🔧 Proposed fix
 lint:
-	golangci-lint run --build-tags=e2e,integration,contract ./cmd/... ./config/... ./internal/... ./tests/...
+	golangci-lint run --build-tags=e2e,integration,contract,swagger ./cmd/... ./config/... ./internal/... ./tests/...
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` around lines 111 - 112, The lint target currently runs
golangci-lint with --build-tags=e2e,integration,contract which excludes
swagger-tagged files; update the Makefile's lint target (the "lint" rule) to
include the swagger build tag so files like cmd/gomodel/swagger_enabled.go and
internal/server/swagger_enabled.go (//go:build swagger) are included in linting,
ensuring imports such as echo-swagger are checked too.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Makefile`:
- Line 55: The Makefile currently invokes node with an explicit glob
"internal/admin/dashboard/static/js/modules/*.test.cjs" which the shell may pass
literally when no matches exist; update the test recipe to avoid shell glob
expansion by either (A) using a guarded finder that only invokes node --test
when matching files are present (use find to locate "*.test.cjs" under the
internal/admin/dashboard/static/js/modules directory and call node --test with
those files), or (B) remove the explicit glob and rely on Node's test discovery
by calling node --test against the modules directory (e.g., node --test
internal/admin/dashboard/static/js/modules) so Node discovers tests itself;
ensure the chosen approach prevents a failing "Cannot find module" when no
.test.cjs files exist.
- Line 27: The Makefile's run recipe hard-codes the swagger build tag in the go
run invocation (the token "go run -tags=swagger ./cmd/gomodel"), preventing
callers from opting out; change the recipe to use a parameterized build-tags
variable (e.g., TAGS or BUILD_TAGS) with a sensible default (swagger) and only
append the "-tags=$(TAGS)" flag when the variable is non-empty so callers can do
TAGS= make run or TAGS="" make run to run a non-swagger binary; update the run
target to reference this variable instead of the literal "-tags=swagger".

---

Outside diff comments:
In `@Makefile`:
- Around line 111-112: The lint target currently runs golangci-lint with
--build-tags=e2e,integration,contract which excludes swagger-tagged files;
update the Makefile's lint target (the "lint" rule) to include the swagger build
tag so files like cmd/gomodel/swagger_enabled.go and
internal/server/swagger_enabled.go (//go:build swagger) are included in linting,
ensuring imports such as echo-swagger are checked too.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 24f2a99a-7b7f-4957-884e-ce02ffa8e726

📥 Commits

Reviewing files that changed from the base of the PR and between 291443d and 7e02755.

📒 Files selected for processing (1)
  • Makefile

Comment thread Makefile
# Run the application
run:
go run ./cmd/gomodel
LOG_LEVEL=$(LOG_LEVEL) SWAGGER_ENABLED=$(SWAGGER_ENABLED) go run -tags=swagger ./cmd/gomodel

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

make run always forces -tags=swagger, even when caller overrides SWAGGER_ENABLED=false.

The build tag is hard-coded on the recipe line, so callers can disable runtime Swagger via SWAGGER_ENABLED=false make run but cannot opt out of the swagger-tagged binary (which carries the echo-swagger and swaggerdocs deps). For symmetry with the new override-friendly env vars, consider also parameterizing the build tags so a dev can run a prod-shaped binary locally:

♻️ Optional: parameterize build tags too
+GO_TAGS ?= swagger
 ...
 run:
-	LOG_LEVEL=$(LOG_LEVEL) SWAGGER_ENABLED=$(SWAGGER_ENABLED) go run -tags=swagger ./cmd/gomodel
+	LOG_LEVEL=$(LOG_LEVEL) SWAGGER_ENABLED=$(SWAGGER_ENABLED) go run $(if $(GO_TAGS),-tags=$(GO_TAGS)) ./cmd/gomodel
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` at line 27, The Makefile's run recipe hard-codes the swagger build
tag in the go run invocation (the token "go run -tags=swagger ./cmd/gomodel"),
preventing callers from opting out; change the recipe to use a parameterized
build-tags variable (e.g., TAGS or BUILD_TAGS) with a sensible default (swagger)
and only append the "-tags=$(TAGS)" flag when the variable is non-empty so
callers can do TAGS= make run or TAGS="" make run to run a non-swagger binary;
update the run target to reference this variable instead of the literal
"-tags=swagger".

Comment thread Makefile
# Run dashboard JavaScript unit tests
test-dashboard:
node --test internal/admin/dashboard/static/js/modules/*.test.js
node --test internal/admin/dashboard/static/js/modules/*.test.cjs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Glob expansion happens in the shell, not in node --test.

internal/admin/dashboard/static/js/modules/*.test.cjs is expanded by the shell at recipe time. If no .cjs test files exist yet (e.g., during the rename transition), the literal pattern is passed to node --test, which will fail with an unhelpful "Cannot find module" error rather than a clean "no tests" exit. With shell-glob nullglob not set in make's default /bin/sh, this is a footgun; consider either guarding with find or relying on Node's built-in test discovery:

♻️ More robust forms
-	node --test internal/admin/dashboard/static/js/modules/*.test.cjs
+	node --test --test-name-pattern='.*' \
+		$$(find internal/admin/dashboard/static/js/modules -name '*.test.cjs')

Or, if the directory only contains tests of a single style, let Node discover them:

-	node --test internal/admin/dashboard/static/js/modules/*.test.cjs
+	node --test internal/admin/dashboard/static/js/modules
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
node --test internal/admin/dashboard/static/js/modules/*.test.cjs
node --test --test-name-pattern='.*' \
$$(find internal/admin/dashboard/static/js/modules -name '*.test.cjs')
Suggested change
node --test internal/admin/dashboard/static/js/modules/*.test.cjs
node --test internal/admin/dashboard/static/js/modules
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` at line 55, The Makefile currently invokes node with an explicit
glob "internal/admin/dashboard/static/js/modules/*.test.cjs" which the shell may
pass literally when no matches exist; update the test recipe to avoid shell glob
expansion by either (A) using a guarded finder that only invokes node --test
when matching files are present (use find to locate "*.test.cjs" under the
internal/admin/dashboard/static/js/modules directory and call node --test with
those files), or (B) remove the explicit glob and rely on Node's test discovery
by calling node --test against the modules directory (e.g., node --test
internal/admin/dashboard/static/js/modules) so Node discovers tests itself;
ensure the chosen approach prevents a failing "Cannot find module" when no
.test.cjs files exist.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Makefile`:
- Line 112: The Makefile's lint-fix target is out of sync with lint: update the
lint-fix target (and optionally factor into variables) so it uses the same
--build-tags=swagger,e2e,integration,contract and the same path list (./cmd/...
./config/... ./internal/... ./tests/...) as the lint target; modify the lint-fix
recipe to invoke golangci-lint run --build-tags=swagger,e2e,integration,contract
against the full path set (or extract BUILD_TAGS and LINT_PATHS variables and
reference them in both lint and lint-fix) so files behind the
swagger/e2e/integration/contract tags are analyzed and auto-fixed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ffa1f9ba-5ccb-48d5-a584-d10ceab9af88

📥 Commits

Reviewing files that changed from the base of the PR and between 7e02755 and c05bc3f.

📒 Files selected for processing (1)
  • Makefile

Comment thread Makefile
# Run linter
lint:
golangci-lint run --build-tags=e2e,integration,contract ./cmd/... ./config/... ./internal/... ./tests/...
golangci-lint run --build-tags=swagger,e2e,integration,contract ./cmd/... ./config/... ./internal/... ./tests/...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

lint-fix is out of sync with lint build tags.

The lint target now passes --build-tags=swagger,e2e,integration,contract, but lint-fix (line 116) still runs without any build tags and against a narrower path set (./cmd/... ./config/... ./internal/..., omitting ./tests/...). As a result, files behind those tags (e.g., cmd/gomodel/swagger_enabled.go with //go:build swagger, plus e2e/integration/contract test files) won't be analyzed or auto-fixed, so make lint-fix followed by make lint can still surface findings the fixer never saw.

♻️ Proposed alignment
 # Run linter with auto-fix
 lint-fix:
-	golangci-lint run --fix ./cmd/... ./config/... ./internal/...
+	golangci-lint run --fix --build-tags=swagger,e2e,integration,contract ./cmd/... ./config/... ./internal/... ./tests/...

Optionally, factor the tag list and path list into Make variables to keep the two targets in lockstep going forward.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
golangci-lint run --build-tags=swagger,e2e,integration,contract ./cmd/... ./config/... ./internal/... ./tests/...
# Run linter with auto-fix
lint-fix:
golangci-lint run --fix --build-tags=swagger,e2e,integration,contract ./cmd/... ./config/... ./internal/... ./tests/...
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` at line 112, The Makefile's lint-fix target is out of sync with
lint: update the lint-fix target (and optionally factor into variables) so it
uses the same --build-tags=swagger,e2e,integration,contract and the same path
list (./cmd/... ./config/... ./internal/... ./tests/...) as the lint target;
modify the lint-fix recipe to invoke golangci-lint run
--build-tags=swagger,e2e,integration,contract against the full path set (or
extract BUILD_TAGS and LINT_PATHS variables and reference them in both lint and
lint-fix) so files behind the swagger/e2e/integration/contract tags are analyzed
and auto-fixed.

@SantiagoDePolonia SantiagoDePolonia merged commit ca1be02 into main Apr 26, 2026
19 checks passed
@SantiagoDePolonia SantiagoDePolonia deleted the build/prod-swagger-tags branch June 11, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants