Generate Coverage PR #78
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: Generate Coverage PR | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- "**/*.spec.ts" | |
workflow_run: | |
workflows: ["Run Tests"] | |
types: | |
- completed | |
jobs: | |
generate-coverage-pr: | |
strategy: | |
matrix: | |
node-version: [20.6.1] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install dependencies | |
run: yarn install --immutable | |
env: | |
# Disable Husky in CI | |
# https://typicode.github.io/husky/how-to.html#skipping-git-hooks | |
HUSKY: "0" | |
- name: Generate coverage report | |
run: | | |
yarn test --coverage | |
- name: Setup files | |
run: | | |
mkdir -p ../coverage/client | |
mv index.html ../coverage | |
mv Packages/Client/test/coverage/lcov-report/** ../coverage/client | |
mv Packages/Client/test/coverage/lcov.info ../coverage/client | |
git rm -rf . | |
git clean -f -d | |
mv ../coverage/client . | |
mv ../coverage/index.html . | |
- name: Create Pull Request | |
id: "open-pr" | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
commit-message: "feat: Add test coverage report" | |
title: "test(coverage): update" | |
body: "This PR adds the test coverage report generated by the GitHub Actions workflow." | |
branch: "test/actions/coverage-report" | |
base: "Coverage-Report" | |
labels: "automated" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Merge Pull Request | |
uses: peter-evans/enable-pull-request-automerge@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
pull-request-number: ${{ steps.open-pr.outputs.pull-request-number }} | |
- name: "Delete PR Branch" | |
run: git push origin --delete test/actions/coverage-report | |
- name: SonarCloud Scan | |
uses: SonarSource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |