-
Notifications
You must be signed in to change notification settings - Fork 5
161 lines (145 loc) · 6.21 KB
/
publish-qa-results.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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Publish QA Results
on:
workflow_call:
inputs:
api-test-outcome:
type: string
required: true
api-test-coverage-markdown-report:
type: string
required: true
python-test-outcome:
type: string
required: true
python-test-coverage-markdown-report:
type: string
required: true
web-test-outcome:
type: string
required: true
web-test-coverage-markdown-report:
type: string
required: true
eslint-outcome:
type: string
required: true
ruff-outcome:
type: string
required: true
mypy-outcome:
type: string
required: true
tflint-outcome:
type: string
required: true
pr-number:
type: string
required: true
write-summary:
type: boolean
default: true
write-comment:
type: boolean
default: false
permissions:
contents: read
pull-requests: write
jobs:
publish:
name: Publish QA Results
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
disable-sudo: true
egress-policy: audit
- name: Create URL to workflow run
id: workflow-run-summary-url
run: |
RUN_URL="$GH_SERVER/$GH_REPO/actions/runs/$GH_RUN_ID"
echo "url=$RUN_URL" >> $GITHUB_OUTPUT
echo "attempt-url=$RUN_URL/attempts/${{ github.run_attempt }}" >> $GITHUB_OUTPUT
env:
GH_SERVER: ${{ github.server_url }}
GH_REPO: ${{ github.repository }}
GH_RUN_ID: ${{ github.run_id }}
- name: Write the report markdown file
run: |
REPORT_FILE=$(mktemp -t summary.md.XXXXX)
echo "REPORT_FILE=$REPORT_FILE" >> $GITHUB_ENV
cat >> $REPORT_FILE << 'ENDOFREPORT'
## QA Summary
*Pusher: @${{ env.GH_ACTOR }}, Action: `${{ env.GH_ACTION }}`, Workflow: [`${{ env.GH_WORKFLOW }}`](${{ env.WORKFLOW_RUN_SUMMARY_URL }})*
_[See our documentation for tips on how to resolve failing QA checks.](${{ env.GH_SERVER}}/${{ env.GH_REPO }}/blob/main/docs/resolving-qa-failures.md)_
| QA Check | Result |
|:----------------|:-------:|
| 🌐 Web Tests | ${{ (env.WEB_TEST_OUTCOME == 'success' && '✅') || (env.WEB_TEST_OUTCOME == 'skipped' && '➖') || '❌' }} |
| 🔗 API Tests | ${{ (env.API_TEST_OUTCOME == 'success' && '✅') || (env.API_TEST_OUTCOME == 'skipped' && '➖') || '❌' }} |
| 🐍 Python Tests | ${{ (env.PYTHON_TEST_OUTCOME == 'success' && '✅') || (env.PYTHON_TEST_OUTCOME == 'skipped' && '➖') || '❌' }} |
| 📏 ESLint | ${{ (env.ESLINT_OUTCOME == 'success' && '✅') || (env.ESLINT_OUTCOME == 'skipped' && '➖') || '❌' }} |
| 🧼 Ruff | ${{ (env.RUFF_OUTCOME == 'success' && '✅') || (env.RUFF_OUTCOME == 'skipped' && '➖') || '❌' }} |
| 🛁 mypy | ${{ (env.MYPY_OUTCOME == 'success' && '✅') || (env.MYPY_OUTCOME == 'skipped' && '➖') || '❌' }} |
| 🧹 TFLint | ${{ (env.TFLINT_OUTCOME == 'success' && '✅') || (env.TFLINT_OUTCOME == 'skipped' && '➖') || '❌' }} |
### Test Coverage
_View the [workflow summary](${{ env.WORKFLOW_RUN_SUMMARY_ATTEMPT_URL }}) for individual coverage reports if this comment is truncated._
<details>
<summary>Coverage report for <code>api</code> suite</summary>
${{ env.API_COVERAGE_REPORT }}
</details>
<details>
<summary>Coverage report for <code>web</code> suite</summary>
${{ env.WEB_COVERAGE_REPORT }}
</details>
<details>
<summary>Coverage report for <code>python</code> suite</summary>
${{ env.PYTHON_COVERAGE_REPORT }}
</details>
ENDOFREPORT
env:
API_TEST_OUTCOME: ${{ inputs.api-test-outcome }}
API_COVERAGE_REPORT: ${{ inputs.api-test-coverage-markdown-report }}
WEB_TEST_OUTCOME: ${{ inputs.web-test-outcome }}
WEB_COVERAGE_REPORT: ${{ inputs.web-test-coverage-markdown-report }}
PYTHON_TEST_OUTCOME: ${{ inputs.python-test-outcome }}
PYTHON_COVERAGE_REPORT: ${{ inputs.python-test-coverage-markdown-report }}
ESLINT_OUTCOME: ${{ inputs.eslint-outcome }}
RUFF_OUTCOME: ${{ inputs.ruff-outcome }}
MYPY_OUTCOME: ${{ inputs.mypy-outcome }}
TFLINT_OUTCOME: ${{ inputs.tflint-outcome }}
WORKFLOW_RUN_SUMMARY_URL: ${{ steps.workflow-run-summary-url.outputs.url }}
WORKFLOW_RUN_SUMMARY_ATTEMPT_URL: ${{ steps.workflow-run-summary-url.outputs.attempt-url }}
GH_ACTOR: ${{ github.actor }}
GH_ACTION: ${{ github.event_name }}
GH_WORKFLOW: ${{ github.workflow }}
GH_SERVER: ${{ github.server_url }}
GH_REPO: ${{ github.repository }}
GH_RUN_ID: ${{ github.run_id }}
- name: Write the step summary
if: inputs.write-summary
run: cat $REPORT_FILE | head -c 65500 >> $GITHUB_STEP_SUMMARY # Observe GitHub's 65535 character limit
- name: Write the comment body
id: comment-body
run: |
CONTENT=$(cat $REPORT_FILE)
echo "REPORT_CONTENT<<ENDOFREPORT" >> $GITHUB_OUTPUT
echo "$CONTENT" >> $GITHUB_OUTPUT
echo "ENDOFREPORT" >> $GITHUB_OUTPUT
- name: Find previous report comment
id: find-comment
if: inputs.write-comment
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
with:
issue-number: ${{ inputs.pr-number }}
comment-author: 'github-actions[bot]'
body-includes: QA Summary
- name: Create or update comment
if: inputs.write-comment
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.comment-body.outputs.REPORT_CONTENT }}
edit-mode: replace