-
Notifications
You must be signed in to change notification settings - Fork 153
feat: add github workflow for test coverage #1034
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: develop
Are you sure you want to change the base?
Changes from all commits
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,38 @@ | ||||||||||||||||||||||||||
| name: Test Coverage | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||||
| branches: [ main, master, develop ] | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||
| coverage: | ||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||
| pull-requests: write | ||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||
| - uses: actions/checkout@v3 | ||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Update GitHub Actions checkout to latest version. The runner for the checkout action is outdated. - - uses: actions/checkout@v3
+ - uses: actions/checkout@v4📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.4)14-14: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue (action) |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: Install pnpm | ||||||||||||||||||||||||||
| uses: pnpm/action-setup@v2 | ||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||
| version: 8 | ||||||||||||||||||||||||||
| run_install: false | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: Setup Node.js | ||||||||||||||||||||||||||
| uses: actions/setup-node@v3 | ||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Update GitHub Actions setup-node to latest version. The runner for the setup-node action is outdated. - - uses: actions/setup-node@v3
+ - uses: actions/setup-node@v4📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.4)23-23: the runner of "actions/setup-node@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue (action) |
||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||
| node-version: 18 | ||||||||||||||||||||||||||
| cache: 'pnpm' | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: Install dependencies | ||||||||||||||||||||||||||
| run: pnpm install | ||||||||||||||||||||||||||
|
Comment on lines
+28
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Consider caching node_modules for faster workflows. While pnpm caching is configured, you could further optimize by caching node_modules. - name: Install dependencies
run: pnpm install
+
+ - name: Cache node_modules
+ uses: actions/cache@v4
+ with:
+ path: node_modules
+ key: ${{ runner.os }}-node-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
+ restore-keys: |
+ ${{ runner.os }}-node-modules-📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: Run tests with coverage | ||||||||||||||||||||||||||
| run: pnpm run test:coverage || true | ||||||||||||||||||||||||||
|
Comment on lines
+31
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Consider failing the workflow on low coverage. The current implementation runs tests with coverage and continues even if tests fail ( You could add a step after posting the coverage comment to check the coverage percentage and fail if it's below a threshold: - name: Check coverage threshold
run: |
COVERAGE=$(cat ./coverage/lcov.info | grep -oP 'LF:\K[0-9]+' | awk '{covered+=$1} END {print covered}')
TOTAL=$(cat ./coverage/lcov.info | grep -oP 'LH:\K[0-9]+' | awk '{total+=$1} END {print total}')
PERCENTAGE=$(awk "BEGIN { print ($TOTAL/$COVERAGE) * 100 }")
echo "Current coverage: $PERCENTAGE%"
if (( $(echo "$PERCENTAGE < 70" | bc -l) )); then
echo "Coverage below threshold of 70%"
exit 1
fiThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
This approach would maintain test integrity while still achieving the coverage reporting goal.
Suggested change
Spotted by Diamond |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: Post coverage comment | ||||||||||||||||||||||||||
| uses: romeovs/[email protected] | ||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||||||||||||||
| lcov-file: ./coverage/lcov.info | ||||||||||||||||||||||||||
|
Comment on lines
+35
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Consider adding a badge to README. The coverage report is posted as a comment, but you might want to also add a coverage badge to your README for visibility. After this workflow is established, you could add the following to your README.md: [](https://codecov.io/gh/Real-Dev-Squad/website-www)This requires setting up integration with a service like Codecov, which could be a future enhancement. |
||||||||||||||||||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
🧹 Nitpick (assertive)
YAML syntax issues in workflow trigger configuration.
There are spacing issues in the bracket notation of the branches array.
📝 Committable suggestion
🧰 Tools
🪛 YAMLlint (1.35.1)
[warning] 3-3: truthy value should be one of [false, true]
(truthy)
[error] 5-5: too many spaces inside brackets
(brackets)
[error] 5-5: too many spaces inside brackets
(brackets)