ilib-mono: Add code coverage comment to main README #74
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
run: | | |
dupa=$(echo "${{ steps.coverageComment.outputs.summaryHtml }}") | |
sed -i '/<!-- Jest Coverage Comment:Begin -->/,/<!-- Jest Coverage Comment:End -->/c\<!-- Jest Coverage Comment:Begin -->\n${dupa}\n<!-- 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 |