Skip to content

Commit 4919bd3

Browse files
committed
Fix #48659: Safari runs should run on the actual epochs
This is decidedly not my favorite fix, because it maintains the complex parsing, and the GitHub UI doesn't actually know what commit is being run against. However, it is actually a relatively small fix after we added support for PR runs a few months ago.
1 parent 8db2e3f commit 4919bd3

File tree

4 files changed

+223
-64
lines changed

4 files changed

+223
-64
lines changed

.github/workflows/safari_stable.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ jobs:
2929
name: "All Tests: Safari (stable)"
3030
needs: check-workflow-run
3131
if: |
32-
github.event_name != 'workflow_run' || fromJSON(needs.check-workflow-run.outputs.updated-refs)[0] != null
32+
github.event_name != 'workflow_run' || fromJSON(needs.check-workflow-run.outputs.updated-refs)['refs/heads/epochs/daily'] != null
3333
uses: ./.github/workflows/safari-wptrunner.yml
3434
with:
3535
artifact-name: safari-results
3636
safari-technology-preview: false
3737
safaridriver-diagnose: false
3838
matrix: '{"current-chunk": [1, 2, 3, 4, 5, 6, 7, 8], "total-chunks": [8]}'
3939
extra-options: --no-fail-on-unexpected
40+
fetch-ref: ${{ fromJSON(needs.check-workflow-run.outputs.updated-refs)['refs/heads/epochs/daily'] }}

.github/workflows/safari_technology_preview.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ jobs:
2929
name: "All Tests: Safari Technology Preview"
3030
needs: check-workflow-run
3131
if: |
32-
github.event_name != 'workflow_run' || fromJSON(needs.check-workflow-run.outputs.updated-refs)[0] != null
32+
github.event_name != 'workflow_run' || fromJSON(needs.check-workflow-run.outputs.updated-refs)['refs/heads/epochs/three_hourly'] != null
3333
uses: ./.github/workflows/safari-wptrunner.yml
3434
with:
3535
artifact-name: safari-technology-preview-results
3636
safari-technology-preview: true
3737
safaridriver-diagnose: false
3838
matrix: '{"current-chunk": [1, 2, 3, 4, 5, 6, 7, 8], "total-chunks": [8]}'
3939
extra-options: --no-fail-on-unexpected
40+
fetch-ref: ${{ fromJSON(needs.check-workflow-run.outputs.updated-refs)['refs/heads/epochs/three_hourly'] }}

tools/ci/check_for_updated_refs.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
import os
33
import re
44
import sys
5-
from typing import IO, Container, Dict, Iterable, List, Optional
5+
from typing import IO, Container, Dict, Iterable, Optional
6+
67

78
GIT_PUSH = re.compile(
8-
r"^(?P<flag>.)\t(?P<from>[^\t:]*):(?P<to>[^\t:]*)\t(?P<summary>.*[^\)])(?: \((?P<reason>[^\)]*)\))?\n$"
9+
r"^(?P<flag>.)\t(?P<from_ref>[^\t:]*):(?P<to_ref>[^\t:]*)\t(?P<summary>.*?)(?: \((?P<reason>.*)\))?\n$"
910
)
1011

1112

@@ -16,18 +17,29 @@ def parse_push(fd: IO[str]) -> Iterable[Dict[str, Optional[str]]]:
1617
yield m.groupdict()
1718

1819

19-
def process_push(fd: IO[str], refs: Container[str]) -> List[str]:
20-
updated_refs = []
20+
def process_push(fd: IO[str], refs: Container[str]) -> Dict[str, Optional[str]]:
21+
updated_refs = {}
2122

2223
for ref_status in parse_push(fd):
2324
flag = ref_status["flag"]
2425
if flag not in (" ", "+", "-", "*"):
2526
continue
2627

27-
to = ref_status["to"]
28-
assert to is not None
29-
if to in refs:
30-
updated_refs.append(to)
28+
to_ref = ref_status["to_ref"]
29+
summary = ref_status["summary"]
30+
assert to_ref is not None
31+
assert summary is not None
32+
33+
if to_ref in refs:
34+
sha = None
35+
36+
if flag in (" ", "+"):
37+
if "..." in summary:
38+
_, sha = summary.split("...", maxsplit=1)
39+
elif ".." in summary:
40+
_, sha = summary.split("..", maxsplit=1)
41+
42+
updated_refs[to_ref] = sha
3143

3244
return updated_refs
3345

tools/ci/tests/test_check_for_updated_refs.py

Lines changed: 199 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -5,102 +5,247 @@
55
from tools.ci import check_for_updated_refs
66

77

8-
def test_parse_push():
9-
s = io.StringIO(
10-
"""
11-
To github.com:gsnedders/web-platform-tests.git
12-
= refs/heads/a:refs/heads/a [up to date]
13-
- :refs/heads/b [deleted]
14-
+ refs/heads/c:refs/heads/c a6eb923e19...9b6507e295 (forced update)
15-
* refs/heads/d:refs/heads/d [new branch]
16-
\x20 refs/heads/e:refs/heads/e 0acd8f62f1..6188942729
17-
! refs/heads/f:refs/heads/f [rejected] (atomic push failed)
8+
PUSH_OUTPUT = """To github.com:web-platform-tests/wpt.git
9+
= refs/heads/stable:refs/heads/stable [up to date]
10+
- :refs/heads/deleted [deleted]
11+
+ refs/heads/force:refs/heads/force 7151480...62ee8b6 (forced update)
12+
* refs/heads/new:refs/heads/new [new branch]
13+
* refs/tags/v1.0:refs/tags/v1.0 [new tag]
14+
* refs/review/pr/123:refs/review/pr/123 [new reference]
15+
\x20 refs/heads/main:refs/heads/main 2e0d156..fd86363
16+
\x20 HEAD:refs/heads/feature 49d4a17..5105902
17+
\x20 refs/heads/short-sha:refs/heads/short-sha 9731..e320
18+
\x20 refs/heads/long-sha:refs/heads/long-sha 01e1bec7812eb37679c0b1cb436290a83cbc4694..8ec0c04d22002009e9db16f5e3c5518574907c93
19+
! refs/heads/reject1:refs/heads/reject1 [rejected] (non-fast-forward)
20+
! refs/heads/reject2:refs/heads/reject2 [rejected] (already exists)
21+
! refs/heads/reject3:refs/heads/reject3 [rejected] (fetch first)
22+
! refs/heads/reject4:refs/heads/reject4 [rejected] (needs force)
23+
! refs/heads/reject5:refs/heads/reject5 [rejected] (stale info)
24+
! refs/heads/reject6:refs/heads/reject6 [rejected] (remote ref updated since checkout)
25+
! refs/heads/reject7:refs/heads/reject7 [rejected] (new shallow roots not allowed)
26+
! refs/heads/reject8:refs/heads/reject8 [rejected] (atomic push failed)
27+
! refs/heads/reject9:refs/heads/reject9 [remote rejected] (hook declined)
28+
! refs/heads/reject10:refs/heads/reject10 [remote failure] (timeout)
29+
! refs/heads/reject11:refs/heads/reject11 [no match]
1830
Done
19-
"""
20-
)
31+
"""
32+
33+
34+
def test_parse_push():
35+
s = io.StringIO(PUSH_OUTPUT)
2136

2237
actual = list(check_for_updated_refs.parse_push(s))
23-
print(repr(actual))
2438
expected = [
2539
{
2640
"flag": "=",
27-
"from": "refs/heads/a",
28-
"to": "refs/heads/a",
41+
"from_ref": "refs/heads/stable",
42+
"to_ref": "refs/heads/stable",
2943
"summary": "[up to date]",
3044
"reason": None,
3145
},
3246
{
3347
"flag": "-",
34-
"from": "",
35-
"to": "refs/heads/b",
48+
"from_ref": "",
49+
"to_ref": "refs/heads/deleted",
3650
"summary": "[deleted]",
3751
"reason": None,
3852
},
3953
{
4054
"flag": "+",
41-
"from": "refs/heads/c",
42-
"to": "refs/heads/c",
43-
"summary": "a6eb923e19...9b6507e295",
55+
"from_ref": "refs/heads/force",
56+
"to_ref": "refs/heads/force",
57+
"summary": "7151480...62ee8b6",
4458
"reason": "forced update",
4559
},
4660
{
4761
"flag": "*",
48-
"from": "refs/heads/d",
49-
"to": "refs/heads/d",
62+
"from_ref": "refs/heads/new",
63+
"to_ref": "refs/heads/new",
5064
"summary": "[new branch]",
5165
"reason": None,
5266
},
67+
{
68+
"flag": "*",
69+
"from_ref": "refs/tags/v1.0",
70+
"to_ref": "refs/tags/v1.0",
71+
"summary": "[new tag]",
72+
"reason": None,
73+
},
74+
{
75+
"flag": "*",
76+
"from_ref": "refs/review/pr/123",
77+
"to_ref": "refs/review/pr/123",
78+
"summary": "[new reference]",
79+
"reason": None,
80+
},
81+
{
82+
"flag": " ",
83+
"from_ref": "refs/heads/main",
84+
"to_ref": "refs/heads/main",
85+
"summary": "2e0d156..fd86363",
86+
"reason": None,
87+
},
5388
{
5489
"flag": " ",
55-
"from": "refs/heads/e",
56-
"to": "refs/heads/e",
57-
"summary": "0acd8f62f1..6188942729",
90+
"from_ref": "HEAD",
91+
"to_ref": "refs/heads/feature",
92+
"summary": "49d4a17..5105902",
5893
"reason": None,
5994
},
95+
{
96+
"flag": " ",
97+
"from_ref": "refs/heads/short-sha",
98+
"to_ref": "refs/heads/short-sha",
99+
"summary": "9731..e320",
100+
"reason": None,
101+
},
102+
{
103+
"flag": " ",
104+
"from_ref": "refs/heads/long-sha",
105+
"to_ref": "refs/heads/long-sha",
106+
"summary": "01e1bec7812eb37679c0b1cb436290a83cbc4694..8ec0c04d22002009e9db16f5e3c5518574907c93",
107+
"reason": None,
108+
},
109+
{
110+
"flag": "!",
111+
"from_ref": "refs/heads/reject1",
112+
"to_ref": "refs/heads/reject1",
113+
"summary": "[rejected]",
114+
"reason": "non-fast-forward",
115+
},
116+
{
117+
"flag": "!",
118+
"from_ref": "refs/heads/reject2",
119+
"to_ref": "refs/heads/reject2",
120+
"summary": "[rejected]",
121+
"reason": "already exists",
122+
},
123+
{
124+
"flag": "!",
125+
"from_ref": "refs/heads/reject3",
126+
"to_ref": "refs/heads/reject3",
127+
"summary": "[rejected]",
128+
"reason": "fetch first",
129+
},
130+
{
131+
"flag": "!",
132+
"from_ref": "refs/heads/reject4",
133+
"to_ref": "refs/heads/reject4",
134+
"summary": "[rejected]",
135+
"reason": "needs force",
136+
},
137+
{
138+
"flag": "!",
139+
"from_ref": "refs/heads/reject5",
140+
"to_ref": "refs/heads/reject5",
141+
"summary": "[rejected]",
142+
"reason": "stale info",
143+
},
60144
{
61145
"flag": "!",
62-
"from": "refs/heads/f",
63-
"to": "refs/heads/f",
146+
"from_ref": "refs/heads/reject6",
147+
"to_ref": "refs/heads/reject6",
148+
"summary": "[rejected]",
149+
"reason": "remote ref updated since checkout",
150+
},
151+
{
152+
"flag": "!",
153+
"from_ref": "refs/heads/reject7",
154+
"to_ref": "refs/heads/reject7",
155+
"summary": "[rejected]",
156+
"reason": "new shallow roots not allowed",
157+
},
158+
{
159+
"flag": "!",
160+
"from_ref": "refs/heads/reject8",
161+
"to_ref": "refs/heads/reject8",
64162
"summary": "[rejected]",
65163
"reason": "atomic push failed",
66164
},
165+
{
166+
"flag": "!",
167+
"from_ref": "refs/heads/reject9",
168+
"to_ref": "refs/heads/reject9",
169+
"summary": "[remote rejected]",
170+
"reason": "hook declined",
171+
},
172+
{
173+
"flag": "!",
174+
"from_ref": "refs/heads/reject10",
175+
"to_ref": "refs/heads/reject10",
176+
"summary": "[remote failure]",
177+
"reason": "timeout",
178+
},
179+
{
180+
"flag": "!",
181+
"from_ref": "refs/heads/reject11",
182+
"to_ref": "refs/heads/reject11",
183+
"summary": "[no match]",
184+
"reason": None,
185+
},
67186
]
68187

69188
assert expected == actual
70189

71190

72-
def test_process_push():
191+
def test_parse_push_malformed_lines():
73192
s = io.StringIO(
74-
"""
75-
To github.com:gsnedders/web-platform-tests.git
76-
= refs/heads/a:refs/heads/a [up to date]
77-
- :refs/heads/b [deleted]
78-
+ refs/heads/c:refs/heads/c a6eb923e19...9b6507e295 (forced update)
79-
* refs/heads/d:refs/heads/d [new branch]
80-
\x20 refs/heads/e:refs/heads/e 0acd8f62f1..6188942729
81-
! refs/heads/f:refs/heads/f [rejected] (atomic push failed)
193+
"""To github.com:test/repo.git
194+
\x20 refs/heads/good:refs/heads/good be30154..bd80959
195+
malformed line without tabs
196+
another bad line
197+
\x20 refs/heads/good2:refs/heads/good2 ae0f96f..207e07b
82198
Done
83-
"""
199+
"""
84200
)
85201

86-
actual = list(
87-
check_for_updated_refs.process_push(
88-
s,
89-
[
90-
"refs/heads/e",
91-
"refs/heads/b",
92-
"refs/heads/c",
93-
"refs/heads/d",
94-
"refs/heads/e",
95-
"refs/heads/x",
96-
],
97-
)
98-
)
202+
actual = list(check_for_updated_refs.parse_push(s))
99203
expected = [
100-
"refs/heads/b",
101-
"refs/heads/c",
102-
"refs/heads/d",
103-
"refs/heads/e",
204+
{
205+
"flag": " ",
206+
"from_ref": "refs/heads/good",
207+
"to_ref": "refs/heads/good",
208+
"summary": "be30154..bd80959",
209+
"reason": None,
210+
},
211+
{
212+
"flag": " ",
213+
"from_ref": "refs/heads/good2",
214+
"to_ref": "refs/heads/good2",
215+
"summary": "ae0f96f..207e07b",
216+
"reason": None,
217+
},
104218
]
105219

106220
assert expected == actual
221+
222+
223+
def test_process_push():
224+
s = io.StringIO(PUSH_OUTPUT)
225+
226+
actual = check_for_updated_refs.process_push(
227+
s,
228+
[
229+
"refs/heads/stable", # Omitted as it wasn't actually updated.
230+
"refs/heads/deleted",
231+
"refs/heads/force",
232+
"refs/heads/new",
233+
"refs/tags/v1.0",
234+
"refs/review/pr/123",
235+
"refs/heads/main",
236+
"refs/heads/feature",
237+
"refs/heads/reject1", # Omitted as it wasn't actually updated.
238+
"refs/heads/nonexistent", # Omitted as it wasn't actually updated.
239+
],
240+
)
241+
expected = {
242+
"refs/heads/deleted": None,
243+
"refs/heads/force": "62ee8b6",
244+
"refs/heads/new": None,
245+
"refs/tags/v1.0": None,
246+
"refs/review/pr/123": None,
247+
"refs/heads/main": "fd86363",
248+
"refs/heads/feature": "5105902",
249+
}
250+
251+
assert expected == actual

0 commit comments

Comments
 (0)