Skip to content

Latest commit

 

History

History
147 lines (110 loc) · 4.98 KB

File metadata and controls

147 lines (110 loc) · 4.98 KB

Coveralls Integration Issues and Fix

Current Issues Identified

1. Missing Upload Step

The GitHub Actions workflow generates coverage data (coverage.out) but never uploads it to Coveralls.io. The workflow stops after generating the coverage file.

2. Incomplete Integration

The current workflow has:

- name: Update coverage
  run: |
    go test -tags test -covermode=atomic -coverprofile=coverage.out ./...
  if: ${{ runner.os == 'Linux' && matrix.go-version == '1.23' }}

But there's no step to send this data to Coveralls.

3. Repository Not Enabled on Coveralls

The Coveralls page (https://coveralls.io/github/mariow/nicmanager-export?branch=master) appears empty, suggesting the repository hasn't been properly added to Coveralls.io.

4. Outdated Integration Method

The integration appears to be from an older era when Go coverage required conversion to LCOV format. Modern Coveralls supports Go coverage natively.

Modern Solution (2024/2025)

Step 1: Add Repository to Coveralls.io

  1. Go to Coveralls.io
  2. Sign in with GitHub account
  3. Go to ADD REPOS
  4. Find mariow/nicmanager-export and toggle it ON
  5. Note the repo token (if needed for private repos)

Step 2: Update GitHub Actions Workflow

Replace the current coverage step with a complete Coveralls integration:

- name: Generate coverage report
  run: go test -tags test -covermode=atomic -coverprofile=coverage.out ./...
  if: ${{ runner.os == 'Linux' && matrix.go-version == '1.23' }}

- name: Upload coverage to Coveralls
  uses: coverallsapp/github-action@v2.3.0
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    file: coverage.out
    format: golang
  if: ${{ runner.os == 'Linux' && matrix.go-version == '1.23' }}

Step 3: Add Repository Secret (If Needed)

For public repositories, the GITHUB_TOKEN is usually sufficient. For private repositories:

  1. Go to repository Settings → Secrets and variables → Actions
  2. Add a new repository secret named COVERALLS_REPO_TOKEN
  3. Use the token from Coveralls.io
  4. Update the workflow to use: github-token: ${{ secrets.COVERALLS_REPO_TOKEN }}

Step 4: Complete Updated Workflow

Here's the complete updated workflow section:

- name: Generate coverage report
  run: go test -tags test -covermode=atomic -coverprofile=coverage.out ./...
  if: ${{ runner.os == 'Linux' && matrix.go-version == '1.23' }}

- name: Upload coverage to Coveralls
  uses: coverallsapp/github-action@v2.3.0
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    file: coverage.out
    format: golang
    fail-on-error: false
  if: ${{ runner.os == 'Linux' && matrix.go-version == '1.23' }}

Key Improvements

1. Native Go Support

Modern Coveralls supports Go coverage format directly - no conversion needed.

2. Simplified Configuration

  • Uses official coverallsapp/github-action@v2.3.0
  • Specifies format: golang for native Go coverage support
  • Uses built-in GITHUB_TOKEN for public repos

3. Error Handling

  • Added fail-on-error: false to prevent CI failures if Coveralls is temporarily unavailable

4. Proper Conditions

  • Only runs on Linux with Go 1.23 to avoid duplicate uploads
  • Maintains existing conditional logic

Expected Results After Fix

  1. Coverage Badge: The badge in README.md will show actual coverage percentage
  2. PR Comments: Coveralls will add comments to pull requests showing coverage changes
  3. Coverage Tracking: Historical coverage data will be tracked over time
  4. Notifications: Optional notifications for coverage changes

Testing the Fix

  1. Apply the workflow changes
  2. Push to master branch
  3. Check GitHub Actions logs for successful Coveralls upload
  4. Verify coverage appears on Coveralls.io
  5. Test with a pull request to see PR comments

Alternative: Modern Coverage Solutions

If Coveralls continues to have issues, consider modern alternatives:

Codecov

- name: Upload coverage to Codecov
  uses: codecov/codecov-action@v4
  with:
    file: coverage.out
    fail_ci_if_error: false

GitHub's Built-in Coverage

Use GitHub's native coverage reporting with PR comments.

Troubleshooting

Common Issues:

  1. "Repository not found": Ensure repo is added to Coveralls.io
  2. "Invalid token": Check GITHUB_TOKEN permissions or use COVERALLS_REPO_TOKEN
  3. "No coverage data": Verify coverage.out file is generated correctly
  4. Badge not updating: May take a few minutes after successful upload

Debug Steps:

  1. Check GitHub Actions logs for Coveralls step
  2. Verify coverage.out file exists and contains data
  3. Check Coveralls.io repository page for recent builds
  4. Test with a simple PR to verify integration

Migration Benefits

  • Simplified maintenance: No custom scripts or conversions
  • Better reliability: Official action with regular updates
  • Enhanced features: PR comments, coverage trends, notifications
  • Future-proof: Supported by Coveralls team directly