Skip to content

ci: run golangci-lint on the Caddy module#2397

Merged
dunglas merged 2 commits intomainfrom
ci/golangci-lint-caddy
May 7, 2026
Merged

ci: run golangci-lint on the Caddy module#2397
dunglas merged 2 commits intomainfrom
ci/golangci-lint-caddy

Conversation

@dunglas
Copy link
Copy Markdown
Member

@dunglas dunglas commented May 7, 2026

Summary

The Caddy module under caddy/ has its own go.mod and was never linted by CI. Enabling lint surfaced a handful of real issues; this PR fixes them and wires the linter in.

Workflow

Adds a second golangci/golangci-lint-action@v9 step with working-directory: caddy, gated on matrix.php-versions == '8.5' (same as the existing root lint).

Fixes

  • caddy/admin.go: restartWorkers discarded the error from admin.success. Now returned.
  • caddy/admin_test.go: defer resp.Body.Close() (errcheck). Switched to defer func() { require.NoError(t, resp.Body.Close()) }() so a real failure surfaces.
  • caddy/app.go: var iniError renamed to errIni (ST1012).
  • caddy/mercure.go: lowercase leading article in two error strings (ST1005).

Lint passes on both modules with the CI build tags nobadger,nomysql,nopgx.

Adds a second golangci-lint step scoped to caddy/ on the same job as
the root lint. Fixes the pre-existing issues that surfaced:

- admin.go: propagate the success() error instead of dropping it
- admin_test.go: assert resp.Body.Close() with require.NoError
- app.go: rename iniError to errIni (ST1012)
- mercure.go: lowercase the leading article in error strings (ST1005)
Copilot AI review requested due to automatic review settings May 7, 2026 08:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enables golangci-lint for the Go submodule under caddy/ in CI and fixes the lint violations that surfaced, bringing the Caddy module’s Go code under the same linting expectations as the repo root module.

Changes:

  • Add a dedicated golangci-lint CI step that runs in the caddy/ module directory (gated to PHP 8.5 like the existing Go lint step).
  • Fix lint findings in the Caddy module: propagate a previously ignored error, adjust test cleanup to check Close() errors, and apply small naming / error-string style corrections.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.github/workflows/tests.yaml Adds a CI lint step to run golangci-lint within the caddy/ module.
caddy/admin.go Returns the admin.success(...) error instead of discarding it.
caddy/admin_test.go Ensures resp.Body.Close() is checked so close failures are reported by tests.
caddy/app.go Renames a package error var to satisfy Go naming lint rules.
caddy/mercure.go Adjusts error strings to match Go error-string style (lowercase).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/tests.yaml Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Kévin Dunglas <kevin@dunglas.fr>
@dunglas dunglas merged commit 68573a9 into main May 7, 2026
31 checks passed
@dunglas dunglas deleted the ci/golangci-lint-caddy branch May 7, 2026 09:49
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.

3 participants