Skip to content

Commit 3d32129

Browse files
committed
Extract code covarage upload
1 parent 1ac2239 commit 3d32129

File tree

4 files changed

+68
-3
lines changed

4 files changed

+68
-3
lines changed

.github/workflows/build-and-test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ on:
88
description: "enabled uploading coverage report to codecov"
99
required: false
1010
default: false
11+
collect-code-coverage:
12+
type: boolean
13+
description: "enables collecting coverage reports and uploading them as artifacts"
14+
required: false
15+
default: false
1116
secrets:
1217
CODECOV_TOKEN:
1318
description: "token to upload codecov report"
@@ -50,6 +55,7 @@ jobs:
5055
run-on: ubuntu-latest
5156
task: linuxAllTest
5257
upload-code-coverage: ${{ inputs.upload-code-coverage }}
58+
collect-code-coverage: ${{ inputs.collect-code-coverage }}
5359
secrets:
5460
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
5561
check-macos:

.github/workflows/check.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ on:
1616
description: "enabled uploading coverage report to codecov"
1717
required: false
1818
default: false
19+
collect-code-coverage:
20+
type: boolean
21+
description: "enables collecting coverage reports and uploading them as artifacts"
22+
required: false
23+
default: false
1924
secrets:
2025
CODECOV_TOKEN:
2126
description: "token to upload codecov report"
@@ -66,3 +71,9 @@ jobs:
6671
uses: codecov/codecov-action@v4
6772
with:
6873
token: ${{ secrets.CODECOV_TOKEN }}
74+
- name: Collect coverage reports
75+
if: inputs.collect-code-coverage && github.actor != 'dependabot[bot]'
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: coverage-reports
79+
path: '**/build/reports/kover/report.xml'
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Upload code coverage results
2+
3+
on:
4+
workflow_run:
5+
workflows: ['Check the PR']
6+
types: [completed]
7+
8+
jobs:
9+
upload:
10+
runs-on: ubuntu-latest
11+
if: github.event.workflow_run.actor.name != 'dependabot[bot]'
12+
steps:
13+
- name: 'Checkout Repository'
14+
uses: actions/checkout@v4
15+
with:
16+
ref: ${{ github.event.workflow_run.head_branch }}
17+
- name: Download benchmark results
18+
uses: actions/download-artifact@v4
19+
with:
20+
name: coverage-reports
21+
path: reports/
22+
run-id: ${{ github.event.workflow_run.id }}
23+
- name: Download PR number
24+
uses: actions/download-artifact@v4
25+
with:
26+
name: pr-number
27+
path: '.'
28+
run-id: ${{ github.event.workflow_run.id }}
29+
- id: trigger
30+
run: echo "pr-number=$(cat pr_number)" >> GITHUB_OUTPUT
31+
- name: Test pull_requests objects
32+
run: echo ${{ github.event.workflow_run.pull_requests }}
33+
- name: Upload coverage reports to Codecov
34+
uses: codecov/codecov-action@v4
35+
with:
36+
override_pr: ${{ steps.trigger.outputs.pr-number }}
37+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/pull_request.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ jobs:
5353
check-pr:
5454
uses: ./.github/workflows/build-and-test.yml
5555
with:
56-
upload-code-coverage: true
57-
secrets:
58-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
56+
collect-code-coverage: true
5957
danger-check:
6058
runs-on: ubuntu-latest
6159
permissions:
@@ -71,4 +69,17 @@ jobs:
7169
dangerfile: Dangerfile.df.kts
7270
env:
7371
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
store-pr-number:
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: Save PR number
76+
env:
77+
PR_NUMBER: ${{ github.event.number }}
78+
run: |
79+
mkdir -p ./pr
80+
echo $PR_NUMBER > ./pr/pr_number
81+
- uses: actions/upload-artifact@v4
82+
with:
83+
name: pr-number
84+
path: pr/
7485

0 commit comments

Comments
 (0)