-
Notifications
You must be signed in to change notification settings - Fork 36
80 lines (67 loc) · 3.19 KB
/
coverage.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
on: [pull_request]
name: Test coverage report # main.yml
permissions:
# allow dependabot to execute this workflow
pull-requests: write
jobs:
hello_world_job:
runs-on: ubuntu-latest
name: Test and report
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 1000
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci --ignore-scripts
- name: Run mcdev-tests with coverage
run: npm run coverage
- name: Prepare for Report Coverage
run: |
npx c8 report --reporter json-summary --exclude-after-remap false
npm i svelte-to-html@1.0.9
git fetch origin ${{ github.event.pull_request.base.ref }} --depth=1000
- name: Upload coverage artifact
uses: actions/upload-artifact@v3
with:
name: test-coverage-output
path: coverage
- name: Download coverage artifact
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Get Run ID
id: get_run_id
run: |
echo "name=run_id::$(\
gh run list \
--workflow "${{ github.event.pull_request.base.ref == 'main' && 'coverage-main-branch.yml' || github.event.pull_request.base.ref == 'develop' && 'coverage-develop-branch.yml' || 'coverage.yml' }}" \
--json conclusion,headSha,status,databaseId \
--jq ".[] | select( .conclusion == \"success\" and .headSha == \"${{github.event.pull_request.base.sha}}\") | .databaseId" \
)" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Download artifact for base branch if available, previous
uses: dawidd6/action-download-artifact@v2
continue-on-error: true
with:
workflow: ${{ github.event.pull_request.base.ref == 'main' && 'coverage-main-branch.yml' || github.event.pull_request.base.ref == 'develop' && 'coverage-develop-branch.yml' || 'coverage.yml' }}
run_id: ${{steps.get_run_id.outputs.run_id}}
name: 'test-coverage-output'
path: base-artifacts
search_artifacts: true
- name: Check file existence
id: check_files
uses: andstor/file-existence-action@v2
with:
files: 'base-artifacts/coverage-summary.json'
- name: Report coverage
uses: sidx1024/report-nyc-coverage-github-action@v1.2.7
id: report
with:
coverage_file: 'artifacts/test-coverage-output/coverage-summary.json'
base_coverage_file: ${{steps.check_files.outputs.files_exists == 'true' && 'base-artifacts/coverage-summary.json' || ''}}
comment_template_file: '.coverage-comment-template.svelte'