24
24
25
25
jobs :
26
26
determine-test-scope :
27
- runs-on : [ inhouse ]
27
+ runs-on : [ inhouse ]
28
28
if : |
29
29
github.event.pull_request.draft == false ||
30
30
github.ref == 'refs/heads/develop' ||
33
33
local_tests : ${{ steps.determine-test-type.outputs.local_tests }}
34
34
remote_tests : ${{ steps.determine-test-type.outputs.remote_tests }}
35
35
steps :
36
+ - name : check-current-approval-status
37
+ id : approval
38
+ if : github.event_name == 'pull_request'
39
+ uses : actions/github-script@v7
40
+ with :
41
+ script : |
42
+ const {owner, repo} = context.repo
43
+ const number = context.payload.pull_request.number
44
+ const reviews = await github.rest.pulls.listReviews({owner, repo, pull_number: number})
45
+
46
+ const latestByUser = {}
47
+ reviews.data.forEach(r => latestByUser[r.user.id] = r)
48
+
49
+ const approved = Object.values(latestByUser)
50
+ .some(r => r.state === 'APPROVED')
51
+ core.setOutput('approved', approved ? 'true' : 'false')
36
52
- name : determine-test-type
37
53
id : determine-test-type
38
54
env :
@@ -42,24 +58,26 @@ jobs:
42
58
REF : ${{ github.ref }}
43
59
INPUT_LOCAL : ${{ github.event.inputs.local_tests }}
44
60
INPUT_REMOTE : ${{ github.event.inputs.remote_tests }}
61
+ APPROVED : ${{ steps.approval.outputs.approved }}
45
62
run : |
46
63
echo "Event: $EVENT_NAME"
47
64
echo "Draft: $DRAFT_STATE"
48
65
echo "Review State: $REVIEW_STATE"
49
66
echo "Git REF: $REF"
50
67
echo "Input local: $INPUT_FAST"
51
68
echo "Input remote: $INPUT_FULL"
69
+ echo "Approved: $APPROVED"
52
70
53
71
remote_tests=false
54
72
local_tests=false
55
73
# Workflow_dispatch input override
56
74
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
57
-
75
+
58
76
# Each option is self contained
59
77
if [[ "$INPUT_REMOTE" == "true" ]]; then
60
78
remote_tests=true
61
79
fi
62
-
80
+
63
81
if [[ "$INPUT_LOCAL" == "true" ]]; then
64
82
local_tests=true
65
83
fi
@@ -76,11 +94,12 @@ jobs:
76
94
fi
77
95
fi
78
96
79
- # All PRs that have been triggered need local tests
97
+ # All PRs that have been triggered need local tests and approved ones need to re-run the remote tests
80
98
if [[ "$EVENT_NAME" == "pull_request" ]]; then
81
99
local_tests=true
100
+ [[ "$APPROVED" == "true" ]] && remote_tests=true
82
101
fi
83
-
102
+
84
103
# If it's a push to develop
85
104
if [[ "$EVENT_NAME" == "push" && "$REF" == "refs/heads/develop" ]]; then
86
105
local_tests=true
@@ -91,12 +110,12 @@ jobs:
91
110
echo "remote_tests=$remote_tests" >> $GITHUB_OUTPUT
92
111
echo "local_tests=$local_tests"
93
112
echo "remote_tests=$remote_tests"
94
-
113
+
95
114
lint :
96
115
needs : determine-test-scope
97
116
if : ( needs.determine-test-scope.outputs.local_tests == 'true' ) || ( needs.determine-test-scope.outputs.remote_tests == 'true' )
98
117
name : Run linting
99
- runs-on : [ inhouse ]
118
+ runs-on : [ inhouse ]
100
119
steps :
101
120
- uses : actions/checkout@v4
102
121
with :
@@ -111,10 +130,10 @@ jobs:
111
130
112
131
local-tests :
113
132
# Run on open PRs OR when manually triggered with local_tests=true
114
- needs : determine-test-scope
133
+ needs : determine-test-scope
115
134
if : needs.determine-test-scope.outputs.local_tests == 'true'
116
- name : Python ${{ matrix.python-version }} - self-hosted-runner
117
- runs-on : [ inhouse ]
135
+ name : Python ${{ matrix.python-version }} - self-hosted-runner
136
+ runs-on : [ inhouse ]
118
137
strategy :
119
138
matrix :
120
139
python-version : ['3.9', '3.13']
@@ -172,13 +191,13 @@ jobs:
172
191
diff-storage : _xml_coverage_reports
173
192
coverage-summary-title : " Code Coverage Summary"
174
193
togglable-report : true
175
-
194
+
176
195
- name : Changed files
177
196
id : diff
178
197
uses : step-security/changed-files@v46
179
198
with :
180
199
files : ' **/*.py'
181
-
200
+
182
201
- name : Slice report down to changed files
183
202
if : ${{ steps.diff.outputs.all_changed_files != '' }}
184
203
env :
@@ -188,7 +207,7 @@ jobs:
188
207
source ${GITHUB_WORKSPACE}/.venv/bin/activate
189
208
include=$(printf '%s\n' $CHANGED | sed 's|^|**/|' | paste -sd, -)
190
209
coverage xml -i -o changed.xml --include="$include"
191
-
210
+
192
211
- name : Produce the changed files coverage report
193
212
uses : insightsengineering/coverage-action@v2
194
213
if : ${{ steps.diff.outputs.all_changed_files != '' }}
@@ -201,7 +220,7 @@ jobs:
201
220
202
221
remote-tests :
203
222
# Run tests on a push event OR a workflow dispatch with remote_tests
204
- needs : determine-test-scope
223
+ needs : determine-test-scope
205
224
if : needs.determine-test-scope.outputs.remote_tests == 'true'
206
225
name : Python ${{ matrix.python-version }} - ${{ matrix.platform }}
207
226
runs-on : ${{ matrix.platform }}
@@ -215,6 +234,10 @@ jobs:
215
234
env : # Set environment variables for the whole job
216
235
PIP_ONLY_BINARY : gdstk
217
236
MPLBACKEND : agg
237
+
238
+ concurrency :
239
+ group : ${{ github.workflow }}-${{ github.event.pull_request.number }}-${{ matrix.platform }}-${{ matrix.python-version }}-remote
240
+ cancel-in-progress : true
218
241
219
242
steps :
220
243
- uses : actions/checkout@v4
@@ -271,7 +294,7 @@ jobs:
271
294
maxColorRange : 95
272
295
valColorRange : ${{ env.total }}
273
296
style : " for-the-badge"
274
-
297
+
275
298
pr-requirements-pass :
276
299
name : pr-requirements-pass
277
300
if : ( needs.determine-test-scope.outputs.local_tests == 'true' ) || ( needs.determine-test-scope.outputs.remote_tests == 'true' )
0 commit comments