Comment coverage on PR #35
This file contains hidden or 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: 'Comment coverage on PR' | |
on: | |
workflow_run: | |
workflows: ['🧪'] | |
types: | |
- completed | |
jobs: | |
coverage: | |
env: | |
unique_id: <!-- coverage-report --> | |
name: Coverage reporting | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/cached-install | |
with: | |
node-version: 20.x | |
install-system-deps: false | |
- uses: actions/download-artifact@v4 | |
with: | |
name: coverage-e2e | |
run-id: ${{ github.event.workflow_run.id }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
path: ./.nyc_output | |
- uses: actions/download-artifact@v4 | |
with: | |
name: coverage-vitest | |
run-id: ${{ github.event.workflow_run.id }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
path: ./.nyc_output | |
- uses: actions/download-artifact@v4 | |
with: | |
name: coverage-visual | |
run-id: ${{ github.event.workflow_run.id }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
path: ./.nyc_output | |
- uses: actions/download-artifact@v4 | |
with: | |
name: prnumber | |
run-id: ${{ github.event.workflow_run.id }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
path: ./ | |
- name: 'copy all coverage files at the same root level' | |
run: | | |
find ./.nyc_output -type f -name 'coverage.json' | while read file; do | |
dir=$(dirname "$file"); | |
base=$(basename "$dir"); | |
cp "$file" "./.nyc_output/${base}.json"; | |
rm -rf "$dir" | |
done; | |
- run: ls -l ./.nyc_output | |
- name: Add pr number to output | |
id: prnumber | |
run: echo "pr_number=$(cat ./prnumber.txt)" >> $GITHUB_OUTPUT | |
- name: Build the report | |
id: report | |
run: | | |
echo "\`\`\`" > ./cov.txt | |
npm run coverage:report:ci >> ./cov.txt | |
echo "\`\`\`" >> ./cov.txt | |
echo "${{ env.unique_id }}" >> ./cov.txt | |
- name: Comment on PR for coverage | |
uses: edumserrano/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
issue-number: ${{ steps.prnumber.outputs.pr_number }} | |
body-includes: '${{ env.unique_id }}' | |
comment-author: 'github-actions[bot]' | |
body-path: ./cov.txt | |
edit-mode: replace |