Skip to content

ci: New Go workfow for linting, testing and building the Capture #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 26, 2025

Conversation

mertssmnoglu
Copy link
Member

@mertssmnoglu mertssmnoglu commented Apr 26, 2025

Summary by CodeRabbit

  • Chores
    • Introduced a new workflow that runs both code linting and tests on pull requests targeting "main" and "develop" branches.
    • Removed a Linux-specific system information test.
    • Added architectural dependency rules to enforce package boundaries. Using https://github.com/mstrYoda/go-arctest

@mertssmnoglu mertssmnoglu added the ci-cd This issue or pull request regarding the CI/CD pipeline label Apr 26, 2025
@mertssmnoglu mertssmnoglu self-assigned this Apr 26, 2025
Copy link
Contributor

coderabbitai bot commented Apr 26, 2025

Warning

Rate limit exceeded

@mertssmnoglu has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 54 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 32e6788 and e491a7f.

📒 Files selected for processing (1)
  • .github/workflows/go.yml (1 hunks)

Walkthrough

A new GitHub Actions workflow file, .github/workflows/go.yml, has been added, and the previous .github/workflows/lint.yml workflow file has been removed. The new workflow consolidates both linting and testing jobs for Go projects, triggering on pull requests to the "main" and "develop" branches. The lint job uses golangci-lint, while the test job sets up the Go environment and runs tests on a specific package. The Go test file test/host_linux_test.go containing the TestHostLinux function was deleted. A new test file test/arch_test.go was added to enforce architectural dependency rules using the arctest package. The go.mod file was updated to add new dependencies for the arctest tool. No changes to exported or public code entities were made.

Changes

File(s) Change Summary
.github/workflows/go.yml Added a new workflow with lint and test jobs for Go, triggered on PRs to "main" and "develop".
.github/workflows/lint.yml Removed the previous workflow that only performed linting on PRs.
test/host_linux_test.go Deleted the test file containing TestHostLinux which verified host information retrieval.
test/arch_test.go Added a new test file enforcing architectural dependency rules using the arctest package.
go.mod Added new dependencies: github.com/mstrYoda/go-arctest and indirect github.com/stretchr/objx.

Sequence Diagram(s)

sequenceDiagram
    participant GitHub PR
    participant go.yml Workflow
    participant Lint Job
    participant Test Job

    GitHub PR->>go.yml Workflow: PR opened/updated (main/develop)
    go.yml Workflow->>Lint Job: Start lint job
    Lint Job->>Lint Job: Checkout code\nRun golangci-lint
    go.yml Workflow->>Test Job: Start test job
    Test Job->>Test Job: Checkout code\nSetup Go\nRun go test
Loading

Poem

🐇
A hop and a skip, the workflows renew,
Lint and test together, a streamlined view!
The old just for linting, now gone from the warren,
With checks now combined, our code is less barren.
New rules to keep code neat and tight,
The arch test guards the path just right.
On every PR, let the green checks show—
The rabbit approves, let the quality grow!


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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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.

Copy link
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: 0

🧹 Nitpick comments (2)
.github/workflows/go.yml (2)

10-20: Consider caching dependencies in lint job
To improve CI performance, you can cache Go modules (and golangci-lint’s cache) between runs. This is an optional enhancement but often yields significant speed-ups.

Proposed diff:

   lint:
     runs-on: ubuntu-22.04
     steps:
       - name: Checkout
         uses: actions/checkout@v4
         with:
           fetch-depth: 0

+      - name: Cache Go modules for lint
+        uses: actions/cache@v3
+        with:
+          path: |
+            ~/.cache/go-build
+            ~/go/pkg/mod
+          key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
+          restore-keys: |
+            ${{ runner.os }}-go-mod-

       - name: Golangci-lint
         uses: golangci/[email protected]

21-32: Verify test scope and consider caching
Currently the test step runs only against github.com/bluewave-labs/capture/test. If you intended to run all packages’ tests, switch to go test ./.... You may also cache Go modules in the test job to speed up runs.

Example diff:

   test:
     runs-on: ubuntu-22.04
     steps:
       - name: Checkout
         uses: actions/checkout@v4
         with:
           fetch-depth: 0
       - uses: actions/setup-go@v5
         with:
           go-version-file: 'go.mod'
+      - name: Cache Go modules
+        uses: actions/cache@v3
+        with:
+          path: |
+            ~/.cache/go-build
+            ~/go/pkg/mod
+          key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
+          restore-keys: |
+            ${{ runner.os }}-go-mod-
       - run: |
-          go test -v -timeout 30s github.com/bluewave-labs/capture/test
+          go test -v -timeout 30s ./...
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c8e1a73 and 9e10c36.

📒 Files selected for processing (2)
  • .github/workflows/go.yml (1 hunks)
  • .github/workflows/lint.yml (0 hunks)
💤 Files with no reviewable changes (1)
  • .github/workflows/lint.yml
🔇 Additional comments (2)
.github/workflows/go.yml (2)

1-2: Workflow naming is clear
No concerns with naming the workflow “go” as it succinctly reflects its purpose.


3-8: Triggers correctly configured for PR validation
The workflow will run on pull requests targeting both main and develop branches, which aligns with the repository’s branching strategy.

- github.com/mstrYoda/go-arctest/pkg/arctest

Signed-off-by: Mert Şişmanoğlu <[email protected]>
Copy link
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: 0

🧹 Nitpick comments (2)
test/arch_test.go (2)

26-35: LGTM, with a suggestion for future expansion

The validation logic looks good. As the codebase grows, consider extending this test to include additional architectural rules.

In the future, you might want to structure this to make adding new rules easier, perhaps by creating a slice of rules at the beginning of the test function and appending to it, rather than having to modify the ValidateDependenciesWithRules call each time.


1-36: Consider adding documentation about the architectural pattern

The test effectively enforces architectural boundaries, but it would be helpful to include more context about the overall architectural pattern being enforced.

Consider adding a comment at the top of the file explaining the high-level architectural approach of the project and why these specific boundaries are important. This would be valuable documentation for new contributors.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d7a14b9 and 32e6788.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • go.mod (2 hunks)
  • test/arch_test.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • go.mod
🔇 Additional comments (3)
test/arch_test.go (3)

1-8: Good choice using the go-arctest library for architecture testing!

The inclusion of architecture testing is a valuable addition to ensure the codebase maintains proper separation of concerns and dependency management. The go-arctest library is a good choice for this purpose.


9-19: LGTM on initial setup and error handling

The initialization of the architecture testing framework is well-structured with appropriate error handling for both the initial setup and package parsing steps.


20-24: Good architectural boundary enforcement

This rule enforces a clean separation between the command layer and internal handlers, which is a sound architectural principle. This helps maintain a clear dependency direction and prevents circular dependencies.

Signed-off-by: Mert Şişmanoğlu <[email protected]>
@mertssmnoglu mertssmnoglu changed the title ci: Merge lint and test workflows in go.yml ci: Go Workfow for linting, testing and building the Capture Apr 26, 2025
@mertssmnoglu mertssmnoglu changed the title ci: Go Workfow for linting, testing and building the Capture ci: New Go workfow for linting, testing and building the Capture Apr 26, 2025
@mertssmnoglu mertssmnoglu merged commit c0daa23 into develop Apr 26, 2025
4 checks passed
@mertssmnoglu mertssmnoglu deleted the ci-lint-and-test branch April 26, 2025 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-cd This issue or pull request regarding the CI/CD pipeline
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant