|
1 | 1 | version: 2.1 |
2 | | - |
| 2 | +setup: true |
3 | 3 | orbs: |
4 | | - orb-hashicorp-vault-cli: smaeda-ks/orb-hashicorp-vault-cli@<<pipeline.parameters.dev-orb-version>> |
5 | | - orb-tools: circleci/[email protected] |
6 | | - |
7 | | - |
8 | | -# Pipeline Parameters |
9 | | -## These parameters are used internally by orb-tools. Skip to the Jobs section. |
10 | | -parameters: |
11 | | - run-integration-tests: |
12 | | - description: An internal flag to prevent integration test from running before a development version has been created. |
13 | | - type: boolean |
14 | | - default: false |
15 | | - dev-orb-version: |
16 | | - description: > |
17 | | - The development version of the orb to test. |
18 | | - This value is automatically adjusted by the "trigger-integration-tests-workflow" job to correspond with the specific version created by the commit and should not be edited. |
19 | | - A "dev:alpha" version must exist for the initial pipeline run. |
20 | | - type: string |
21 | | - default: "dev:alpha" |
22 | | - |
23 | | -jobs: |
24 | | - integration-test-1: |
25 | | - machine: true |
26 | | - steps: |
27 | | - - checkout |
28 | | - - run: |
29 | | - name: Start local Vault dev server (Docker) |
30 | | - command: | |
31 | | - docker run -d --cap-add=IPC_LOCK -p 8200:8200 -e 'VAULT_DEV_ROOT_TOKEN_ID=myroot' vault |
32 | | - - orb-hashicorp-vault-cli/install |
33 | | - - run: vault --version |
34 | | - - run: |
35 | | - name: Set up Vault dev server |
36 | | - command: | |
37 | | - vault auth enable jwt |
| 4 | + orb-tools: circleci/[email protected] |
| 5 | + # shellcheck: circleci/[email protected] |
38 | 6 |
|
39 | | - vault write auth/jwt/config \ |
40 | | - bound_issuer="https://oidc.circleci.com/org/${CIRCLECI_ORG_ID}" \ |
41 | | - oidc_discovery_url="https://oidc.circleci.com/org/${CIRCLECI_ORG_ID}" |
| 7 | +filters: &filters |
| 8 | + tags: |
| 9 | + only: /.*/ |
42 | 10 |
|
43 | | - vault kv put secret/circleci/orb test=foo |
44 | | -
|
45 | | - vault policy write circleci-orb-dev -\<<EOF |
46 | | - path "secret/data/circleci/orb" { |
47 | | - capabilities = ["read"] |
48 | | - } |
49 | | - EOF |
50 | | -
|
51 | | - vault write auth/jwt/role/circleci-orb-dev -\<<EOF |
52 | | - { |
53 | | - "role_type": "jwt", |
54 | | - "user_claim": "sub", |
55 | | - "bound_claims": { |
56 | | - "aud": "${CIRCLECI_ORG_ID}" |
57 | | - }, |
58 | | - "policies": ["circleci-orb-dev"], |
59 | | - "ttl": "1h" |
60 | | - } |
61 | | - EOF |
62 | | - exit 0 |
63 | | - environment: |
64 | | - VAULT_TOKEN: myroot |
65 | | - VAULT_ADDR: "http://localhost:8200" |
66 | | - - orb-hashicorp-vault-cli/auth-oidc: |
67 | | - vault-address: "http://localhost:8200" |
68 | | - vault-role: "circleci-orb-dev" |
69 | | - - run: vault kv get -field=test secret/circleci/orb |
70 | 11 | workflows: |
71 | | - # Prior to producing a development orb (which requires credentials) basic validation, linting, and even unit testing can be performed. |
72 | | - # This workflow will run on every commit |
73 | | - test-pack: |
74 | | - unless: << pipeline.parameters.run-integration-tests >> |
| 12 | + lint-pack: |
75 | 13 | jobs: |
76 | | - - orb-tools/lint # Lint Yaml files |
77 | | - - orb-tools/pack # Pack orb source |
78 | | - # optional: Run BATS tests against your scripts |
79 | | - # - bats/run: |
80 | | - # path: ./src/tests |
81 | | - # Publish development version(s) of the orb. |
82 | | - - orb-tools/publish-dev: |
| 14 | + - orb-tools/lint: |
| 15 | + filters: *filters |
| 16 | + - orb-tools/pack: |
| 17 | + filters: *filters |
| 18 | + - orb-tools/review: |
| 19 | + filters: *filters |
| 20 | + exclude: RC006,RC009 |
| 21 | + # - shellcheck/check: |
| 22 | + # exclude: SC2148,SC2038,SC2086,SC2002,SC2016 |
| 23 | + # filters: *filters |
| 24 | + - orb-tools/publish: |
83 | 25 | orb-name: smaeda-ks/orb-hashicorp-vault-cli |
84 | | - context: orb-publishing # A restricted context containing your private publishing credentials. Will only execute if approved by an authorized user. |
85 | | - requires: |
86 | | - - orb-tools/lint |
87 | | - - orb-tools/pack |
88 | | - # - bats/run |
89 | | - # Trigger an integration workflow to test the |
90 | | - # dev:${CIRCLE_SHA1:0:7} version of your orb |
91 | | - - orb-tools/trigger-integration-tests-workflow: |
92 | | - name: trigger-integration-dev |
93 | | - context: orb-publishing |
| 26 | + vcs-type: << pipeline.project.type >> |
94 | 27 | requires: |
95 | | - - orb-tools/publish-dev |
96 | | - |
97 | | - # This `integration-test_deploy` workflow will only run |
98 | | - # when the run-integration-tests pipeline parameter is set to true. |
99 | | - # It is meant to be triggered by the "trigger-integration-tests-workflow" |
100 | | - # job, and run tests on <your orb>@dev:${CIRCLE_SHA1:0:7}. |
101 | | - integration-test_deploy: |
102 | | - when: << pipeline.parameters.run-integration-tests >> |
103 | | - jobs: |
104 | | - # Run any integration tests defined within the `jobs` key. |
105 | | - - integration-test-1: |
| 28 | + [orb-tools/lint, orb-tools/review, orb-tools/pack] |
| 29 | + # Use a context to hold your publishing token. |
106 | 30 | context: orb-publishing |
107 | | - # Publish a semver version of the orb. relies on |
108 | | - # the commit subject containing the text "[semver:patch|minor|major|skip]" |
109 | | - # as that will determine whether a patch, minor or major |
110 | | - # version will be published or if publishing should |
111 | | - # be skipped. |
112 | | - # e.g. [semver:patch] will cause a patch version to be published. |
113 | | - - orb-tools/dev-promote-prod-from-commit-subject: |
114 | | - orb-name: smaeda-ks/orb-hashicorp-vault-cli |
115 | | - context: orb-publishing |
116 | | - add-pr-comment: false |
117 | | - fail-if-semver-not-indicated: true |
118 | | - publish-version-tag: false |
119 | | - requires: |
120 | | - - integration-test-1 |
121 | | - filters: |
122 | | - branches: |
123 | | - only: |
124 | | - - master |
125 | | - - main |
| 31 | + filters: *filters |
| 32 | + # Triggers the next workflow in the Orb Development Kit. |
| 33 | + - orb-tools/continue: |
| 34 | + config-path: .circleci/test-deploy.yml |
| 35 | + pipeline-number: << pipeline.number >> |
| 36 | + vcs-type: << pipeline.project.type >> |
| 37 | + requires: [orb-tools/publish] |
| 38 | + filters: *filters |
0 commit comments