forked from adoptium/aqa-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
233 lines (213 loc) · 9.83 KB
/
Copy pathautoTestPR.yml
File metadata and controls
233 lines (213 loc) · 9.83 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
name: "Auto test PR"
on:
issue_comment:
types: [created]
permissions:
contents: write
issues: write
pull-requests: write
jobs:
autoTestPR:
runs-on: ubuntu-latest
if: startsWith(github.event.comment.body, 'auto exclude test')
steps:
- name: Set up Python 3.14
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: 3.14
- name: check python version
run: |
python -V
- name: install xml module
run: |
pip install lxml
- name: checkout current repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: 'tests'
- name: checkout TKG repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: 'adoptium/TKG.git'
ref: 'master'
path: 'TKG'
- name: run script
env:
comment_body: ${{ github.event.comment.body }}
run: |
git config --list
python TKG/scripts/testBot/disable.py -m "$comment_body" -c "${{ github.event.comment.html_url }}" -d "$GITHUB_WORKSPACE/tests"
- name: test cannot be found
if: failure()
run: |
curl -u github-actions:${{ secrets.GITHUB_TOKEN }} -d '{ "body": "The specified test cannot be excluded. Action run: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" }' -X POST ${{ github.event.issue.comments_url }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
path: 'tests'
title: '${{ github.event.comment.body }}'
body: |
related: ${{ github.event.comment.html_url }}
triggered by @${{ github.event.comment.user.login }}
commit-message: |
AUTO: ${{ github.event.comment.body }}
- related: ${{ github.event.comment.html_url }}
branch: 'autoTestPR'
branch-suffix: 'random'
signoff: 'true'
- name: add label
run: |
curl -u github-actions:${{ secrets.GITHUB_TOKEN }} -d '{"labels":["test excluded"]}' -X POST ${{ github.event.issue.url }}/labels
exclude-openjdk-test:
runs-on: ubuntu-latest
if: startsWith(github.event.comment.body, '/exclude ')
steps:
- name: Check permission
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMENTER: ${{ github.event.comment.user.login }}
ISSUE_AUTHOR: ${{ github.event.issue.user.login }}
run: |
# Allow if commenter is the issue author
if [ "$COMMENTER" = "$ISSUE_AUTHOR" ]; then
echo "✅ Commenter is the issue author"
exit 0
fi
# Allow if commenter is a project committer (write/admin permission)
PERMISSION=$(gh api \
-H "Accept: application/vnd.github+json" \
"/repos/${{ github.repository }}/collaborators/$COMMENTER/permission" \
--jq '.permission' 2>/dev/null || echo "none")
if [ "$PERMISSION" = "admin" ] || [ "$PERMISSION" = "write" ]; then
echo "✅ Commenter is a project committer with $PERMISSION permission"
exit 0
fi
# Deny if neither condition is met
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
"/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments" \
-f body="@${COMMENTER} ⛔ You don't have permission to trigger test exclusions. Only the issue author or project committers can use this command."
exit 1
- name: Parse exclude command
id: parse
env:
COMMENT_BODY: ${{ github.event.comment.body }}
COMMENTER: ${{ github.event.comment.user.login }}
run: |
# Extract command components
echo "commenter=$COMMENTER" >> "$GITHUB_OUTPUT"
# Basic validation - check format (minimum 3 required parameters + optional parameters)
# Format: /exclude <testcases> <issue_url> <platform> [jdk=<versions>] [impl=<impl>] [variant=<variant>]
if ! echo "$COMMENT_BODY" | grep -qE '^/exclude [^ ]+ [^ ]+ [^ ]+'; then
echo "❌ Invalid command format"
echo "Expected: /exclude <testcases> <issue_url> <platform> [jdk=<versions>] [impl=<impl>] [variant=<variant>]"
echo ""
echo "Examples:"
echo " /exclude java/beans/PropertyEditor/TestColorClassValue.java https://bugs.openjdk.java.net/browse/JDK-8173082 macosx-all"
echo " /exclude test.java https://bugs.openjdk.java.net/browse/JDK-8173082 linux-x64 jdk=11,17,21"
echo " /exclude test.java https://bugs.openjdk.java.net/browse/JDK-8173082 linux-x64 jdk=11 impl=openj9"
echo " /exclude test.java https://bugs.openjdk.java.net/browse/JDK-8173082 linux-x64 variant=alpine"
echo ""
echo "Note: When jdk= is omitted, defaults to LTS versions (8,11,17,21,25) + latest (26)"
exit 1
fi
# Extract testcases (second word)
TESTCASES=$(echo "$COMMENT_BODY" | awk '{print $2}')
echo "testcases=$TESTCASES" >> "$GITHUB_OUTPUT"
- name: Post acknowledgement comment
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TESTCASES: ${{ steps.parse.outputs.testcases }}
COMMENTER: ${{ steps.parse.outputs.commenter }}
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
"/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments" \
-f "body=@${COMMENTER} 🔧 Processing OpenJDK test exclusion for: \`${TESTCASES}\`..."
- name: Set up Python 3.14
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: 3.14
- name: Checkout current repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: 'tests'
- name: Run exclude script
id: exclude
env:
COMMENT_BODY: ${{ github.event.comment.body }}
COMMENT_URL: ${{ github.event.comment.html_url }}
run: |
cd tests
python scripts/disabled_tests/exclude_openjdk.py \
-m "$COMMENT_BODY" \
-c "$COMMENT_URL" \
-d "$GITHUB_WORKSPACE/tests"
- name: Script failed
if: failure() && steps.exclude.outcome == 'failure'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMENTER: ${{ steps.parse.outputs.commenter }}
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
"/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments" \
-f "body=@${COMMENTER} ❌ Failed to process exclusion. Please check the [action run](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}) for details."
- name: Create Pull Request
id: create-pr
if: success()
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
path: 'tests'
title: 'Exclude OpenJDK test: ${{ steps.parse.outputs.testcases }}'
body: |
**OpenJDK Test Exclusion**
- **Test(s)**: `${{ steps.parse.outputs.testcases }}`
- **Triggered by**: @${{ steps.parse.outputs.commenter }}
- **Related**: ${{ github.event.comment.html_url }}
This PR excludes the specified test(s) from ProblemList files.
See the commit for details on which ProblemList files were modified.
commit-message: |
Exclude OpenJDK test: ${{ steps.parse.outputs.testcases }}
Related: ${{ github.event.comment.html_url }}
branch: 'exclude-openjdk-test'
branch-suffix: 'random'
signoff: 'true'
- name: Add label
if: success()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
"/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels" \
-f "labels[]=test excluded"
- name: Comment success
if: success()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TESTCASES: ${{ steps.parse.outputs.testcases }}
COMMENTER: ${{ steps.parse.outputs.commenter }}
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
"/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments" \
-f "body=@${COMMENTER} ✅ Successfully created PR to exclude OpenJDK test(s): \`${TESTCASES}\`. Check the PR for details on which ProblemList files were modified."
- name: Comment no changes
if: success() && steps.create-pr.outputs.pull-request-number == ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TARGETS: ${{ steps.parse.outputs.targets }}
TESTCASE: ${{ steps.parse.outputs.testcase }}
COMMENTER: ${{ steps.parse.outputs.commenter }}
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
"/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments" \
-f "body=@${COMMENTER} ℹ️ No changes were made — \`${TESTCASE}\` may already be excluded for targets: \`${TARGETS}\`"