Skip to content

Codecov integration added to CI but secret likely not configured (will fail silently) #176

@sfloess

Description

@sfloess

Problem

The main.yml workflow was updated to include Codecov integration (issue #168 implementation), but the required CODECOV_TOKEN secret is likely not configured in GitHub repository settings.

Evidence

Workflow Configuration (.github/workflows/main.yml)

- name: Upload coverage to Codecov
  uses: codecov/codecov-action@v4.6.0
  with:
    token: ${{ secrets.CODECOV_TOKEN }}
    files: ./target/site/jacoco/jacoco.xml
    flags: unittests
    name: codecov-flossware-jcommons
    fail_ci_if_error: false  # ⚠️ Fails silently if secret missing

Configuration Details

  • Action used: codecov/codecov-action@v4.6.0
  • Token required: secrets.CODECOV_TOKEN
  • Fail on error: false ← Will not fail CI if secret missing

Current Badge in README

[![codecov](https://codecov.io/gh/FlossWare/jcommons/branch/main/graph/badge.svg)](https://codecov.io/gh/FlossWare/jcommons)

Badge likely still shows: "Unknown" or no coverage data

Impact

1. Silent Failure

Setting fail_ci_if_error: false means:

  • If CODECOV_TOKEN missing → upload silently skipped
  • CI shows green ✅ even though coverage not uploaded
  • No indication of failure in workflow logs (easy to miss)

Result: Integration appears complete but actually not working.

2. Badge Still Broken

README badge remains broken/inaccurate:

3. False Confidence

Developers believe:

  • Codecov is working (workflow step exists)
  • Coverage being tracked (badge in README)

Reality:

  • No uploads happening
  • Coverage not tracked
  • Badge meaningless

Verification Needed

Check if Secret Exists

Method 1: Repository Settings

  1. Go to: https://github.com/FlossWare/jcommons/settings/secrets/actions
  2. Look for: CODECOV_TOKEN
  3. If missing → this issue confirmed

Method 2: Recent Workflow Run

gh run list --workflow=main.yml --limit 1
gh run view <run-id> --log | grep -i "codecov"

Look for:

  • "Error: Codecov token not found" (secret missing)
  • "Coverage uploaded successfully" (working)
  • No error message (silent skip due to fail_ci_if_error: false)

Check Codecov Dashboard

Visit: https://app.codecov.io/gh/FlossWare/jcommons

If working: Should show coverage data
If broken: "Repository not found" or no data

Setup Instructions

Step 1: Sign Up at Codecov

  1. Visit: https://codecov.io
  2. Sign in with GitHub account
  3. Authorize Codecov for FlossWare organization

Step 2: Add Repository

  1. In Codecov dashboard: "Add new repository"
  2. Select: FlossWare/jcommons
  3. Copy the repository upload token

Step 3: Add Secret to GitHub

  1. Go to: https://github.com/FlossWare/jcommons/settings/secrets/actions
  2. Click: "New repository secret"
  3. Name: CODECOV_TOKEN
  4. Value: (paste token from Codecov)
  5. Click: "Add secret"

Step 4: Verify Integration

# Trigger a new build
git commit --allow-empty -m "Test Codecov integration"
git push

# Check workflow logs
gh run watch

# Look for success message
gh run view --log | grep -i "codecov"
# Should see: "Coverage uploaded successfully"

Step 5: Verify Badge

  1. Wait ~5 minutes for Codecov to process
  2. Visit: https://codecov.io/gh/FlossWare/jcommons
  3. Check badge URL: https://codecov.io/gh/FlossWare/jcommons/branch/main/graph/badge.svg
  4. Should show actual coverage percentage (93%)

Alternative: Use GitHub Token

Codecov v4+ can use GitHub token instead of Codecov token (for public repos):

- name: Upload coverage to Codecov
  uses: codecov/codecov-action@v4.6.0
  with:
    token: ${{ secrets.GITHUB_TOKEN }}  # Use GitHub token instead
    files: ./target/site/jacoco/jacoco.xml
    flags: unittests
    name: codecov-flossware-jcommons
    fail_ci_if_error: false

Benefits:

  • No Codecov token needed
  • Works immediately (GITHUB_TOKEN auto-provided)
  • Simpler setup

Drawbacks:

  • May have rate limits
  • Less control over Codecov features

Recommendation: Try GITHUB_TOKEN first, if issues then get Codecov token.

Recommended Workflow Update

Option 1: Fail on Error (Recommended)

Change to catch integration issues:

- name: Upload coverage to Codecov
  uses: codecov/codecov-action@v4.6.0
  with:
    token: ${{ secrets.CODECOV_TOKEN }}
    files: ./target/site/jacoco/jacoco.xml
    flags: unittests
    name: codecov-flossware-jcommons
    fail_ci_if_error: true  # ✅ Fail if upload fails

Benefits: Immediate feedback if secret missing or upload fails

OR at minimum, add explicit error logging:

- name: Upload coverage to Codecov
  id: codecov
  uses: codecov/codecov-action@v4.6.0
  with:
    token: ${{ secrets.CODECOV_TOKEN }}
    files: ./target/site/jacoco/jacoco.xml
    fail_ci_if_error: false
    
- name: Verify Codecov Upload
  if: steps.codecov.outcome != 'success'
  run: |
    echo "⚠️ WARNING: Codecov upload failed or was skipped"
    echo "Check if CODECOV_TOKEN secret is configured"

Option 2: Conditional Upload

Only upload if token exists:

- name: Upload coverage to Codecov
  if: secrets.CODECOV_TOKEN != ''
  uses: codecov/codecov-action@v4.6.0
  with:
    token: ${{ secrets.CODECOV_TOKEN }}
    files: ./target/site/jacoco/jacoco.xml

Documentation Updates

If Codecov Configured

Update CONTRIBUTING.md:

## Code Coverage

Coverage is automatically tracked via [Codecov](https://codecov.io/gh/FlossWare/jcommons):
- Coverage reports uploaded on every commit
- PR comments show coverage diff
- Badge in README shows current coverage

View coverage: https://app.codecov.io/gh/FlossWare/jcommons

If Codecov Not Configured Yet

Add to README (temporary):

**Note**: Codecov integration is configured but requires repository secret setup.
See issue #XXX for setup instructions.

Related Issues

Verification Checklist

  • Check if CODECOV_TOKEN secret exists in repository
  • Review recent workflow runs for Codecov upload status
  • Visit Codecov dashboard to see if data being received
  • Verify badge shows actual coverage percentage
  • Test with new commit to ensure upload works
  • Update workflow to fail on error OR add warning logging

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions