Skip to content

ilib-mono: Add code coverage comment to main README #70

ilib-mono: Add code coverage comment to main README

ilib-mono: Add code coverage comment to main README #70

Workflow file for this run

name: Test All
on:
push:
branches:
- add-code-coverage-1
jobs:
test-all:
name: Test All
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: Install Chrome
uses: browser-actions/setup-chrome@v1
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run code coverage
run: pnpm coverage:ci
- name: Jest Coverage Comment
id: coverageComment
uses: MishaKav/jest-coverage-comment@main
with:
hide-summary: true
coverage-summary-path: ./packages/ilib-lint-python/coverage/coverage-summary.json
- name: Update README with Coverage HTML
env:
dupa: ${{ steps.coverageComment.outputs.summaryHtml }}
run: |
sed -i '/<!-- Jest Coverage Comment:Begin -->/,/<!-- Jest Coverage Comment:End -->/c\<!-- Jest Coverage Comment:Begin -->$dupa<!-- Jest Coverage Comment:End -->' ./README.md
cat ./README.md
- name: Commit & Push changes in README
uses: actions-js/push@master
with:
branch: 'add-code-coverage-1'
message: Update coverage in README
github_token: ${{ secrets.GITHUB_TOKEN }}
#
# - name: Generate coverage data
# id: coverageComment
# uses: MishaKav/jest-coverage-comment@main
# with:
# hide-comment: true
# coverage-summary-path: ./packages/ilib-lint-python/coverage/coverage-summary.json
# - name: Check the output coverage
# run: |
# echo "Coverage Percentage - ${{ steps.coverageComment.outputs }}"
# echo "Coverage Color - ${{ steps.coverageComment.outputs }}"
# echo "Summary HTML - ${{ steps.coverageComment.outputs }}"
#
# - name: Update coverage badge in README
# if: github.ref == 'refs/heads/add-code-coverage-1'
# uses: schneegans/[email protected]
# with:
## TODO @Edwin
## 1. Create gist
## 2. Create token for authorization to update gist (scope gist)
## 3. Add token to lib-mono actions' secrets and used here
# auth: ${{ secrets.GIST_TOKEN }}
# gistID: ${{ gistID }}
# filename: ilib-lint-python.json
# label: Coverage
# message: ${{ steps.coverageComment.outputs.coverage }}%
# color: ${{ steps.coverageComment.outputs.color }}
# namedLogo: javascript
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: code-coverage
path: ./packages/*/coverage/
retention-days: 3