Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 2, 2026

Add Test Coverage Badge to GitHub Page

  • Remove Codecov integration per maintainer feedback
  • Implement self-contained coverage badge solution
  • Parse SimpleCov output directly to extract coverage percentage
  • Create badge JSON file in repository
  • Use shields.io endpoint badge to display coverage
  • Add make rubocop target for consistency
  • Add write permissions for badge updates
  • Add error handling for coverage parsing
  • Add conflict resolution for badge updates
  • Use sed for better portability
  • Fix badge URL to point to correct branch
  • Improve sed regex to handle spaces in JSON
  • Fix regex to handle single-digit coverage values
  • All issues addressed and ready for testing

Note: The badge URL in README points to the feature branch for testing. Update to master or develop branch after merge.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add test coverage metrick to the github page</issue_title>
<issue_description>make coverage generates simplecov coverage output. Can we incorporate that with CI and generate a badge on the github page with the coverage?</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits January 2, 2026 08:01
Co-authored-by: kwerle <23320+kwerle@users.noreply.github.com>
Co-authored-by: kwerle <23320+kwerle@users.noreply.github.com>
…rkflow

Co-authored-by: kwerle <23320+kwerle@users.noreply.github.com>
Co-authored-by: kwerle <23320+kwerle@users.noreply.github.com>
…p target

Co-authored-by: kwerle <23320+kwerle@users.noreply.github.com>
Copilot AI changed the title [WIP] Add test coverage metric to GitHub page Add test coverage reporting with Codecov integration Jan 2, 2026
Copilot AI requested a review from kwerle January 2, 2026 08:09
Copy link
Owner

@kwerle kwerle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No - let's avoid using codecov and simply parse the coverage output to get a number.

Copilot AI and others added 3 commits January 2, 2026 08:17
Co-authored-by: kwerle <23320+kwerle@users.noreply.github.com>
Co-authored-by: kwerle <23320+kwerle@users.noreply.github.com>
Co-authored-by: kwerle <23320+kwerle@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 2, 2026

No - let's avoid using codecov and simply parse the coverage output to get a number.

Done! I've replaced Codecov with a self-contained solution that parses SimpleCov output directly. The workflow now:

  1. Runs tests with coverage
  2. Extracts the coverage percentage from SimpleCov's .last_run.json file
  3. Creates a badge JSON file in .github/badges/coverage.json
  4. Commits and pushes the badge automatically
  5. The README displays the badge using shields.io endpoint format

No external services or secrets required. Changes in commit 465825b.

Copilot AI changed the title Add test coverage reporting with Codecov integration Add test coverage badge to GitHub page with self-contained solution Jan 2, 2026
Copilot AI requested a review from kwerle January 2, 2026 08:21
Copy link
Owner

@kwerle kwerle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot
When I look at https://github.com/kwerle/ruby_language_server/tree/copilot/add-test-coverage-badge?tab=readme-ov-file (the github page for this branch) I see an icon that says custom badge resource not found.
Is that expected?

Makefile Outdated
./bin/run_in_shell "COVERAGE=true bundle exec rake test"

rubocop: image
./bin/run_in_shell bundle exec rubocop
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't use run_in_shell on ci because it is interactive. Chnge this to the docker command.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has already been fixed in commits 817345e and d92cd1a. The Makefile now uses docker run commands directly instead of run_in_shell for the coverage and rubocop targets.

# Use sed for better portability instead of grep -P
COVERAGE=$(sed -n 's/.*"coverage":\([0-9.]*\).*/\1/p' coverage/.last_run.json | head -1)
if [ -z "$COVERAGE" ]; then
echo "Error: Could not extract coverage percentage"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit ecd8f98. The issue was with the sed regex pattern - it wasn't accounting for optional spaces after the colon in the JSON. The pattern now correctly matches "coverage": 85.7 with or without spaces. I also added debug output to help diagnose future issues.

Co-authored-by: kwerle <23320+kwerle@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 2, 2026

@copilot
When I look at https://github.com/kwerle/ruby_language_server/tree/copilot/add-test-coverage-badge?tab=readme-ov-file (the github page for this branch) I see an icon that says custom badge ...

Yes, that's expected for now. The badge URL was pointing to the master branch, but the badge file only exists on the feature branch copilot/add-test-coverage-badge.

I've fixed this in commit ecd8f98 - the badge URL now points to the feature branch so you should see it working. Once this PR is merged to master (or develop), you'll want to update the URL back to point to the main branch.

The badge should now display once the CI run completes successfully.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/kwerle/ruby_language_server/actions/jobs/59328099365
    • Triggering command: /usr/bin/curl curl -s REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Co-authored-by: kwerle <23320+kwerle@users.noreply.github.com>
Copilot AI requested a review from kwerle January 2, 2026 17:14
@kwerle kwerle marked this pull request as ready for review January 2, 2026 18:05
@kwerle kwerle merged commit fe288b9 into develop Jan 2, 2026
3 checks passed
@kwerle kwerle deleted the copilot/add-test-coverage-badge branch January 2, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add test coverage metrick to the github page

2 participants