Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 04443d5

Browse files
committed
Remove the limit for querying a baseline
`--limit=1` seems to apply before `jq` filtering, meaning our `WORKFLOW_NAME` ("CI") workflow may not appear in the input to the jq query. Removing `--limit` provides a default amount of inputs that jq can then filter from, so this works better.
1 parent a298d92 commit 04443d5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ci/ci-util.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,22 +201,24 @@ def locate_baseline(flags: list[str]) -> None:
201201
"gh",
202202
"run",
203203
"list",
204-
"--limit=1",
205204
"--status=success",
206205
f"--branch={DEFAULT_BRANCH}",
207206
"--json=databaseId,url,headSha,conclusion,createdAt,"
208207
"status,workflowDatabaseId,workflowName",
209-
f'--jq=select(.[].workflowName == "{WORKFLOW_NAME}")',
208+
# Return the first array element matching our workflow name. NB: cannot
209+
# just use `--limit=1`, jq filtering happens after limiting. We also
210+
# cannot just use `--workflow` because GH gets confused from
211+
# different file names in history.
212+
f'--jq=[.[] | select(.workflowName == "{WORKFLOW_NAME}")][0]',
210213
],
211214
text=True,
212215
)
213-
eprint(f"latest: '{latest_job}'")
214216
except sp.CalledProcessError as e:
215217
eprint(f"failed to run github command: {e}")
216218
return
217219

218220
try:
219-
latest = json.loads(latest_job)[0]
221+
latest = json.loads(latest_job)
220222
eprint("latest job: ", json.dumps(latest, indent=4))
221223
except json.JSONDecodeError as e:
222224
eprint(f"failed to decode json '{latest_job}', {e}")

0 commit comments

Comments
 (0)