Skip to content

Commit 835ddf2

Browse files
osteeleclaude
andauthored
feat: re-enable code coverage with GitHub Actions native tooling (#132)
This PR addresses issue #48 by re-enabling code coverage reporting using GitHub Actions and Go's native coverage tools, without requiring external SaaS services like Codecov or Coveralls. The blocking Go issue (golang/go#35781) causing "inconsistent NumStmt" errors has been worked around in commit 7ad8c5d by removing the -race flag from coverage runs. Changes: - Replace Codecov integration with GitHub Actions native coverage - Extract and display coverage percentage in workflow summary - Add optional badge generation using GitHub gist (no external services) - Update documentation to reflect new coverage approach - Coverage generation works successfully (83.8% overall coverage) Benefits of this approach: - No external SaaS dependencies or API tokens required - Coverage data visible in GitHub Actions workflow summary - Uses Go's built-in coverage tools - Badge generation is optional (requires GIST_SECRET if desired) - Follows modern best practices for Go projects in 2024-2025 Fixes #48 Co-authored-by: Claude <noreply@anthropic.com>
1 parent b9a72ce commit 835ddf2

File tree

3 files changed

+35
-11
lines changed

3 files changed

+35
-11
lines changed

.github/workflows/go.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,32 @@ jobs:
5757
- name: Generate coverage report
5858
run: make coverage
5959

60-
- name: Upload coverage to Codecov
61-
uses: codecov/codecov-action@v4
60+
- name: Extract coverage percentage
61+
id: coverage
62+
run: |
63+
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
64+
echo "percentage=$COVERAGE" >> $GITHUB_OUTPUT
65+
echo "Coverage: $COVERAGE%"
66+
67+
- name: Create coverage badge
68+
uses: schneegans/dynamic-badges-action@v1.7.0
69+
if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') && secrets.GIST_SECRET != ''
70+
continue-on-error: true
6271
with:
63-
file: ./coverage.out
64-
flags: unittests
65-
name: codecov-umbrella
66-
fail_ci_if_error: false
72+
auth: ${{ secrets.GIST_SECRET }}
73+
gistID: ${{ secrets.GIST_ID }}
74+
filename: liquid-coverage.json
75+
label: coverage
76+
message: ${{ steps.coverage.outputs.percentage }}%
77+
color: ${{ steps.coverage.outputs.percentage > 80 && 'green' || steps.coverage.outputs.percentage > 60 && 'yellow' || 'red' }}
78+
79+
- name: Add coverage to summary
80+
run: |
81+
echo "## Coverage Report" >> $GITHUB_STEP_SUMMARY
82+
echo "Total coverage: ${{ steps.coverage.outputs.percentage }}%" >> $GITHUB_STEP_SUMMARY
83+
echo "" >> $GITHUB_STEP_SUMMARY
84+
echo "### Per-package coverage:" >> $GITHUB_STEP_SUMMARY
85+
go tool cover -func=coverage.out | grep -v "total:" | awk '{printf "- %s: %s\n", $2, $3}' >> $GITHUB_STEP_SUMMARY
6786
6887
verify-mod:
6988
runs-on: ubuntu-latest

CONTRIBUTING.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Here's some ways to help:
44

55
* Select an item from the [issues list](https://github.com/osteele/liquid/issues)
66
* Search the sources for FIXME and TODO comments using `make list-todo`
7-
* Improve the [code coverage](https://coveralls.io/github/osteele/liquid?branch=master) - run `make coverage` to see current coverage
7+
* Improve the code coverage - run `make coverage` to see current coverage (currently ~84%)
88

99
Review the [pull request template](https://github.com/osteele/liquid/blob/master/.github/PULL_REQUEST_TEMPLATE.md) before you get too far along on coding.
1010

@@ -68,10 +68,18 @@ make pre-commit # Run formatter, linter, and tests before committing
6868
```bash
6969
make test # Run all tests
7070
make test-short # Run short tests only
71-
make coverage # Generate test coverage report (HTML)
71+
make coverage # Generate test coverage report
7272
make benchmark # Run performance benchmarks
7373
```
7474

75+
**Coverage Reporting**: Code coverage is tracked automatically via GitHub Actions. When you push to the main branch, the CI pipeline:
76+
- Generates a coverage report using Go's native coverage tools
77+
- Extracts the coverage percentage
78+
- Displays coverage details in the workflow summary
79+
- Optionally creates a coverage badge (if `GIST_SECRET` is configured)
80+
81+
To view coverage locally, run `make coverage`. This generates `coverage.out` and displays per-package coverage percentages. The coverage data is generated without external SaaS services, using only Go's built-in tooling.
82+
7583
### Code Quality
7684

7785
```bash

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,6 @@ and filter test cases are taken directly from the Liquid documentation.
381381
382382
MIT License
383383
384-
[coveralls-url]: https://coveralls.io/r/osteele/liquid?branch=master
385-
[coveralls-svg]: https://img.shields.io/coveralls/osteele/liquid.svg?branch=master
386-
387384
[go-url]: https://github.com/osteele/liquid/actions?query=workflow%3A%22Build+Status%22
388385
[go-svg]: https://github.com/osteele/liquid/actions/workflows/go.yml/badge.svg
389386

0 commit comments

Comments
 (0)