-
Notifications
You must be signed in to change notification settings - Fork 4
123 lines (110 loc) · 4.23 KB
/
ci-reports.yaml
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: "PR Reports"
on:
workflow_run:
workflows: ["CI"]
types:
- completed
permissions:
actions: read
checks: write
contents: read
pull-requests: write
jobs:
report:
name: "Report"
runs-on: ubuntu-latest
steps:
- name: Find workflow run
id: find-run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: octokit/[email protected]
with:
route: GET /repos/${{ github.event.workflow_run.repository.full_name }}/actions/runs/${{ github.event.workflow_run.id }}
- name: Extract PR number
id: get-pr
env:
GH_TOKEN: ${{ github.token }}
run: |
head_branch=$(echo '${{ steps.find-run.outputs.data }}' | jq -r '.head_branch')
head_sha=$(echo '${{ steps.find-run.outputs.data }}' | jq -r '.head_sha')
head_repo=$(echo '${{ steps.find-run.outputs.data }}' | jq -r '.head_repository.full_name')
head_repo_owner=$(echo '${{ steps.find-run.outputs.data }}' | jq -r '.head_repository.owner.login')
if [[ "${head_branch}" != "" && "${head_repo}" != "" ]]; then
pr_number="$(gh pr list -R ${{ github.repository }} --state open --json number,headRefName,headRepositoryOwner,headRepository,baseRefName -q "map(select(.headRefName == \"${head_branch}\" and .headRepositoryOwner.login == \"${head_repo_owner}\" and .baseRefName == \"main\")) | .[0].number" || true)"
else
pr_number=""
fi
if [[ "${pr_number}" != "" ]]; then
echo "This workflow run was for PR #${pr_number}."
else
echo "This workflow run was not for a PR."
fi
echo "pr_number=${pr_number}" >> "$GITHUB_OUTPUT"
echo "head_branch=${head_branch}" >> "$GITHUB_OUTPUT"
echo "head_sha=${head_sha}" >> "$GITHUB_OUTPUT"
echo "head_repo=${head_repo}" >> "$GITHUB_OUTPUT"
- name: Download code coverage reports
if: steps.get-pr.outputs.pr_number != ''
continue-on-error: true
uses: actions/download-artifact@v4
with:
pattern: codecov-reports*
merge-multiple: true
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
path: reports/
- name: Download performance reports
if: steps.get-pr.outputs.pr_number != ''
continue-on-error: true
uses: actions/download-artifact@v4
with:
pattern: perf-reports*
merge-multiple: true
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
path: reports/
- name: Download test results
if: steps.get-pr.outputs.pr_number != ''
continue-on-error: true
uses: actions/download-artifact@v4
with:
pattern: test-reports*
merge-multiple: true
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
path: reports/
- name: Show published reports
continue-on-error: true
if: steps.get-pr.outputs.pr_number != ''
run: |
ls -lR reports/
- name: "Synthesize event file"
if: steps.get-pr.outputs.pr_number != ''
run: |
echo \
'{
"pull_request": {
"head": {
"sha": "${{ steps.get-pr.outputs.head_sha }}",
"repo": {
"full_name": "${{ steps.get-pr.outputs.head_repo }}"
}
}
}
}' >event-file.json
- name: "Publish test results"
uses: EnricoMi/publish-unit-test-result-action@v2
if: steps.get-pr.outputs.pr_number != ''
continue-on-error: true
with:
commit: ${{ github.event.workflow_run.head_sha }}
event_file: event-file.json
event_name: ${{ github.event.workflow_run.event }}
files: reports/test-results-*.xml
- name: "Publish available .md reports to PR"
uses: marocchino/sticky-pull-request-comment@v2
if: steps.get-pr.outputs.pr_number != ''
with:
path: reports/*.md
number: ${{ steps.get-pr.outputs.pr_number }}