Skip to content

Commit

Permalink
feat: added post coverage comment github PR
Browse files Browse the repository at this point in the history
feat: added post faliure comment github PR
  • Loading branch information
DE7924 committed Dec 4, 2024
1 parent 18e9307 commit 5724312
Showing 1 changed file with 49 additions and 2 deletions.
51 changes: 49 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ jobs:
run: npm run prettier
- name: Run lit-analyzer
run: npm run lint:lit-analyzer
- name: Run tests
run: npm run test -- --debug
- name: Run tests and generate coverage
run: npm run test -- --coverage --debug
- name: Test tsdoc
run: npm run docs
- name: Check for modified files
Expand All @@ -67,6 +67,53 @@ jobs:
git add -A
git commit -m '[automated commit] lint format and import sort'
git push
- name: Post coverage comment
if: always()
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const coverage = fs.readFileSync("coverage/lcov-report/index.html", "utf8");
const coverageData = coverage
.split('<table class="coverage-summary">')
.pop()
?.split("</table>")[0]
.replaceAll(/<a [^>]*>([^<]*)<\/a>/g, "$1");
const commentBody = `
## Test Coverage Report
<details>
<summary>
Code Coverage Report
</summary>
<table class="coverage-summary">
${coverageData}
</table>
</details>
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
});
- name: Post failure comment
if: failure()
uses: actions/github-script@v6
with:
script: |
const failedSteps = context.payload.workflow_run.jobs.filter(job => job.conclusion === 'failure');
const failedStepsDetails = failedSteps.map(step => `- ${step.name}: ${step.conclusion}`).join('\n');
const commentBody = `
## Code Quality Checks Failed
The following checks failed:
${failedStepsDetails}
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
});
generate-localizations:
name: Generate localizations.
needs: [code-quality]
Expand Down

0 comments on commit 5724312

Please sign in to comment.