diff --git a/.circleci/config.yml b/.circleci/config.yml index d93b0923..8f7215c2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2.1 orbs: - orbtools: gofunky/orbtools@dev:198 + orbtools: gofunky/orbtools@dev:691 envorb: gofunky/envorb@0.3.9 docker: gofunky/docker@0.1.2 @@ -46,6 +46,10 @@ orbtools_job: &orbtools_job context: docker-hub args: "VERSION=${CLI_VERSION},ALPINE=${ALPINE_VERSION},CLI=${CLI_VERSION}" +orb_tests: &orb_tests + success-config: test/success-test.yml + #fail-config: test/invalid-test.yml + workflows: build_latest_image: jobs: @@ -97,16 +101,14 @@ workflows: check_orb: jobs: - orbtools/check: - name: check_pull_request - <<: [*pr_filter, *use_alpine_version] + <<: [*pr_filter, *use_alpine_version, *orb_tests] publish_orb: jobs: - - orbtools/env-pack-publish: - name: publish_latest + - orbtools/publish: context: orb-tools version: "dev:${CIRCLE_BUILD_NUM}" - <<: [*master_filter, *use_alpine_version] + <<: [*master_filter, *use_alpine_version, *orb_tests] release_orb: jobs: @@ -116,8 +118,7 @@ workflows: variable: ORB_PUBLISHING_VERSION <<: [*tag_filter, *use_alpine_version] - - orbtools/env-pack-publish: - name: publish_release + - orbtools/publish: context: orb-tools - <<: [*tag_filter, *use_alpine_version] + <<: [*tag_filter, *use_alpine_version, *orb_tests] requires: [release_tag] diff --git a/Dockerfile b/Dockerfile index 2a7cc044..b9d8b60c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ ARG ALPINE ARG CLI -FROM mikefarah/yq:2.1.2 as yq +FROM mikefarah/yq:2.2.0 as yq FROM gofunky/envtpl:0.2.1 as envtpl FROM circleci/circleci-cli:${CLI}-alpine as cli @@ -17,6 +17,8 @@ RUN chmod +x /usr/local/bin/envtpl COPY --from=cli /usr/local/bin/circleci /usr/local/bin/circleci RUN chmod +x /usr/local/bin/circleci +RUN apk add --no-cache docker + ARG VERSION ARG BUILD_DATE ARG VCS_REF diff --git a/src/+parameters.yml b/src/+parameters.yml new file mode 100644 index 00000000..a1ca7755 --- /dev/null +++ b/src/+parameters.yml @@ -0,0 +1,90 @@ +alpine_version: + description: the Alpine image version + type: string + +publish-token-variable: + description: > + the env var containing your publish token. Pass this as a literal string such + as `$ORB_PUBLISHING_TOKEN`. DO NOT paste the actual token into your + configuration. If omitted it's assumed the CLI has already been setup + with a valid token. + By default, an environment variable `$ORB_PUBLISHING_TOKEN` is expected. + Make sure to pass a context to this job that contains the variable. + type: string + default: "${ORB_PUBLISHING_TOKEN}" + +destination-file: + description: Path including filename of where the packed orb will be written. + type: string + default: ./.orbspace/orb.yml + +orb-path: + description: the path to the orb file + type: string + +namespace: + description: > + The namespace of your target orb. + Environment variables from envorbs are accepted. + By default, the git organization is assumed. + type: string + default: "" + +orb-name: + description: > + The name of your target orb. + Environment variables from envorbs are accepted. + By default, the git repository name is assumed. + type: string + default: "" + +source-dir: + description: > + Path to the root of the orb source directory to be packed. + By default, `src/` is assumed. + type: string + default: src/ + +store-artifact: + description: If enabled, the destination-file will be stored as artifact. + type: boolean + default: true + +patch-environment-variables: + description: > + To replace all template variables with the respective environment variables. + Variables have to be defined in the format `{{"{{"}}.VAR{{"}}"}}`. + type: boolean + default: true + +patch-parameters: + description: > + To patch all crosscutting parameters defined in the src/+parameters.yml file. + Parameters that are shared among multiple commands, orbs or executors can thereby be shared. + Define the parameters in the root layer of the +parameters.yml file. + In every yaml file inside the commands, jobs, or executors folder, the parameters are propagated if they + are referenced there via << parameters.xyz >>. + type: boolean + default: true + +success-verification: + description: define additional post-test-execution checks to verify that the test succeeded + type: steps + default: [] +success-config: + description: the path to the succeeding test case config that refers to the orb jobs to be tested + type: string + default: "" +fail-verification: + description: define additional post-test-execution checks to verify that the test failed + type: steps + default: [] +fail-config: + description: the path to the failing test case config that refers to the orb jobs to be tested + type: string + default: "" + +test-steps: + description: if you need more than 2 test cases, you can define your own test sequence here using the test command + type: steps + default: [] diff --git a/src/@orb.yml b/src/@orb.yml index 3637b629..b67ac2ab 100644 --- a/src/@orb.yml +++ b/src/@orb.yml @@ -1,386 +1,13 @@ version: 2.1 -alpine_params: &alpine_params - alpine_version: - description: > - Alpine version - type: string - default: "" - -alpine_args: &alpine_args - alpine_version: << parameters.alpine_version >> - -executors: - default: - parameters: - <<: *alpine_params - docker: - - image: gofunky/orbtools:alpine<< parameters.alpine_version >> +description: > + This version of the orb tools provides extended functions to the upstream version. + First, you can use environment variables from the envorb, e.g., for version tagging. + Second, you can use placeholders in your yaml files that are patched by environment variables. + Third, you can reduce the overhead of your orbs' parameters by using cross-cutting paramters. + Simply define your parameters in your +parameters.yml file and they are propagated to the files where they are + referenced during the build. orbs: envorb: gofunky/envorb@0.3.9 - -commands: - pack: - description: > - *Experimental* - Uses the CLI to pack an orb file structure - into a single orb yml. - parameters: - source: - description: "Path to the root folder of an unpacked orb." - type: string - destination: - description: "Path including the filename to output the packed orb." - type: string - steps: - - run: - name: "Ensure destination path" - command: | - mkdir -pv $(dirname << parameters.destination >>) - - run: - name: "Pack << parameters.source>> to << parameters.destination >>" - command: | - circleci config pack << parameters.source >> > << parameters.destination >> - - validate: - description: > - Users the CLI to validate a given orb yml - parameters: - orb-path: - description: "Path to the orb file to be validated." - type: string - steps: - - run: - name: "Validate whether this is a well-formed orb." - command: circleci orb validate << parameters.orb-path >> - - increment: - description: > - Uses the CLI to increment the version of an orb in the registry. - If the orb does not have a version yet it starts at 0.0.0 - parameters: - orb-path: - description: "Path to an orb file." - type: string - orb-ref: - description: "A versionless orb-ref in the form /" - type: string - segment: - description: "The semver segment to increment 'major' or 'minor' or 'patch'" - type: enum - enum: ["major", "minor", "patch"] - token-variable: - description: > - The env var containing your token. Pass this as a literal string such - as `$ORB_PUBLISHING_TOKEN`. Do not paste the actual token into your - configuration. If omitted it's assumed the CLI has already been setup - with a valid token. - type: string - default: "" - steps: - - run: - name: > - Increment << parameters.segment >> segment of orb at << parameters.orb-path >> - NOTE: this currently assumes you are publishing to the registry at circleci.com - command: > - circleci orb publish increment - << parameters.orb-path >> - << parameters.orb-ref >> - << parameters.segment >> - <<# parameters.token-variable >>--token << parameters.token-variable >> <> - publish: - description: > - Uses the CLI to publish an orb to the registry. - parameters: - orb-path: - description: "Path to an orb file." - type: string - orb-ref: - description: > - A fully-qualified reference to an orb. This takes the form /@ - NOTE: To publish a dev version prefix the version with 'dev:' like this: /@dev: