-
Notifications
You must be signed in to change notification settings - Fork 3
Update CI and linter, fix issues #23
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
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #23 +/- ##
===========================================
- Coverage 85.00% 72.22% -12.78%
===========================================
Files 4 5 +1
Lines 280 504 +224
===========================================
+ Hits 238 364 +126
- Misses 23 121 +98
Partials 19 19
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI Code Review by LlamaPReview
🎯 TL;DR & Recommendation
Recommendation: Request Changes
This PR updates CI workflows but introduces critical risks: test coverage analysis now depends on GitHub API which may fail, and release tooling uses non-deterministic Go versions leading to inconsistent results.
🌟 Strengths
- Updates dependencies and linter configurations to newer versions.
- Maintains test success across multiple Go versions.
| Priority | File | Category | Impact Summary | Anchors |
|---|---|---|---|---|
| P1 | .github/workflows/test-unit.yml | Testing | Test coverage depends on GitHub API, may fail | method:gocovdiff search:pull_request.diff |
| P1 | .github/workflows/gorelease.yml | Architecture | Non-deterministic Go version in release tooling | constant:GO_VERSION search:stable |
| P2 | .github/workflows/release-assets.yml | Architecture | Debug binaries uploaded without build clarity | search:linux_amd64_dbg method:upload-release-asset |
| P2 | .golangci.yml | Maintainability | Linter config may introduce noise and maintenance burden | |
| P2 | equal.go | Maintainability | Uses deprecated bytes.Replace instead of ReplaceAll | method:bytes.Replace search:gocritic,staticcheck |
| P2 | cmd/jsoncompact/main.go | Maintainability | Blanket nolint directive could hide issues | method:fmt.Fprintln search:nolint |
🔍 Notable Themes
- Multiple CI workflow changes introduce external dependencies and non-deterministic behavior, increasing failure risks.
- Maintainability issues with linter configurations and directives could lead to technical debt and hidden problems.
📈 Risk Diagram
This diagram illustrates the new test coverage analysis flow and its dependency on GitHub API.
sequenceDiagram
participant CI as CI System
participant GA as GitHub API
participant GC as gocovdiff Tool
CI->>GA: Fetch PR diff (with token)
GA-->>CI: Return diff or error
CI->>GC: Analyze coverage with diff file
GC-->>CI: Coverage report
note over CI,GA: R1(P1): Dependency on GitHub API may fail due to rate limits or permissions
💡 Have feedback? We'd love to hear it in our GitHub Discussions.
✨ This review was generated by LlamaPReview Advanced, which is free for all open-source projects. Learn more.
| curl -sLO https://github.com/vearutop/gocovdiff/releases/download/v1.4.2/linux_amd64.tar.gz && tar xf linux_amd64.tar.gz && rm linux_amd64.tar.gz | ||
| gocovdiff_hash=$(git hash-object ./gocovdiff) | ||
| [ "$gocovdiff_hash" == "8e507e0d671d4d6dfb3612309b72b163492f28eb" ] || (echo "::error::unexpected hash for gocovdiff, possible tampering: $gocovdiff_hash" && exit 1) | ||
| git fetch origin master ${{ github.event.pull_request.base.sha }} | ||
| REP=$(./gocovdiff -cov unit.coverprofile -gha-annotations gha-unit.txt -delta-cov-file delta-cov-unit.txt -target-delta-cov ${TARGET_DELTA_COV}) | ||
| [ "$gocovdiff_hash" == "c37862c73a677e5a9c069470287823ab5bbf0244" ] || (echo "::error::unexpected hash for gocovdiff, possible tampering: $gocovdiff_hash" && exit 1) | ||
| # Fetch PR diff from GitHub API. | ||
| curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3.diff" https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} > pull_request.diff | ||
| REP=$(./gocovdiff -diff pull_request.diff -mod github.com/$GITHUB_REPOSITORY -cov unit.coverprofile -gha-annotations gha-unit.txt -delta-cov-file delta-cov-unit.txt -target-delta-cov ${TARGET_DELTA_COV}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1 | Confidence: High
The test coverage analysis now fetches PR diff via GitHub API instead of using git fetch, which changes the fundamental approach to determining code changes. This introduces a dependency on GitHub API rate limits and authentication that wasn't present before. The new method may fail if the GitHub token lacks permissions or if API limits are exceeded, potentially breaking the coverage analysis workflow. The removal of git fetch also means the analysis no longer has access to the actual base commit files, which could lead to inaccurate coverage calculations.
| GO_VERSION: stable | ||
| jobs: | ||
| gorelease: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Install Go stable | ||
| if: env.GO_VERSION != 'tip' | ||
| uses: actions/setup-go@v4 | ||
| - name: Install Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: ${{ env.GO_VERSION }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1 | Confidence: High
The change replaces specific Go version pinning (1.20.x) with 'stable', which introduces non-deterministic build behavior. This could cause the gorelease tool to analyze the code against different Go versions over time, potentially leading to inconsistent API compatibility reports. For a release tooling workflow, deterministic behavior is critical to ensure consistent analysis results across different runs.
| GO_VERSION: stable | |
| jobs: | |
| gorelease: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Install Go stable | |
| if: env.GO_VERSION != 'tip' | |
| uses: actions/setup-go@v4 | |
| - name: Install Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| env: | |
| GO_VERSION: 1.21.x # Pin to a specific supported version |
Evidence: constant:GO_VERSION, search:stable
| } | ||
|
|
||
| expected = bytes.Replace(expected, []byte(`"`+k+`"`), j, -1) //nolint:gocritic // To support go1.11. | ||
| expected = bytes.Replace(expected, []byte(`"`+k+`"`), j, -1) //nolint:gocritic,staticcheck // To support go1.11. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2 | Confidence: High
The added staticcheck nolint directive suppresses a legitimate lint warning about using deprecated functionality (bytes.Replace with -1 count). Since the project now uses Go 1.17+ (per go.mod), this should be updated to use bytes.ReplaceAll() for better clarity and forward compatibility, as the current approach relies on deprecated behavior.
| expected = bytes.Replace(expected, []byte(`"`+k+`"`), j, -1) //nolint:gocritic,staticcheck // To support go1.11. | |
| expected = bytes.ReplaceAll(expected, []byte(`"`+k+`"`), j) |
Evidence: method:bytes.Replace, search:gocritic,staticcheck
| input = flag.Arg(0) | ||
| if input == "" { | ||
| _, _ = fmt.Fprintln(flag.CommandLine.Output(), "Missing input path argument, use `-` for stdin.") | ||
| _, _ = fmt.Fprintln(flag.CommandLine.Output(), "Missing input path argument, use `-` for stdin.") //nolint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2 | Confidence: High
The blanket nolint directive suppresses all linter warnings without specifying which linter or warning is being ignored. This makes the code harder to maintain and could hide legitimate issues. Specific linters should be named in the nolint directive to ensure only intended warnings are suppressed.
| _, _ = fmt.Fprintln(flag.CommandLine.Output(), "Missing input path argument, use `-` for stdin.") //nolint | |
| _, _ = fmt.Fprintln(flag.CommandLine.Output(), "Missing input path argument, use `-` for stdin.") //nolint:errcheck |
Evidence: method:fmt.Fprintln, search:nolint
| - name: Upload linux_amd64_dbg.tar.gz | ||
| if: hashFiles('linux_amd64_dbg.tar.gz') != '' | ||
| uses: actions/upload-release-asset@v1 | ||
| with: | ||
| upload_url: ${{ github.event.release.upload_url }} | ||
| asset_path: ./linux_amd64_dbg.tar.gz | ||
| asset_name: linux_amd64_dbg.tar.gz | ||
| asset_content_type: application/tar+gzip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2 | Confidence: Medium
Speculative: The addition of debug binary uploads suggests the build process now generates debug artifacts, but there's no corresponding change in the Makefile to show how these are built. Without seeing the build configuration changes, it's unclear if debug symbols are properly stripped from release binaries or if debug builds follow security best practices (e.g., not including sensitive information).
| linters: | ||
| enable-all: true | ||
| default: all | ||
| disable: | ||
| - nilnil | ||
| - tparallel | ||
| - goerr113 | ||
| - err113 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2 | Confidence: Medium
The linter configuration switches from enabling specific linters to enabling all and then disabling many. This approach may catch more issues but could introduce noise from linters not suited to this codebase. The extensive disable list (28+ linters) suggests the 'enable all' approach might not be optimal for this project's coding style and could make the configuration harder to maintain.
No description provided.