eddiewebb / circleci-queue

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

support `tag-pattern` wrapped with slashes [semver:patch] #74

Closed duniul closed 2 years ago

duniul commented 3 years ago

Checklist

Motivation, issues

Issue Patterns passed to CircleCI's own tag/branch filters (e.g. filters.tags.only) are required to be wrapped with / to indicate that they are patterns, like /^release-.*/. However, if you pass the same pattern as tag-pattern to until_front_of_line it gets stuck in an infinite queue because it passes the slashes as part of the pattern.

Motivation

jobs: queue_job: steps:

workflows: version: 2

example_workflow: jobs:

Description

eddiewebb commented 3 years ago

bors try

@duniul - I'll work on a test, but will have bors publish a dev version you can try out as well.

eddiewebb commented 3 years ago

BotComment: Development version of orb available for manual validation - eddiewebb/queue@dev:74

bors[bot] commented 3 years ago

try

Build succeeded:

duniul commented 2 years ago

@eddiewebb Testing the orb I noticed a related issue: if the current build doesn't match the provided tag pattern (either because it's incorrect or because its own tag doesn't match the pattern) it gets filtered out of the list of active builds. This means augmented_jobstatus.json ends up empty and oldest_commit_time is null, getting the queue infinitely stuck.

I've fixed this in 9b965e7 by excluding the current build from the tag filtering step 👍 would you mind creating another dev version build and I'll try it out?

eddiewebb commented 2 years ago

bors try

eddiewebb commented 2 years ago

BotComment: Development version of orb available for manual validation - eddiewebb/queue@dev:74

bors[bot] commented 2 years ago

try

Build succeeded:

duniul commented 2 years ago

@eddiewebb Thanks! We've been using this in several workflow runs today and it seems to work correctly now 🎉

eddiewebb commented 2 years ago

bors merge

eddiewebb commented 2 years ago

BotComment: Development version of orb available for manual validation - eddiewebb/queue@dev:74

bors[bot] commented 2 years ago

Build failed:

eddiewebb commented 2 years ago

bors merge

eddiewebb commented 2 years ago

BotComment: Development version of orb available for manual validation - eddiewebb/queue@dev:74

eddiewebb commented 2 years ago

BotComment: Production version of orb available for use - eddiewebb/queue@1.6.4

bors[bot] commented 2 years ago

Build succeeded:

calvin-cdev commented 2 years ago

just caught up on this. nice contribution @duniul :D

calvin-cdev commented 2 years ago

wanted to note that this broke our usage of tag-pattern we had ours set to the following:

# jq regex uses `\\` for escape characters
tag-pattern: 'v0\\.\\d+\\.\\d+$'

which produced the following error when running after updating to use the orb with this PR's changes:

jq: error: Invalid escape at line 1, column 6 (while parsing '"\.\d"') at <top-level>, line 1:
[ .[] | select((.build_num | . == "85161") or (.vcs_tag | (. != null and ****("v0\.\d+\.\d+$"))) ) ]                                                                                 
jq: error: Invalid escape at line 1, column 6 (while parsing '"\.\d"') at <top-level>, line 1:
[ .[] | select((.build_num | . == "85161") or (.vcs_tag | (. != null and ****("v0\.\d+\.\d+$"))) ) ]                                                                                      
jq: 2 compile errors

Exited with code exit status 3
eddiewebb commented 2 years ago

@calvin-summer shoot sorry. Not clear though, Do we need to tweak this further, or is it easy fix in config once known?

calvin-cdev commented 2 years ago

@calvin-summer shoot sorry. Not clear though, Do we need to tweak this further, or is it easy fix in config once known?

going to work on it after the weekend. I'll update in this thread when I've figured it out.