forked from tronprotocol/java-tron
-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (66 loc) · 2.26 KB
/
coverage-upload.yml
File metadata and controls
73 lines (66 loc) · 2.26 KB
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
name: Codecov Upload & Compare
on:
workflow_run:
workflows:
- Coverage Build
types:
- completed
permissions:
contents: read
actions: read
pull-requests: read
jobs:
upload-coverage:
name: Upload Coverage
if: >
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'pull_request'
runs-on: ubuntu-latest
outputs:
pr_number: ${{ steps.pr.outputs.pr_number }}
steps:
- name: Checkout repo
uses: actions/checkout@v5 # must download source code
with:
fetch-depth: 0
persist-credentials: false
- name: Download coverage artifact
uses: actions/download-artifact@v7
with:
name: jacoco-coverage
path: coverage
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Get PR details
id: pr
uses: actions/github-script@v8
with:
script: |
const headSha = context.payload.workflow_run.head_sha;
const headOwner = context.payload.workflow_run.head_repository.owner.login;
const headBranch = context.payload.workflow_run.head_branch;
const { data: pulls } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'all',
head: `${headOwner}:${headBranch}`,
});
const pr = pulls.find((p) => p.head.sha === headSha);
if (pr) {
core.setOutput('pr_number', pr.number);
core.setOutput('pr_sha', headSha);
core.setOutput('pr_branch', headBranch);
core.setOutput('base_sha', pr.base.sha);
} else {
core.setFailed(`No pull request found for commit ${headSha}`);
}
- name: Upload to Codecov
if: ${{ steps.pr.outputs.pr_number != '' }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
override_commit: ${{ steps.pr.outputs.pr_sha }}
override_branch: ${{ steps.pr.outputs.pr_branch }}
override_pr: ${{ steps.pr.outputs.pr_number }}
fail_ci_if_error: true
verbose: true