Skip to content

ci: break out integration tests from unit #2369

Merged
tac0turtle merged 14 commits intomainfrom
marko/test_integration
Jun 11, 2025
Merged

ci: break out integration tests from unit #2369
tac0turtle merged 14 commits intomainfrom
marko/test_integration

Conversation

@tac0turtle
Copy link
Copy Markdown
Contributor

@tac0turtle tac0turtle commented Jun 11, 2025

Overview

This pr splits the unit tests from integration in node. this allows the integration tests to have a custom job for integration test as the integration tests were flaky

Summary by CodeRabbit

  • New Features

    • Added new commands to run integration tests and generate integration test coverage reports.
  • Refactor

    • Updated test and coverage commands for improved integration test handling and coverage reporting.
    • Adjusted test job workflow to separate unit and integration test coverage, with combined reporting.
  • Chores

    • Introduced build tags and linter directives to better organize test files and suppress unused code warnings.
    • Improved test isolation by using separate in-memory datastores during service restarts.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 11, 2025

Walkthrough

This update restructures test workflows and scripts to better separate unit and integration tests. It introduces new build constraints to distinguish integration tests, adds new Makefile targets for integration testing and coverage, and modifies CI to collect and combine coverage from both unit and integration tests before uploading to Codecov. The test for header sync service restart now uses a fresh datastore on restart.

Changes

File(s) Change Summary
.github/workflows/test.yml Refactored workflow: uploads coverage as artifacts, adds integration test and coverage combination jobs, updates dependencies.
scripts/test.mk Added test-integration and test-integration-cover targets; adjusted test and removed cover targets for new test/coverage flow.
node/execution_test.go, node/full_node_test.go, node/single_sequencer_test.go Added //go:build !integration constraint to exclude from integration builds.
node/full_node_integration_test.go, node/single_sequencer_integration_test.go Added //go:build integration constraint to include only in integration builds.
node/helpers.go, node/helpers_test.go Added //nolint:unused to suppress linter warnings for unused code.
pkg/sync/sync_service_test.go Modified TestHeaderSyncServiceRestart to use a new in-memory datastore on restart.

Sequence Diagram(s)

sequenceDiagram
    participant CI
    participant UnitTest
    participant IntegrationTest
    participant ArtifactStore
    participant CoverageCombiner
    participant Codecov

    CI->>UnitTest: Run unit tests
    UnitTest->>ArtifactStore: Upload unit test coverage artifact

    CI->>IntegrationTest: Run integration tests
    IntegrationTest->>ArtifactStore: Upload integration test coverage artifact

    CI->>CoverageCombiner: Combine coverage artifacts
    CoverageCombiner->>ArtifactStore: Download unit & integration coverage
    CoverageCombiner->>Codecov: Upload combined coverage
Loading

Possibly related PRs

  • rollkit/rollkit#2302: Also modifies .github/workflows/test.yml for CI test workflow and coverage handling, related through CI and coverage changes.
  • rollkit/rollkit#2362: Modifies TestHeaderSyncServiceRestart in pkg/sync/sync_service_test.go for improved test reliability, directly related to changes in the same test.

Suggested reviewers

  • Manav-Aggarwal
  • julienrbrt

Poem

In the warren where tests now hop,
Integration and unit, each with their stop.
Coverage combined, artifacts in tow,
Fresh datastores sprout where old ones go.
With tags and scripts, the garden’s neat—
Every test, a carrot treat! 🥕


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 69efdf4 and 9e111ba.

📒 Files selected for processing (1)
  • scripts/test.mk (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/test.mk
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: test / Run Unit Tests
  • GitHub Check: test / Run Integration Tests
  • GitHub Check: test / Build Docker Image
  • GitHub Check: test / Build All Rollkit Binaries
  • GitHub Check: lint / markdown-lint
  • GitHub Check: lint / golangci-lint
  • GitHub Check: Analyze (go)
  • GitHub Check: Summary

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 11, 2025

The latest Buf updates on your PR. Results from workflow CI and Release / buf-check (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped✅ passed✅ passedJun 11, 2025, 1:52 PM

Comment thread .github/workflows/test.yml Fixed
Comment thread .github/workflows/test.yml Fixed
Comment thread .github/workflows/test.yml Fixed
tac0turtle and others added 8 commits June 11, 2025 12:07
name: integration-test-coverage-report-${{ github.sha }}
path: ./integration-coverage
- name: Upload combined coverage report
uses: codecov/codecov-action@v5.4.3

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium test

Unpinned 3rd party Action 'Tests / Code Coverage' step
Uses Step
uses 'codecov/codecov-action' with ref 'v5.4.3', not a pinned commit hash
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.76%. Comparing base (cacaec2) to head (2ee27b5).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2369      +/-   ##
==========================================
+ Coverage   69.70%   69.76%   +0.06%     
==========================================
  Files          64       64              
  Lines        6241     6241              
==========================================
+ Hits         4350     4354       +4     
+ Misses       1501     1497       -4     
  Partials      390      390              
Flag Coverage Δ
combined 69.76% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tac0turtle tac0turtle marked this pull request as ready for review June 11, 2025 12:30
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
.github/workflows/test.yml (1)

150-154: 🛠️ Refactor suggestion

Unpinned 3rd-party Action – security hardening

codecov/codecov-action@v5.4.3 is a version tag, not a commit SHA.
Pin to a full SHA per GHAS recommendation:

- uses: codecov/codecov-action@v5.4.3
+ uses: codecov/codecov-action@ae5e...  # exact commit
🧰 Tools
🪛 GitHub Check: CodeQL

[warning] 150-150: Unpinned tag for a non-immutable Action in workflow
Unpinned 3rd party Action 'Tests / Code Coverage' step Uses Step uses 'codecov/codecov-action' with ref 'v5.4.3', not a pinned commit hash

🧹 Nitpick comments (7)
node/helpers_test.go (1)

1-1: Avoid file-wide nolint – tame the warning closer to the source

A blanket //nolint:unused suppresses all unused-code warnings for the whole file and can hide genuine mistakes.
Consider either (a) removing the directive entirely, or (b) moving it to the specific helpers that are intentionally left unused.

-//nolint:unused
+// nolint:unused // keep only if absolutely sure the whole file should skip the check
node/helpers.go (1)

1-1: Duplicate “unused” suppression – consider trimming

You now have a file-level //nolint:unused as well as one on safeClose.
If only safeClose needs the exemption, the broader directive can be dropped to keep linter noise under control.

node/full_node_integration_test.go (1)

1-2: Add legacy +build tag (optional)

If you still support Go ≤1.16 tool-chains (e.g. downstream consumers using old IDEs), append the legacy build tag comment:

// +build integration

immediately above the new //go:build integration line.
Not required for Go ≥1.17, but harmless and increases compatibility.

node/single_sequencer_test.go (1)

1-2: Consider including legacy build tag for wider compatibility

Same rationale as the previous file – add:

// +build !integration

just below the modern constraint if Go ≤ 1.16 users must still be able to run go test.

node/single_sequencer_integration_test.go (1)

1-2: Mirror legacy build tag (optional)

// +build integration

will keep pre-1.17 tool-chains happy.
Feel free to ignore if the project policy is “Go ≥ 1.20 only”.

scripts/test.mk (1)

31-35: Message copy-paste nit – says “e2e” but runs integration tests

The echo still says “Running e2e tests”; update to reduce confusion.

-	@echo "--> Running e2e tests"
+	@echo "--> Running integration tests"
.github/workflows/test.yml (1)

80-84: Permission block missing on unit_test job

Other newly added jobs specify minimal permissions. For parity and to silence GHAS warnings, add:

permissions:
  contents: read

under unit_test.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 619bd55 and 69efdf4.

📒 Files selected for processing (10)
  • .github/workflows/test.yml (3 hunks)
  • node/execution_test.go (1 hunks)
  • node/full_node_integration_test.go (1 hunks)
  • node/full_node_test.go (1 hunks)
  • node/helpers.go (1 hunks)
  • node/helpers_test.go (1 hunks)
  • node/single_sequencer_integration_test.go (1 hunks)
  • node/single_sequencer_test.go (1 hunks)
  • pkg/sync/sync_service_test.go (2 hunks)
  • scripts/test.mk (2 hunks)
🧰 Additional context used
🪛 GitHub Check: CodeQL
.github/workflows/test.yml

[warning] 150-150: Unpinned tag for a non-immutable Action in workflow
Unpinned 3rd party Action 'Tests / Code Coverage' step Uses Step uses 'codecov/codecov-action' with ref 'v5.4.3', not a pinned commit hash

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (5)
pkg/sync/sync_service_test.go (1)

82-94: Good call isolating state with a fresh datastore

Switching to restartedKV ensures the restarted service doesn’t see artefacts from the first run – this makes the restart logic far more deterministic. 👍

node/full_node_test.go (1)

1-2: Build tag looks correct

The //go:build !integration directive cleanly splits unit from integration tests and is placed at the required very first line. No issues detected.

node/execution_test.go (1)

1-2: Build tag looks correct

Same remark as above – the exclusion tag is correctly applied.

scripts/test.mk (1)

10-10: Unit-test target unintentionally enables integration code

go run -tags='run integration' sets BOTH the run and integration tags, which contradicts the intent of keeping integration tests out of the unit-test job.
Verify that scripts/test.go really needs the integration tag. Most likely the unit pipeline should exclude it:

-	@go run -tags='run integration' scripts/test.go
+	@go run -tags=run scripts/test.go

or pass -tags='run,!integration' inside the helper script.
Please double-check – failing to exclude the tag will compile integration-only files and defeat the split.

.github/workflows/test.yml (1)

85-103: Reuse artifact filename constant or path mismatch risk

make test-integration-cover writes coverage.txt inside node/, but the upload step expects ./node/coverage.txt. Good now, but fragile if the relative cd changes.
Consider:

path: ${{ github.workspace }}/node/coverage.txt

or emit to the workspace root for symmetry with unit tests.

Comment thread scripts/test.mk Outdated
@echo "--> Generating Code Coverage"
@go install github.com/ory/go-acc@latest
@go-acc -o coverage.txt ./...
@go tool cover -mode=set -o coverage.txt ./...
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.

⚠️ Potential issue

cover target will fail – invalid go tool cover usage

go tool cover does not accept -mode or packages; it only consumes an existing coverage profile.
Current command will exit with “unknown flag: -mode”.
Replace the target with a proper go test invocation that creates the profile:

-	@go tool cover -mode=set -o coverage.txt ./...
+	@go test -mod=readonly -failfast -timeout=15m -tags='!integration' \
+	       -coverprofile=coverage.txt -covermode=atomic ./...

This mirrors what you do for test-integration-cover and restores CI green.

🤖 Prompt for AI Agents
In scripts/test.mk at line 28, the `go tool cover` command is incorrectly used
with the `-mode` flag and package arguments, which it does not support. Replace
this line with a `go test` command that runs tests with coverage enabled and
outputs a coverage profile file, similar to the `test-integration-cover` target.
This will generate a valid coverage profile for use with `go tool cover` and
prevent the command from failing.

@tac0turtle tac0turtle added this pull request to the merge queue Jun 11, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 11, 2025
@tac0turtle tac0turtle added this pull request to the merge queue Jun 11, 2025
Merged via the queue into main with commit 7808d2d Jun 11, 2025
26 checks passed
@tac0turtle tac0turtle deleted the marko/test_integration branch June 11, 2025 14:32
@github-project-automation github-project-automation Bot moved this to Done in Evolve Jun 11, 2025
@tac0turtle tac0turtle removed this from Evolve Aug 25, 2025
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