Create go.yml - #1
Conversation
Reviewer's GuideAdds 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 ExecutionsequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v4 | ||
| with: | ||
| go-version: '1.20' |
There was a problem hiding this comment.
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.
| - 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' |
| - name: Build | ||
| run: go build -v ./... |
There was a problem hiding this comment.
suggestion: Add an explicit dependency fetch step
Adding go mod download before go build ensures all modules are available and improves build caching efficiency.
| - name: Build | |
| run: go build -v ./... | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Build | |
| run: go build -v ./... |
| - name: Build | ||
| run: go build -v ./... | ||
|
|
||
| - name: Test |
There was a problem hiding this comment.
suggestion (testing): Run tests with the race detector
Add -race to the test command in CI to detect data races in concurrent code.
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
| pull_request: | ||
| branches: [ "main" ] |
There was a problem hiding this comment.
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.
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| workflow_dispatch: |
Summary by Sourcery
CI: