Skip to content

Latest commit

 

History

History
170 lines (124 loc) · 3.8 KB

File metadata and controls

170 lines (124 loc) · 3.8 KB

Latest Fixes - GitHub Actions Permissions & Go 1.24 Compatibility

Problems Solved

✅ 1. PR Comment Permission Error (403)

Error: Resource not accessible by integration

Fix: Added permissions to workflow

permissions:
  contents: read
  pull-requests: write
  issues: write

✅ 2. golangci-lint Go 1.24 Incompatibility

Error: go language version (go1.23) used to build golangci-lint is lower than targeted Go version (1.24.0)

Fix: Replaced golangci-lint with native Go tools that always support your Go version:

  • go vet - Static analysis
  • gofmt -s - Code formatting
  • goimports - Import organization
  • misspell - Spell checking

Files Changed

  1. .github/workflows/pr-checks.yaml

    • Added permissions block
    • Replaced golangci-lint with native Go tools
    • Added error handling for PR comments
  2. Makefile

    • Updated lint-depends target
    • Replaced lint target with native tools
    • Added new fmt target for auto-fixing

New Make Commands

# Install linting tools
make lint-depends

# Run all lint checks (will fail if issues found)
make lint

# Auto-fix formatting issues (NEW!)
make fmt

# Run tests with coverage
make test-coverage

# View coverage in browser
make coverage-view

What Works Now

PR Checks Workflow:

  • Linting with Go 1.24-compatible tools
  • Tests run successfully
  • Coverage generated and uploaded
  • PR comments posted (with graceful error handling)

Test Workflow:

  • All tests run with race detection
  • Coverage reports generated
  • HTML coverage available as artifacts
  • Coverage threshold enforced

Local Development:

  • make lint uses same tools as CI
  • make fmt auto-fixes formatting
  • Full Go 1.24 compatibility

Commit and Push

git add .github/workflows/pr-checks.yaml Makefile
git commit -m "Fix PR checks: add permissions and use native Go tools for Go 1.24"
git push

Why Native Go Tools?

Problem: golangci-lint is built with Go 1.23 and cannot analyze Go 1.24 code

Solution: Use tools from the Go toolchain itself:

  • Always compatible with your Go version
  • No version lag issues
  • Official, well-maintained tools
  • Faster to install
  • Cover the essential checks

What You Get:

  • go vet - Catches common mistakes and bugs
  • gofmt - Enforces standard Go formatting
  • goimports - Organizes imports properly
  • misspell - Catches typos in code/comments

When to Switch Back:


Testing

After pushing:

  1. Check Actions Tab:

  2. Test PR Comment:

    • Create or update a PR
    • Check if coverage comment appears
    • If not, coverage still visible in workflow logs
  3. Test Locally:

    make lint          # Should pass
    make fmt           # Auto-fix any issues
    make test-coverage # Run tests with coverage

Troubleshooting

If lint fails:

# Auto-fix formatting
make fmt

# Then run lint again
make lint

If PR comment doesn't appear:

  • Check workflow logs for coverage percentage
  • Download coverage artifact from Actions
  • Comment posting is optional; main tests still work

If you need golangci-lint:

  • Wait for Go 1.24-compatible version
  • Or use it locally with caution (may show errors)

Summary

✅ Permissions fixed - PR comments should work
✅ Go 1.24 compatibility - using native tools
✅ Same checks in CI and local dev
✅ Auto-fix capability added (make fmt)
✅ All workflows should pass now

Next: Push and verify in GitHub Actions! 🚀