From 83f27b23a03233d05ea89e73a263f53f9daeb953 Mon Sep 17 00:00:00 2001 From: Lucas Kacher Date: Thu, 1 Dec 2022 15:48:33 -0800 Subject: [PATCH 01/13] feat: additional work --- .yamllint | 1 - src/executors/default.yml | 12 ------------ src/jobs/hello.yml | 4 +++- 3 files changed, 3 insertions(+), 14 deletions(-) delete mode 100755 src/executors/default.yml diff --git a/.yamllint b/.yamllint index c9a8a2e..d48c2d3 100644 --- a/.yamllint +++ b/.yamllint @@ -4,4 +4,3 @@ rules: line-length: max: 200 allow-non-breakable-inline-mappings: true - diff --git a/src/executors/default.yml b/src/executors/default.yml deleted file mode 100755 index ca3f5dc..0000000 --- a/src/executors/default.yml +++ /dev/null @@ -1,12 +0,0 @@ -description: > - This is a sample executor using Docker and Node. If you want to provide a custom environment in your orb, insert your image here. - If you do not require an executor, you can simply delete this directory. -docker: - - image: 'cimg/node:<>' -parameters: - tag: - default: lts - description: > - Pick a specific cimg/node image variant: - https://hub.docker.com/r/cimg/node/tags - type: string diff --git a/src/jobs/hello.yml b/src/jobs/hello.yml index 8f1df04..9455135 100755 --- a/src/jobs/hello.yml +++ b/src/jobs/hello.yml @@ -2,7 +2,9 @@ description: > Sample description # What will this job do? -executor: default +docker: + - image: cimg/base:stable +resource_class: small parameters: to: From 52b74dfec05c60e44a3fdbfe3638b57d87a3fa87 Mon Sep 17 00:00:00 2001 From: Lucas Kacher Date: Thu, 1 Dec 2022 15:57:38 -0800 Subject: [PATCH 02/13] feat: add scaffolding for additional queue command --- src/commands/queue.yml | 34 ++++++++++++++++++++++++++++++++++ src/jobs/hello.yml | 42 +++++++++++++++++++++++++++++++++++------- src/scripts/queue.sh | 9 +++++++++ 3 files changed, 78 insertions(+), 7 deletions(-) create mode 100755 src/commands/queue.yml create mode 100644 src/scripts/queue.sh diff --git a/src/commands/queue.yml b/src/commands/queue.yml new file mode 100755 index 0000000..e4f2f76 --- /dev/null +++ b/src/commands/queue.yml @@ -0,0 +1,34 @@ +description: > + This command is executed and blocks further execution until the necessary criteria is met. +parameters: + debug: + type: boolean + default: false + description: "If enabled, DEBUG messages will be logged." + time: + type: string + default: "10" + description: "Minutes to wait before giving up." + dont-quit: + type: boolean + default: false + description: "Force job through once time expires instead of failing." + only-on-branch: + type: string + default: "*" + description: "Only queue on specified branch" + confidence: + type: string + default: "1" + description: > + Due to concurrency issues, how many times should we requery the pipeline list to ensure previous jobs are "pending", + but not yet active. This number indicates the threshold for API returning no previous pending pipelines. + Default is one confirmation, increase if you see issues. + circleci-user-auth: + type: env_var_name + default: CIRCLECI_USER_AUTH + description: "In the event you wish to supply CCI basic-auth credentials via a different environment value, set the name here." +steps: +- run: + name: Queue Until Front of Line + command: <> diff --git a/src/jobs/hello.yml b/src/jobs/hello.yml index 9455135..5749b95 100755 --- a/src/jobs/hello.yml +++ b/src/jobs/hello.yml @@ -1,16 +1,44 @@ description: > - Sample description -# What will this job do? + This job is executed and blocks further execution until the necessary criteria is met. docker: - image: cimg/base:stable resource_class: small parameters: - to: + debug: + type: boolean + default: false + description: "If enabled, DEBUG messages will be logged." + time: type: string - default: "World" - description: "Hello to whom?" + default: "10" + description: "Minutes to wait before giving up." + dont-quit: + type: boolean + default: false + description: "Force job through once time expires instead of failing." + only-on-branch: + type: string + default: "*" + description: "Only queue on specified branch" + confidence: + type: string + default: "1" + description: > + Due to concurrency issues, how many times should we requery the pipeline list to ensure previous jobs are "pending", + but not yet active. This number indicates the threshold for API returning no previous pending pipelines. + Default is one confirmation, increase if you see issues. + circleci-user-auth: + type: env_var_name + default: CIRCLECI_USER_AUTH + description: "In the event you wish to supply CCI basic-auth credentials via a different environment value, set the name here." + steps: - - greet: - to: << parameters.to >> + - queue: + debug: << parameters.debug >> + time: <> + dont-quit: <> + only-on-branch: <> + confidence: <> + circleci-user-auth: <> diff --git a/src/scripts/queue.sh b/src/scripts/queue.sh new file mode 100644 index 0000000..e089459 --- /dev/null +++ b/src/scripts/queue.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +debug() { + if ["<< parameters.debug >>" == "true"]; then + echo "DEBUG: ${@}" + fi +} + +debug "this is a test" From 416da8da414ddc955922c18f2fd1f634838154d6 Mon Sep 17 00:00:00 2001 From: Lucas Kacher Date: Thu, 1 Dec 2022 16:04:57 -0800 Subject: [PATCH 03/13] fix: shellcheck --- src/scripts/queue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/queue.sh b/src/scripts/queue.sh index e089459..a1a7772 100644 --- a/src/scripts/queue.sh +++ b/src/scripts/queue.sh @@ -1,7 +1,7 @@ #!/bin/bash debug() { - if ["<< parameters.debug >>" == "true"]; then + if [ "<< parameters.debug >>" == "true" ]; then echo "DEBUG: ${@}" fi } From 604293bb1eefe06bc756d3d743b460b751d98505 Mon Sep 17 00:00:00 2001 From: Lucas Kacher Date: Thu, 1 Dec 2022 16:07:39 -0800 Subject: [PATCH 04/13] fix: shellcheck --- src/scripts/queue.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/scripts/queue.sh b/src/scripts/queue.sh index a1a7772..36152d5 100644 --- a/src/scripts/queue.sh +++ b/src/scripts/queue.sh @@ -1,8 +1,10 @@ #!/bin/bash +DEBUG_ENABLED="<< parameters.debug >>" + debug() { - if [ "<< parameters.debug >>" == "true" ]; then - echo "DEBUG: ${@}" + if [ "${DEBUG_ENABLED}" == "true" ]; then + echo "DEBUG: ${*}" fi } From 050b88704bcdc1739ca5c97be31fdf3edb114462 Mon Sep 17 00:00:00 2001 From: Lucas Kacher Date: Thu, 1 Dec 2022 16:09:32 -0800 Subject: [PATCH 05/13] feat: test our command --- .circleci/test-deploy.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index b026448..71224ce 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -15,8 +15,7 @@ jobs: - image: cimg/base:current steps: - checkout - # Run your orb's commands to validate them. - - workflow-queue/greet + - workflow-queue/queue workflows: test-deploy: jobs: From d352236414792ebd6ce00e50bfdcd76200e3112f Mon Sep 17 00:00:00 2001 From: Lucas Kacher Date: Thu, 1 Dec 2022 16:13:23 -0800 Subject: [PATCH 06/13] feat: enable debug --- .circleci/test-deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 71224ce..8119b49 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -16,6 +16,7 @@ jobs: steps: - checkout - workflow-queue/queue + debug: true workflows: test-deploy: jobs: From b63c0e74d4242820ad76497cbbb459662eebb4d4 Mon Sep 17 00:00:00 2001 From: Lucas Kacher Date: Fri, 2 Dec 2022 08:52:47 -0800 Subject: [PATCH 07/13] fix: rename queue job --- src/jobs/{hello.yml => queue.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/jobs/{hello.yml => queue.yml} (100%) diff --git a/src/jobs/hello.yml b/src/jobs/queue.yml similarity index 100% rename from src/jobs/hello.yml rename to src/jobs/queue.yml From d7ee4374fa749ac53366c36811e7cf01309a993c Mon Sep 17 00:00:00 2001 From: Lucas Kacher Date: Fri, 2 Dec 2022 08:54:48 -0800 Subject: [PATCH 08/13] fix: try to get this working --- .circleci/test-deploy.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 8119b49..71224ce 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -16,7 +16,6 @@ jobs: steps: - checkout - workflow-queue/queue - debug: true workflows: test-deploy: jobs: From 92ba2aeda0ac6ad5efd3fce78829d93ca3bf4df6 Mon Sep 17 00:00:00 2001 From: Lucas Kacher Date: Fri, 2 Dec 2022 09:07:31 -0800 Subject: [PATCH 09/13] feat: try to force debug on --- src/commands/greet.yml | 15 --------------- src/commands/queue.yml | 3 ++- src/scripts/greet.sh | 2 -- 3 files changed, 2 insertions(+), 18 deletions(-) delete mode 100755 src/commands/greet.yml delete mode 100644 src/scripts/greet.sh diff --git a/src/commands/greet.yml b/src/commands/greet.yml deleted file mode 100755 index f4e2205..0000000 --- a/src/commands/greet.yml +++ /dev/null @@ -1,15 +0,0 @@ -description: > - This command echos "Hello World" using file inclusion. -# What will this command do? -# Descriptions should be short, simple, and clear. -parameters: - to: - type: string - default: "World" - description: "Hello to whom?" -steps: - - run: - environment: - PARAM_TO: <> - name: Hello Greeting - command: <> diff --git a/src/commands/queue.yml b/src/commands/queue.yml index e4f2f76..c524363 100755 --- a/src/commands/queue.yml +++ b/src/commands/queue.yml @@ -1,9 +1,10 @@ description: > This command is executed and blocks further execution until the necessary criteria is met. + parameters: debug: type: boolean - default: false + default: true description: "If enabled, DEBUG messages will be logged." time: type: string diff --git a/src/scripts/greet.sh b/src/scripts/greet.sh deleted file mode 100644 index f01be79..0000000 --- a/src/scripts/greet.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -echo Hello "${PARAM_TO}" \ No newline at end of file From dc5d9e4e7a1b37281febff0df11a2e0b4b1e171f Mon Sep 17 00:00:00 2001 From: Lucas Kacher Date: Fri, 2 Dec 2022 09:17:55 -0800 Subject: [PATCH 10/13] feat: enable debug --- src/commands/queue.yml | 2 ++ src/scripts/queue.sh | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/queue.yml b/src/commands/queue.yml index c524363..dc80062 100755 --- a/src/commands/queue.yml +++ b/src/commands/queue.yml @@ -32,4 +32,6 @@ parameters: steps: - run: name: Queue Until Front of Line + environment: + DEBUG_ENABLED: "<< parameters.debug >>" command: <> diff --git a/src/scripts/queue.sh b/src/scripts/queue.sh index 36152d5..8ded00b 100644 --- a/src/scripts/queue.sh +++ b/src/scripts/queue.sh @@ -1,7 +1,5 @@ #!/bin/bash -DEBUG_ENABLED="<< parameters.debug >>" - debug() { if [ "${DEBUG_ENABLED}" == "true" ]; then echo "DEBUG: ${*}" From 548d98aa8db7688956e5f6d8a7f4c6499deb0d39 Mon Sep 17 00:00:00 2001 From: Lucas Kacher Date: Fri, 2 Dec 2022 09:25:59 -0800 Subject: [PATCH 11/13] retest From 0a1895edf72239be0b094ecdea3625ee85a3d96d Mon Sep 17 00:00:00 2001 From: Lucas Kacher Date: Fri, 2 Dec 2022 09:29:54 -0800 Subject: [PATCH 12/13] feat: more work --- src/scripts/queue.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/scripts/queue.sh b/src/scripts/queue.sh index 8ded00b..c6190cb 100644 --- a/src/scripts/queue.sh +++ b/src/scripts/queue.sh @@ -7,3 +7,4 @@ debug() { } debug "this is a test" +echo "this is a test" From 1c6ba9382f55023e0c1e1fd8b239640c202ce284 Mon Sep 17 00:00:00 2001 From: Lucas Kacher Date: Fri, 2 Dec 2022 11:41:52 -0800 Subject: [PATCH 13/13] feat: test --- src/scripts/queue.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/queue.sh b/src/scripts/queue.sh index c6190cb..70cc5be 100644 --- a/src/scripts/queue.sh +++ b/src/scripts/queue.sh @@ -1,7 +1,7 @@ #!/bin/bash debug() { - if [ "${DEBUG_ENABLED}" == "true" ]; then + if [ -n "${DEBUG_ENABLED}" ]; then echo "DEBUG: ${*}" fi }