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.
This commit is contained in:
Trevor Gross 2025-01-16 20:30:47 +00:00 committed by Trevor Gross
parent 753af94f1f
commit f39af6cb97

View file

@ -201,22 +201,24 @@ def locate_baseline(flags: list[str]) -> None:
"gh",
"run",
"list",
"--limit=1",
"--status=success",
f"--branch={DEFAULT_BRANCH}",
"--json=databaseId,url,headSha,conclusion,createdAt,"
"status,workflowDatabaseId,workflowName",
f'--jq=select(.[].workflowName == "{WORKFLOW_NAME}")',
# Return the first array element matching our workflow name. NB: cannot
# just use `--limit=1`, jq filtering happens after limiting. We also
# cannot just use `--workflow` because GH gets confused from
# different file names in history.
f'--jq=[.[] | select(.workflowName == "{WORKFLOW_NAME}")][0]',
],
text=True,
)
eprint(f"latest: '{latest_job}'")
except sp.CalledProcessError as e:
eprint(f"failed to run github command: {e}")
return
try:
latest = json.loads(latest_job)[0]
latest = json.loads(latest_job)
eprint("latest job: ", json.dumps(latest, indent=4))
except json.JSONDecodeError as e:
eprint(f"failed to decode json '{latest_job}', {e}")