Skip to content

Create go.yml - #1

Open
allyelvis wants to merge 1 commit into
mainfrom
allyelvis-patch-1
Open

Create go.yml#1
allyelvis wants to merge 1 commit into
mainfrom
allyelvis-patch-1

Conversation

@allyelvis

@allyelvis allyelvis commented May 31, 2025

Copy link
Copy Markdown
Owner

Summary by Sourcery

CI:

  • Introduce a Go CI workflow using GitHub Actions to set up Go 1.20, build with go build, and run go test on ubuntu-latest

@sourcery-ai

sourcery-ai Bot commented May 31, 2025

Copy link
Copy Markdown

Reviewer's Guide

Adds a new GitHub Actions workflow to automatically build and test the Go code on push and pull-request events targeting the main branch.

Sequence Diagram for the Go CI Workflow Execution

sequenceDiagram
    actor Developer
    participant GitHubRepo as "GitHub Repository"
    participant GitHubActions as "GitHub Actions"
    participant Runner as "CI Runner (ubuntu-latest)"

    Developer->>GitHubRepo: Push code to 'main' / Create PR for 'main'
    GitHubRepo->>GitHubActions: Trigger 'Go' Workflow (on: push/pull_request)
    GitHubActions->>Runner: Dispatch 'build' job
    Runner->>Runner: Run Step: actions/checkout@v4
    Runner->>Runner: Run Step: actions/setup-go@v4 (Go 1.20)
    Runner->>Runner: Run Step: go build -v ./...
    Runner->>Runner: Run Step: go test -v ./...
    Runner-->>GitHubActions: Job status (success/failure)
    GitHubActions-->>GitHubRepo: Workflow status (e.g., PR check update)
    GitHubRepo-->>Developer: Notify Developer of CI status
Loading

File-Level Changes

Change Details Files
Introduce Go build-and-test workflow
  • Define triggers on push and pull_request for the main branch
  • Use ubuntu-latest runner environment
  • Checkout repository code with actions/checkout@v4
  • Set up Go 1.20 using actions/setup-go@v4
  • Add build step executing go build -v ./...
  • Add test step executing go test -v ./...
.github/workflows/go.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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

Hey @allyelvis - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .github/workflows/go.yml
Comment on lines +17 to +22
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (performance): Consider adding module and build cache to speed up CI

Adding an actions/cache step for ~/.cache/go-build and $GOPATH/pkg/mod after checkout can reduce CI build times.

Suggested change
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
- uses: actions/checkout@v4
- name: Cache Go modules and build cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
${{ env.GOPATH }}/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'

Comment thread .github/workflows/go.yml
Comment on lines +24 to +25
- name: Build
run: go build -v ./...

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Add an explicit dependency fetch step

Adding go mod download before go build ensures all modules are available and improves build caching efficiency.

Suggested change
- name: Build
run: go build -v ./...
- name: Download dependencies
run: go mod download
- name: Build
run: go build -v ./...

Comment thread .github/workflows/go.yml
- name: Build
run: go build -v ./...

- name: Test

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (testing): Run tests with the race detector

Add -race to the test command in CI to detect data races in concurrent code.

Comment thread .github/workflows/go.yml
Comment on lines +6 to +10
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Consider adding a manual workflow trigger

Including workflow_dispatch: allows you to trigger the workflow manually from the GitHub UI for ad-hoc testing.

Suggested change
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

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.

1 participant