Skip to content

ci: lint fork Go code in fork-ci and fix existing findings - #140

Open
ibetitsmike wants to merge 4 commits into
mainfrom
mike/issue-123-fork-ci-go-lint
Open

ibetitsmike wants to merge 4 commits into
mainfrom
mike/issue-123-fork-ci-go-lint

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

Xum (AI agent) opened this on behalf of @ibetitsmike.

Closes #123

fork-ci had no Go lint job, so fork code on main carried 29 golangci-lint findings that no check reported. This adds a lint job and fixes those findings so the job starts green.

The job

The job installs the golangci-lint version that mise.toml pins (v2.0.2, the same one upstream's lint job uses) and runs it with the repository .golangci.yaml:

golangci-lint run --fix=false --new-from-merge-base="$NEW_FROM" \
  <every package that holds a fork_*.go or */fork.go file> \
  ./cli ./enterprise/coderd ./coderd/x/... ./coderd/database/forkdb/... ./coderd/database/migrations/chatdmig/... \
  ./codersdk/x/... ./examples/plugins/...
  • The fork-owned trees (forkdb, chatdmig, plugins, pluginsdk, the signal example) are listed explicitly, as are ./cli and ./enterprise/coderd, which hold the fork's plugin files without a fork_ prefix. The fork_*.go list is computed with git ls-files, so a package that gains fork code is covered without a workflow change. Today that is 17 packages, including coderd, codersdk, agent/agentgit and coderd/database/dbauthz.
  • --new-from-merge-base reports only issues on lines the pull request changes, so open PRs are not blocked by findings they did not introduce. Like upstream's lint/go/new-code, a pull request compares the merge commit with its first parent (fetch-depth: 2); pushes compare HEAD with itself and report nothing, which keeps them useful only for priming the cache.
  • --fix=false overrides fix: true in .golangci.yaml, so CI reports fixable issues instead of silently fixing them in the runner.
  • The golangci-lint cache is restored on every run and saved only on pushes to main, as in upstream's lint job, so pull requests cannot poison it.

The findings

None of them was a real bug. Fixes where a rewrite is clean, and a targeted //nolint with a reason, following upstream's existing precedent, where the flagged code is intentional:

Linter Where Resolution
revive unhandled-error (5) strings.Builder writes in fork_context.go, fork_isolation.go, fork_wakeups_internal_test.go _, _ = / _ =, as upstream does
revive unused-receiver taskStarter.commitForkContextMessage unnamed receiver
gocritic unlambda fork_context_internal_test.go use codersdk.ChatMessageText directly
gocritic boolExprSimplify subagentCanSpawn int(depth) < limits.maxDepth (same result)
misspell (5) "cancelled" comment fixed; nolint on the GitHub check-run conclusion value, its test fixture, and the stored todo status cancelled (an API and database value; the directive sits on the const block because swag copies a trailing comment into the API docs)
nilnil (5) tool policy, MCP slugs, pending descendant question nolint: a nil result means "none", and every caller checks for it
revive get-return (3) getForkChatFamilyCapacity, getChatDescendantQuestions, getChatTodos nolint, the same comment upstream puts on its HTTP handlers
revive flag-parameter (5) AncestorChatIDs, forkValidateSubagentResume, withSubagentWorktreePrompt, resolveRawPath, a test helper nolint; splitting them would duplicate the bodies, and two have callers in upstream files
gosec G306 (2) git hook fixtures in fork_worktrees_internal_test.go nolint: git runs only executable hooks
gosec G115 advisory lock key split in a test nolint: pg_locks stores the key as two 32-bit halves

Two of the flag-parameter findings come from #135, which merged while this PR was in progress.

Validation

  • golangci-lint over the covered packages with no --new-from-merge-base: 29 issues on main, 0 on this branch.
  • Gating: on main plus one new unhandled WriteString in fork_context.go, --new-from-merge-base=HEAD reports only that line (1 issue), while the ungated run reports 30, including the 3 existing findings in the same file.
  • go test on the touched chatd paths (TestNestedSubagent*, TestForkSpawnIsolation*, TestForkWorktreeBranch, TestTodoSnapshotMessage), ./coderd/externalauth/gitprovider and ./agent/agentgit: pass.
  • actionlint on fork-ci.yaml and shellcheck on the new run steps: clean.
  • .github/fork/check-apidoc.sh: no drift.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T12:50:22.321717Z b3eb384 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6352e99a6c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/fork-ci.yaml Resolved
Also moves the todo status misspell directive to the const block, since
swag copied the trailing comment into the API docs.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: b3eb384cfb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…i-go-lint

# Conflicts:
#	coderd/externalauth/gitprovider/fork_github_activity_test.go
#	coderd/x/chatd/fork_subagents.go

This branch has not been deployed

No deployments
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.

fork-ci: add a Go lint job and fix the existing golangci-lint findings in fork code

1 participant