eddiewebb / circleci-queue

CircleCI orb to block/queue jobs to enforce max concurrency limits
MIT License
74 stars 75 forks source link

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

Closed kelvintaywl closed 8 months ago

kelvintaywl commented 1 year ago

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 https://github.com/eddiewebb/circleci-queue/blob/988b09bac5b704500039dc08ce50e7645a5a5657/src/commands/until_front_of_line.yml#L131
.vcs_tag https://github.com/eddiewebb/circleci-queue/blob/988b09bac5b704500039dc08ce50e7645a5a5657/src/commands/until_front_of_line.yml#L131
.workflow.workflow_id https://github.com/eddiewebb/circleci-queue/blob/988b09bac5b704500039dc08ce50e7645a5a5657/src/commands/until_front_of_line.yml#L140

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.

eddiewebb commented 1 year ago

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