eddiewebb/circleci-queue

[semver:minor] Reduce payload from CircleCI recent-builds API to improve performance

Closed this issue · 1 comments

RELEASE CANDIDATE READY

➡️ Potential fix for this issue is ready ⬅️

For anyone willing to validate on non-critical workloads, please use eddiewebb/queue@dev:506 and report any issues on #112


Is your feature request related to a problem? Please describe.

Some users noted the Recent Builds for project API returning HTTP 400 at times (intermittent).

I noted the CircleCI V1 API is used:
https://circleci.com/docs/api/v1/index.html#recent-builds-for-a-single-project

Additionally, the shallow=true query parameter is recommended to reduce the returned payload, and possibly improve performance and reliability of the API response.

I noted from the Orb command's script that we are really only checking the following attributes from this API's response:

Attribute Evidence
.build_num
jq "[ .[] | select((.build_num | . == \"${CIRCLE_BUILD_NUM}\") or (.vcs_tag | (. != null and test(\"${tag_pattern}\"))) ) ]" /tmp/jobstatus.json >/tmp/jobstatus_tag.json
.vcs_tag
jq "[ .[] | select((.build_num | . == \"${CIRCLE_BUILD_NUM}\") or (.vcs_tag | (. != null and test(\"${tag_pattern}\"))) ) ]" /tmp/jobstatus.json >/tmp/jobstatus_tag.json
.workflow.workflow_id
for workflow in `jq -r ".[] | .workflows.workflow_id //empty" /tmp/augmented_jobstatus.json | uniq`

Additionally, I can confirm the .build_num, .vcs_tag and .workflow.workflow_id attributes are returned even when shallow=true.
For example:
https://circleci.com/api/v1.1/project/github/kelvintaywl/whale-of-a-time?shallow=true

As such, I think we can leverage the shallow=true query parameter for this Orb indeed.
Hopefully, this can reduce or alleviate the randomly-intermittent HTTP 400 from CircleCI too?
If anything, it should help to improve the performance of the script 🙏

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

THanks for great detail @kelvintaywl , I am in support of the shallow clone.