eddiewebb / circleci-queue

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

fix JQ to allow for spaces in job names [semver:patch] #134

Closed RainofTerra closed 3 months ago

RainofTerra commented 3 months ago

Checklist

Motivation, issues, and description (because I mushed them all together)

Ok, so I thought I fixed #128 but not quite: there were issues in the jq as well. It was being treated as a regex, in particular with sx which means it would ignore whitespace which means it would fail the match for things with spaces in them. This PR changes it to explicitly check for equality unless a regex is specified.

It also changes this:

if [[ -z "$front_of_queue_pipeline_number" ]] || [[ -n "$MY_PIPELINE_NUMBER" ]] && [[ "$front_of_queue_pipeline_number" == "$MY_PIPELINE_NUMBER" ]]; then

to this:

    # This condition checks if the current job should proceed based on confidence level:
    # 1. If 'front_of_queue_pipeline_number' is empty, it means there are no other jobs in the queue, so the current job can proceed.
    # 2. If 'MY_PIPELINE_NUMBER' is non-empty and equals 'front_of_queue_pipeline_number', it means the current job is at the front of the queue and can proceed.
    # Confidence level is incremented if either of these conditions is true.
    if [[ -z "$front_of_queue_pipeline_number" ]] || ([[ -n "$MY_PIPELINE_NUMBER" ]] && [[ "$front_of_queue_pipeline_number" == "$MY_PIPELINE_NUMBER" ]]); then

which I think is what is actually wanted here because in my case, I have to poll the API 5 times before the job shows up with its own name. Though that makes me think this will probably need a high confidence level because otherwise, two jobs launched at the same time will probably still make it through (since neither might show up in the list right away)

Let me know if that isn't what you were going for.

eddiewebb commented 3 months ago

@RainofTerra - not sure if you have ideas bu shellcheck keeps removing the $ from MAX_TIME variable leaving it as string.

eddiewebb commented 3 months ago

BotComment: Development version of orb available for manual validation - Once an orb is created it cannot be deleted. Orbs are semver compliant, and each published version is immutable. Publicly released orbs are potential dependencies for other projects. Therefore, allowing orb deletion would make users susceptible to unexpected loss of functionality. eddiewebb/queue@dev:567

eddiewebb commented 3 months ago

BotComment: Production version of orb available for use - Once an orb is created it cannot be deleted. Orbs are semver compliant, and each published version is immutable. Publicly released orbs are potential dependencies for other projects. Therefore, allowing orb deletion would make users susceptible to unexpected loss of functionality. eddiewebb/queue@3.1.6

eddiewebb commented 3 months ago

BotComment: Development version of orb available for manual validation - Once an orb is created it cannot be deleted. Orbs are semver compliant, and each published version is immutable. Publicly released orbs are potential dependencies for other projects. Therefore, allowing orb deletion would make users susceptible to unexpected loss of functionality. eddiewebb/queue@dev:570

eddiewebb commented 3 months ago

BotComment: Production version of orb available for use - Once an orb is created it cannot be deleted. Orbs are semver compliant, and each published version is immutable. Publicly released orbs are potential dependencies for other projects. Therefore, allowing orb deletion would make users susceptible to unexpected loss of functionality. eddiewebb/queue@3.2.0