-
-
Notifications
You must be signed in to change notification settings - Fork 0
Add Node.js coverage workflow template for cloudhealthoffice repo #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
60d1d2b
ac534f4
a721aa8
ff7ee57
83fc2bd
694aa04
488b59f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,301 @@ | ||||||
| # Enhanced Code Coverage Report Template for CloudHealthOffice | ||||||
|
|
||||||
| ## Overview | ||||||
|
|
||||||
| This document provides a workflow template to enhance the code coverage reporting in the **cloudhealthoffice** repository, modeled after the comprehensive coverage implementation in the **privaseeai.net** build (PrivaseeAI.Security repository). | ||||||
|
|
||||||
| ## What's Different? | ||||||
|
|
||||||
| ### Current CloudHealthOffice Coverage (codecov.yml) | ||||||
| β Basic codecov upload | ||||||
| β Terminal coverage summary | ||||||
| β No HTML coverage artifacts | ||||||
| β No test result publishing | ||||||
| β No PR coverage comments | ||||||
| β No test artifacts | ||||||
|
|
||||||
| ### Enhanced Coverage (This Template) | ||||||
| β Codecov upload (retained) | ||||||
| β Terminal coverage summary (retained) | ||||||
| β **HTML coverage reports as downloadable artifacts** (30-day retention) | ||||||
| β **Test results published as PR status checks** | ||||||
| β **Automated coverage comments on PRs** | ||||||
| β **Test result artifacts for debugging** | ||||||
|
|
||||||
| ## Implementation Guide | ||||||
|
|
||||||
| ### Step 1: Install Required Dependencies | ||||||
|
|
||||||
| Add the `jest-junit` package to your `devDependencies` in `package.json`: | ||||||
|
|
||||||
| ```bash | ||||||
| npm install --save-dev jest-junit | ||||||
| ``` | ||||||
|
|
||||||
| ### Step 2: Configure Jest for JUnit Output | ||||||
|
|
||||||
| Update your `jest.config.js` or `package.json` jest configuration to support junit reporting: | ||||||
|
|
||||||
| ```javascript | ||||||
| // jest.config.js | ||||||
| module.exports = { | ||||||
| // ... existing config ... | ||||||
| reporters: [ | ||||||
| 'default', | ||||||
| ['jest-junit', { | ||||||
| outputDirectory: './test-results', | ||||||
| outputName: 'junit.xml', | ||||||
| }] | ||||||
| ], | ||||||
| }; | ||||||
| ``` | ||||||
|
|
||||||
| Or in `package.json`: | ||||||
|
|
||||||
| ```json | ||||||
| { | ||||||
| "jest": { | ||||||
| "reporters": [ | ||||||
| "default", | ||||||
| ["jest-junit", { | ||||||
| "outputDirectory": "./test-results", | ||||||
| "outputName": "junit.xml" | ||||||
| }] | ||||||
| ] | ||||||
| } | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| ### Step 3: Update `.gitignore` | ||||||
|
|
||||||
| Add these lines to `.gitignore` if not already present: | ||||||
|
|
||||||
| ``` | ||||||
| # Test results and coverage | ||||||
| coverage/ | ||||||
| test-results/ | ||||||
| *.lcov | ||||||
| ``` | ||||||
|
|
||||||
| ### Step 4: Replace the Workflow File | ||||||
|
|
||||||
| Replace the current `.github/workflows/codecov.yml` with the enhanced version: | ||||||
|
|
||||||
| 1. **Option A: Direct replacement** | ||||||
| - Copy the content from `.github/workflow-templates/nodejs-coverage-enhanced.yml` in this repository | ||||||
| - Replace `.github/workflows/codecov.yml` in cloudhealthoffice repository | ||||||
|
|
||||||
| 2. **Option B: Create new workflow** | ||||||
| - Keep the existing `codecov.yml` as backup | ||||||
| - Create a new file `.github/workflows/test.yml` with the enhanced template | ||||||
| - Disable the old workflow once the new one is verified | ||||||
|
|
||||||
| ### Step 5: Verify Permissions | ||||||
|
|
||||||
| Ensure your GitHub Actions workflow has the necessary permissions. The enhanced workflow requires: | ||||||
|
|
||||||
| ```yaml | ||||||
| permissions: | ||||||
| contents: read | ||||||
| checks: write | ||||||
| pull-requests: write | ||||||
| ``` | ||||||
|
|
||||||
| These are already included in the template. | ||||||
|
|
||||||
| ### Step 6: Test the Workflow | ||||||
|
|
||||||
| 1. Create a pull request with the new workflow | ||||||
| 2. Verify that the workflow runs successfully | ||||||
| 3. Check for the following: | ||||||
| - β Tests execute with coverage | ||||||
| - β Codecov upload succeeds | ||||||
| - β Test results appear as PR checks | ||||||
| - β Coverage comment appears on PR | ||||||
| - β Artifacts are available for download | ||||||
|
|
||||||
| ## What You'll Get | ||||||
|
|
||||||
| ### 1. HTML Coverage Reports | ||||||
|
|
||||||
| After each workflow run, you can download a complete HTML coverage report: | ||||||
|
|
||||||
| - Navigate to the workflow run in the **Actions** tab | ||||||
| - Scroll to the **Artifacts** section | ||||||
| - Download `coverage-report-html` | ||||||
| - Open `index.html` in your browser for interactive coverage exploration | ||||||
|
|
||||||
| ### 2. Test Results as PR Checks | ||||||
|
|
||||||
| Test results will appear as status checks on pull requests: | ||||||
| - β Total tests passed/failed/skipped | ||||||
| - β Test execution time | ||||||
| - β Detailed breakdown by test suite | ||||||
|
|
||||||
| ### 3. PR Coverage Comments | ||||||
|
|
||||||
| Each PR will get an automated comment showing: | ||||||
| - Overall coverage percentage | ||||||
| - Coverage changes (increase/decrease) | ||||||
| - File-by-file coverage breakdown | ||||||
| - Uncovered lines highlighted | ||||||
|
|
||||||
| ### 4. Test Result Artifacts | ||||||
|
|
||||||
| JUnit XML test results are uploaded as artifacts for: | ||||||
| - Integration with external tools | ||||||
| - Historical test result tracking | ||||||
| - Debugging test failures | ||||||
|
|
||||||
| ## Enhanced Features Explained | ||||||
|
|
||||||
| ### Feature 1: Multiple Coverage Report Formats | ||||||
|
|
||||||
| ```yaml | ||||||
| npm test -- --coverage \ | ||||||
| --coverageReporters=lcov \ # For Codecov | ||||||
| --coverageReporters=json-summary \ # For summary display | ||||||
| --coverageReporters=text \ # For terminal output | ||||||
| --coverageReporters=html # For browseable report | ||||||
|
||||||
| --coverageReporters=html # For browseable report | |
| --coverageReporters=html # For browsable report |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 694aa04. Corrected spelling to "browsable".
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example configures the third-party action romeovs/lcov-reporter-action@v0.3.1 via a mutable tag and passes secrets.GITHUB_TOKEN with pull-requests: write privileges to any repo that copies it. If that upstream action or its tag is ever compromised, consumer repositories could leak their repo token and allow an attacker to forge or remove coverage comments on pull requests. Update the recommended configuration to pin this action to a vetted commit SHA and, where possible, reduce the token/permissions it receives to the minimum needed for posting comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added security note in commit 694aa04. Documentation now includes a warning about using mutable tags and recommends pinning to a specific commit SHA for enhanced security in production environments.
Outdated
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The action name could be more precise. The actual action used is py-cov-action/python-coverage-comment-action not just "py-cov-action". Consider updating this to match the full action name for clarity.
| | PR Coverage Comments | β py-cov-action | β lcov-reporter-action | | |
| | PR Coverage Comments | β py-cov-action/python-coverage-comment-action | β lcov-reporter-action | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected in commit 694aa04. Updated to full action name py-cov-action/python-coverage-comment-action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent capitalization of the repository name. The title uses "CloudHealthOffice" (camelCase) but the repository is actually "cloudhealthoffice" (lowercase) as referenced throughout the rest of the documentation. Consider using "cloudhealthoffice" consistently or clarifying that this is a stylized name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 694aa04. Changed title to use lowercase "cloudhealthoffice" for consistency.