-
Notifications
You must be signed in to change notification settings - Fork 1
51 lines (49 loc) · 1.76 KB
/
Copy pathCodecov.yml
File metadata and controls
51 lines (49 loc) · 1.76 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
name: Codecov
on:
workflow_run:
workflows: ["Tests"]
types:
- completed
jobs:
upload:
if: >-
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event != 'schedule'
permissions:
actions: read
contents: read
pull-requests: read
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Download coverage artifacts
uses: actions/download-artifact@v4
with:
pattern: coverage
path: /tmp/coverage-artifacts
merge-multiple: true
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Restore coverage files
run: |
cp -v /tmp/coverage-artifacts/*.json . 2>/dev/null || true
- name: Resolve PR number on PR events
id: resolve_pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_NUMBER=""
if [ "${{ github.event.workflow_run.event }}" = "pull_request" ]; then
HEAD="${{ github.event.workflow_run.head_repository.owner.login }}:${{ github.event.workflow_run.head_branch }}"
PR_NUMBER=$(gh api "repos/${{ github.repository }}/pulls?state=all&head=${HEAD}" --jq ".[0].number // empty")
fi
echo "pr_number=${PR_NUMBER}" >> "$GITHUB_OUTPUT"
echo "Resolved PR: ${PR_NUMBER:-(none)}"
- name: Upload to Codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
CODECOV_COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
CODECOV_BRANCH: ${{ github.event.workflow_run.head_branch }}
CODECOV_PR: ${{ steps.resolve_pr.outputs.pr_number }}
run: ./dev/upload_codecov.sh