Repository navigation
193 lines (164 loc) · 6.81 KB
/
Copy pathcall-patchworks-api.yaml
File metadata and controls
193 lines (164 loc) · 6.81 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
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: Call-Patchworks-Api
on:
issue_comment:
types: [created]
env:
PRECOMMIT_REPOSITORY: ${{ github.repository }}
PATCHWORK_REPORTING_ENABLED: ${{ vars.PATCHWORK_REPORTING_ENABLED }}
permissions:
actions: read
contents: read
issues: read
jobs:
get-patch-info:
runs-on: ubuntu-24.04
environment: production
if: ${{ vars.PATCHWORK_REPORTING_ENABLED == 'true' && !github.event.issue.pull_request && (contains(github.event.comment.body, '/pass_') || contains(github.event.comment.body, '/warn_') || contains(github.event.comment.body, '/error_')) && contains(format(',{0},', vars.PATCHWORK_OVERRIDE_USERS), format(',{0},', github.actor)) }}
defaults:
run:
working-directory: riscv-gnu-toolchain
steps:
- uses: actions/checkout@v4
- name: Setup env
uses: ./.github/actions/common/setup-env
with:
free_up_space: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
- name: Install Python dependencies
run: |
pip install -r ../requirements.txt --break-system-packages
- name: Get patch-name
id: patch-name
env:
ISSUE_TITLE: ${{ github.event.issue.title }}
run: |
PATCH_NAME=${ISSUE_TITLE##* }
if [[ ! "$PATCH_NAME" =~ ^[A-Za-z0-9._-]+$ ]]; then
echo "Invalid patch artifact name: $PATCH_NAME" >&2
exit 1
fi
echo "$PATCH_NAME"
echo "patch_name=$PATCH_NAME" >> "$GITHUB_OUTPUT"
- name: Get check
id: check
env:
COMMENT_BODY: ${{ github.event.comment.body }}
run: |
COMMAND=${COMMENT_BODY%%$'\n'*}
if [[ ! "$COMMAND" =~ ^/(pass|warn|error)_(test|apply|build|lint)([[:space:]]|$) ]]; then
echo "Unsupported Patchwork override command" >&2
exit 1
fi
RESULT=${BASH_REMATCH[1]}
CONTEXT=${BASH_REMATCH[2]}
case "$CONTEXT" in
test) CHECK=Testing ;;
apply) CHECK=Apply; CONTEXT=apply-patch ;;
build) CHECK=Build ;;
lint) CHECK=Lint ;;
esac
echo "$CHECK"
echo "$CONTEXT"
echo "result=$RESULT" >> "$GITHUB_OUTPUT"
echo "check=$CHECK" >> "$GITHUB_OUTPUT"
echo "context=$CONTEXT" >> "$GITHUB_OUTPUT"
- name: Download patch
run: |
python ./scripts/download_artifact.py -name "${{ steps.patch-name.outputs.patch_name }}-downloaded-patches" -repo "${PRECOMMIT_REPOSITORY}" -token '${{ secrets.GITHUB_TOKEN }}' -outdir ./patches
- name: Get patch id
id: patch-id
run: |
PATCH_ID=$(tail -n 1 "./patches/${{ steps.patch-name.outputs.patch_name }}")
if [[ ! "$PATCH_ID" =~ ^[0-9]+$ ]]; then
echo "Invalid Patchwork patch id: $PATCH_ID" >&2
exit 1
fi
echo "$PATCH_ID"
echo "patch_id=$PATCH_ID" >> "$GITHUB_OUTPUT"
outputs:
patch_name: ${{ steps.patch-name.outputs.patch_name }}
patch_id: ${{ steps.patch-id.outputs.patch_id }}
check: ${{ steps.check.outputs.check }}
context: ${{ steps.check.outputs.context }}
result: ${{ steps.check.outputs.result }}
report-pass:
needs: [get-patch-info]
if: ${{ needs.get-patch-info.outputs.result == 'pass' && vars.PATCHWORK_REPORTING_ENABLED == 'true' }}
runs-on: ubuntu-24.04
environment: production
defaults:
run:
working-directory: riscv-gnu-toolchain
steps:
- uses: actions/checkout@v4
- name: Setup env
uses: ./.github/actions/common/setup-env
with:
free_up_space: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
- name: Install Python dependencies
run: |
pip install -r ../requirements.txt --break-system-packages
- name: Report pass
run: |
if [[ '${{ needs.get-patch-info.outputs.check }}' == 'Apply' ]]; then DESC="Patch applied"; else DESC="${{ needs.get-patch-info.outputs.check }} passed"; fi
python scripts/post_check_to_patchworks.py -event '${{ github.event_name }}' -repo "${PRECOMMIT_REPOSITORY}" -pid '${{ needs.get-patch-info.outputs.patch_id }}' -desc "$DESC" -iid '${{ github.event.issue.number }}' -state 'success' -context '${{ needs.get-patch-info.outputs.context }}' -token '${{ secrets.PATCHWORK_API }}'
report-warn:
needs: [get-patch-info]
if: ${{ needs.get-patch-info.outputs.result == 'warn' && vars.PATCHWORK_REPORTING_ENABLED == 'true' }}
runs-on: ubuntu-24.04
environment: production
defaults:
run:
working-directory: riscv-gnu-toolchain
steps:
- uses: actions/checkout@v4
- name: Setup env
uses: ./.github/actions/common/setup-env
with:
free_up_space: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
- name: Install Python dependencies
run: |
pip install -r ../requirements.txt --break-system-packages
- name: Report Warning
run: |
python scripts/post_check_to_patchworks.py -event '${{ github.event_name }}' -repo "${PRECOMMIT_REPOSITORY}" -pid '${{ needs.get-patch-info.outputs.patch_id }}' -desc '${{ needs.get-patch-info.outputs.check }} warning' -iid '${{ github.event.issue.number }}' -state 'warning' -context '${{ needs.get-patch-info.outputs.context }}' -token '${{ secrets.PATCHWORK_API }}'
report-error:
needs: [get-patch-info]
if: ${{ needs.get-patch-info.outputs.result == 'error' && vars.PATCHWORK_REPORTING_ENABLED == 'true' }}
runs-on: ubuntu-24.04
environment: production
defaults:
run:
working-directory: riscv-gnu-toolchain
steps:
- uses: actions/checkout@v4
- name: Setup env
uses: ./.github/actions/common/setup-env
with:
free_up_space: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
- name: Install Python dependencies
run: |
pip install -r ../requirements.txt --break-system-packages
- name: Report Error
run: |
if [[ '${{ needs.get-patch-info.outputs.check }}' == 'Apply' ]]; then DESC="Patch failed to apply"; else DESC="${{ needs.get-patch-info.outputs.check }} failed"; fi
python scripts/post_check_to_patchworks.py -event '${{ github.event_name }}' -repo "${PRECOMMIT_REPOSITORY}" -pid '${{ needs.get-patch-info.outputs.patch_id }}' -desc "$DESC" -iid '${{ github.event.issue.number }}' -state 'fail' -context '${{ needs.get-patch-info.outputs.context }}' -token '${{ secrets.PATCHWORK_API }}'