Skip to content

feat: TASK-02 GitHub Actions CI#5

Merged
gaarutyunov merged 9 commits into
mainfrom
claude/issue-4-20260331-0747
Apr 1, 2026
Merged

feat: TASK-02 GitHub Actions CI#5
gaarutyunov merged 9 commits into
mainfrom
claude/issue-4-20260331-0747

Conversation

@gaarutyunov

@gaarutyunov gaarutyunov commented Mar 31, 2026

Copy link
Copy Markdown
Owner

Implements TASK-02: GitHub Actions CI

  • Add internal/testutil/containers.go with MustStartContainer helper
  • Add internal/testutil/smoke_integration_test.go smoke test for Testcontainers
  • NOTE: .github/workflows/ci.yml must be added manually (GitHub App lacks workflows permission)

Closes #4

Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added test utilities to simplify starting and managing container-based integration tests.
    • Added a smoke integration test to verify container startup, connectivity, and basic HTTP responses.
  • Chores
    • Added CI workflow to run linting, unit tests, and gated integration tests.
    • Refined CI/tooling configuration and allowed-tooling rules for automation.
    • Updated project module path and linting import-prefix configuration.

- Add .github/workflows/ci.yml with lint-and-test and integration-test jobs
- Add internal/testutil/containers.go with MustStartContainer helper
- Add internal/testutil/smoke_integration_test.go to verify Testcontainers Cloud

Co-authored-by: German Arutyunov <gaarutyunov@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds an internal test helper to start Testcontainers (MustStartContainer), a smoke integration test (build tag integration) that verifies Testcontainers via an nginx:alpine container, a CI workflow that runs lint/tests and gated integration tests using Testcontainers Cloud, updates a Claude workflow argument, and adjusts go module / linter local-prefixes.

Changes

Cohort / File(s) Summary
Testutil helpers & tests
internal/testutil/containers.go, internal/testutil/smoke_integration_test.go
New helper MustStartContainer(ctx, t, req) starts a container with Started: true, marks test helper, fails test on start error, and registers cleanup that logs terminate errors. New //go:build integration smoke test starts nginx:alpine, waits for HTTP readiness, resolves host/port, issues GET /, and asserts 200.
CI workflow
.github/workflows/ci.yml
New CI workflow triggered on push/pull_request to main, sets GOWORK=off, concurrency cancels in-progress runs; lint-and-test job runs checkout, setup-go, installs golangci-lint, runs go vet, golangci-lint, go test -race -count=1, and go build; integration-test needs lint-and-test, configures TC_CLOUD_TOKEN from secrets and runs go test -race -tags integration -count=1 -timeout 300s ./....
Claude workflow tweak
.github/workflows/claude.yml
Enables claude_args allowing specific Bash tool patterns (previously commented), explicitly listing allowed Bash commands/patterns.
Module & linter config
go.mod, .golangci.yml
Module path changed to github.com/gaarutyunov/mcp-anything; linters-settings.goimports.local-prefixes updated to match new module path.

Sequence Diagram(s)

sequenceDiagram
  participant GH as "GitHub Actions"
  participant Lint as "lint-and-test job"
  participant Int as "integration-test job"
  participant Helper as "testutil.MustStartContainer"
  participant TCCloud as "Testcontainers Cloud"
  participant Container as "nginx container"
  participant Test as "Integration Test (http.Client)"

  GH->>Lint: start lint-and-test
  Lint-->>GH: succeed
  GH->>Int: start integration-test (needs lint-and-test)
  Int->>Helper: MustStartContainer(ctx, req)
  Helper->>TCCloud: request container start (nginx:alpine)
  TCCloud->>Container: provision & start
  Container-->>Helper: started, host & mapped port
  Helper-->>Int: return container
  Int->>Test: perform HTTP GET http://host:port/
  Test->>Container: GET /
  Container-->>Test: 200 OK
  Int->>Container: c.Terminate() (via t.Cleanup)
  Container-->>TCCloud: stop & remove
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I nudged a tiny nginx to start,

clouds hummed softly, tests took part.
Cleanup queued like carrot stew,
CI blinked green and sprang anew —
a happy rabbit hops, "All through!"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes out-of-scope changes: updates to go.mod module path, .golangci.yml local-prefixes, and .github/workflows/claude.yml are unrelated to TASK-02 GitHub Actions CI requirements. Separate the module path changes (go.mod, .golangci.yml, claude.yml updates) into a dedicated PR, keeping this PR focused solely on TASK-02 CI implementation.
✅ 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 'feat: TASK-02 GitHub Actions CI' clearly and directly summarizes the main change: implementing GitHub Actions CI as specified in TASK-02.
Linked Issues check ✅ Passed The PR implements all core requirements from issue #4: .github/workflows/ci.yml with correct job structure and triggers, internal/testutil/containers.go with MustStartContainer helper, smoke_integration_test.go with nginx test, GOWORK=off configuration, and TC_CLOUD_TOKEN documentation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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 claude/issue-4-20260331-0747

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

@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

🧹 Nitpick comments (1)
internal/testutil/smoke_integration_test.go (1)

26-34: Use MustStartContainer here instead of reimplementing startup/cleanup.

Lines [26-34] duplicate logic already centralized in internal/testutil/containers.go. Reusing the helper avoids drift and keeps cleanup/error behavior consistent.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/testutil/smoke_integration_test.go` around lines 26 - 34, Replace
the manual GenericContainer startup/cleanup with the centralized helper
MustStartContainer from internal/testutil/containers.go: remove the explicit
testcontainers.GenericContainer call, error check, and t.Cleanup Terminate call,
and instead call MustStartContainer (passing ctx, t and the
ContainerRequest/req) to obtain the container; this reuses the existing
startup/error-handling/cleanup behavior and prevents duplication.
🤖 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/testutil/containers.go`:
- Line 14: The helper MustStartContainer currently has signature
MustStartContainer(t *testing.T, ctx context.Context, req
testcontainers.ContainerRequest); change it so context.Context is the first
parameter (e.g., MustStartContainer(ctx context.Context, t *testing.T, req
testcontainers.ContainerRequest)), update all call sites and any tests to pass
ctx first, and ensure any documentation or usages that rely on the old order are
adjusted; keep the function name and behavior unchanged besides the parameter
reorder.

In `@internal/testutil/smoke_integration_test.go`:
- Around line 45-49: Replace the plain http.Get call with a context-bounded
request: create a timeout context (e.g., ctx, cancel := context.WithTimeout(ctx,
10*time.Second); defer cancel()), build the request with
http.NewRequestWithContext(ctx, "GET", url, nil) and execute it with
http.DefaultClient.Do(req) instead of http.Get; update error handling around
resp, err (from http.Get) and ensure resp.Body.Close() stays deferred; remove
the nolint noctx comment.

---

Nitpick comments:
In `@internal/testutil/smoke_integration_test.go`:
- Around line 26-34: Replace the manual GenericContainer startup/cleanup with
the centralized helper MustStartContainer from internal/testutil/containers.go:
remove the explicit testcontainers.GenericContainer call, error check, and
t.Cleanup Terminate call, and instead call MustStartContainer (passing ctx, t
and the ContainerRequest/req) to obtain the container; this reuses the existing
startup/error-handling/cleanup behavior and prevents duplication.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 83eb35fb-b11f-4a16-a68a-d78baadbe272

📥 Commits

Reviewing files that changed from the base of the PR and between 769c564 and 05e2e53.

📒 Files selected for processing (2)
  • internal/testutil/containers.go
  • internal/testutil/smoke_integration_test.go

Comment thread internal/testutil/containers.go Outdated
Comment thread internal/testutil/smoke_integration_test.go Outdated
Removed concurrency setting for Testcontainers Cloud Client.
@gaarutyunov

Copy link
Copy Markdown
Owner Author

@claude fix org to gaarutyunov

Error: internal/testutil/containers.go:9:2: missing go.sum entry for module providing package github.com/testcontainers/testcontainers-go (imported by github.com/your-org/mcp-anything/internal/testutil); to add:
go get github.com/your-org/mcp-anything/internal/testutil
Error: Process completed with exit code 1

@claude

claude Bot commented Mar 31, 2026

Copy link
Copy Markdown

Claude finished @gaarutyunov's task in 5m 33s —— View job


Fixing module path and go.sum entry

  • Read go.mod and relevant files
  • Fix module path from your-org to gaarutyunov in go.mod
  • Run go mod tidy to generate go.sum — blocked by sandbox permissions
  • Push changes

What was done

Fixed go.mod module path: github.com/your-org/mcp-anythinggithub.qkg1.top/gaarutyunov/mcp-anything (commit a194f16, staged locally but not yet pushed — see below).

Blocker: missing go.sum

The go.sum file has never been committed to this repo, which is the root cause of the CI failure. Running go mod tidy is required to generate it, but the Claude Code action sandbox is blocking all go and git fetch/pull commands that aren't pre-approved.

How to fix

Option A — run locally (quickest):

git checkout claude/issue-4-20260331-0747
git pull
# go.mod already has the correct module path; just generate go.sum:
go mod tidy
git add go.mod go.sum
git commit -m "fix: update module path and generate go.sum"
git push

Option B — allow go commands in the Claude Code action:

Add allowed_tools to the workflow step that invokes the action so future runs can run go mod tidy automatically:

- uses: anthropics/claude-code-action@v1
  with:
    allowed_tools: "Bash(go mod tidy),Bash(git fetch *),Bash(git pull *)"
    # ... other inputs

Note: I cannot modify .github/workflows/ files (GitHub App lacks workflows permission), so Option A (running locally) is the simplest path.

@gaarutyunov

Copy link
Copy Markdown
Owner Author

@claude I added the tools

@claude

claude Bot commented Mar 31, 2026

Copy link
Copy Markdown

Claude finished @gaarutyunov's task in 2m 24s —— View job


Fixing module path and code review issues

  • Gather context (reading current files)
  • Fix module path your-orggaarutyunov in go.mod and .golangci.yml
  • Fix context.Context parameter order in MustStartContainer (ctx is now first)
  • Replace http.Get with context-bounded request in smoke test
  • Use MustStartContainer helper in smoke test (removed duplication)
  • Commit and push (commit 6a09315)
  • Run go mod tidyblocked, see below

Still needed: go mod tidy

The go.sum file is missing from the repo, which causes the CI build error. I couldn't run go mod tidy because there's a syntax error in .github/workflows/claude.yml line 49 — a missing comma between the two tool specs:

# Current (broken):
claude_args: '--allowed-tools Bash(make:*)Bash(go mod tidy),Bash(git fetch *),Bash(git pull *)'

# Fix (add comma after Bash(make:*)):
claude_args: '--allowed-tools Bash(make:*),Bash(go mod tidy),Bash(git fetch *),Bash(git pull *)'

Please fix that comma, then either:

  • Run go mod tidy && git add go.sum && git commit -m "fix: generate go.sum" && git push locally, or
  • Tag @claude again after fixing the comma and I'll run it

- Change module path from github.com/your-org/mcp-anything to github.com/gaarutyunov/mcp-anything
- Update .golangci.yml local-prefixes to match
- Fix context.Context parameter order in MustStartContainer (ctx first, per conventions)
- Replace http.Get with context-bounded request in smoke test
- Use MustStartContainer helper in smoke test to remove duplication

Co-authored-by: German Arutyunov <gaarutyunov@users.noreply.github.com>

@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.

🧹 Nitpick comments (1)
internal/testutil/containers.go (1)

23-26: Bound cleanup termination with a timeout.

Line [24] uses context.Background() for container teardown. If Docker/Testcontainers is slow or unreachable, cleanup can block too long. Prefer a timeout-bound context.

Proposed change
 import (
 	"context"
 	"testing"
+	"time"

 	"github.com/testcontainers/testcontainers-go"
 )
@@
 	t.Cleanup(func() {
-		if err := c.Terminate(context.Background()); err != nil {
+		termCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+		defer cancel()
+		if err := c.Terminate(termCtx); err != nil {
 			t.Logf("terminate container %q: %v", req.Image, err)
 		}
 	})
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/testutil/containers.go` around lines 23 - 26, The cleanup currently
calls c.Terminate(context.Background()) which can block indefinitely; change the
t.Cleanup closure to create a timeout-bound context (e.g., ctx, cancel :=
context.WithTimeout(context.Background(), <reasonable duration>) and defer
cancel()) and pass that ctx to c.Terminate; update imports to include time if
needed and ensure the cancel is deferred inside the closure so the termination
is bounded and resources are released.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/testutil/containers.go`:
- Around line 23-26: The cleanup currently calls
c.Terminate(context.Background()) which can block indefinitely; change the
t.Cleanup closure to create a timeout-bound context (e.g., ctx, cancel :=
context.WithTimeout(context.Background(), <reasonable duration>) and defer
cancel()) and pass that ctx to c.Terminate; update imports to include time if
needed and ensure the cancel is deferred inside the closure so the termination
is bounded and resources are released.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8c3c1170-d538-48bc-8f97-f3d6948af01e

📥 Commits

Reviewing files that changed from the base of the PR and between 240aa5d and 6a09315.

📒 Files selected for processing (4)
  • .golangci.yml
  • go.mod
  • internal/testutil/containers.go
  • internal/testutil/smoke_integration_test.go
✅ Files skipped from review due to trivial changes (3)
  • .golangci.yml
  • go.mod
  • internal/testutil/smoke_integration_test.go

@gaarutyunov

Copy link
Copy Markdown
Owner Author

@claude fixed it

@claude

claude Bot commented Mar 31, 2026

Copy link
Copy Markdown

Claude finished @gaarutyunov's task in 1m 42s —— View job


Fixes applied

  • Gather context
  • Fix CodeRabbit nitpick: bound container cleanup with 30s timeout in containers.go (commit ec99b32)
  • Run go mod tidy to generate go.sum — blocked, see below

Still needed: go mod tidy

go mod tidy still can't run in this session because the claude.yml fix (adding Bash(go mod tidy) to allowed-tools) is on this PR branch, but GitHub Actions runs the workflow file from the main branch for issue_comment events. So the fix isn't active until it's merged.

To unblock CI, please run locally:

git checkout claude/issue-4-20260331-0747
git pull
go mod tidy
git add go.sum
git commit -m "fix: generate go.sum"
git push

Once go.sum is committed, the CI should pass.
| Branch

github-actions Bot and others added 2 commits March 31, 2026 11:30
CodeRabbit nitpick: c.Terminate(context.Background()) could block indefinitely;
use a timeout-bound context instead.

Co-authored-by: German Arutyunov <gaarutyunov@users.noreply.github.com>
- Add go.sum (was never committed, causing CI vet failure)
- Fix incorrect reggen pseudo-version hash in go.mod
- Update .golangci.yml for golangci-lint v2 (move gofmt/goimports to
  formatters, remove gosimple merged into staticcheck)
- Add package comment to cmd/proxy/main.go (revive)
- Suppress contextcheck on cleanup closure that intentionally uses fresh context
- Run go mod tidy to prune unused dependencies

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gaarutyunov
gaarutyunov merged commit 8fb4c6d into main Apr 1, 2026
2 checks passed
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.

TASK-02: GitHub Actions CI

1 participant