Skip to content

Commit 2170691

Browse files
authored
Update orb-tools version (#4)
1 parent 7e5a61f commit 2170691

File tree

2 files changed

+108
-116
lines changed

2 files changed

+108
-116
lines changed

.circleci/config.yml

Lines changed: 29 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,38 @@
11
version: 2.1
2-
2+
setup: true
33
orbs:
4-
orb-hashicorp-vault-cli: smaeda-ks/orb-hashicorp-vault-cli@<<pipeline.parameters.dev-orb-version>>
5-
orb-tools: circleci/[email protected]
6-
bats: circleci/[email protected]
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]
386

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: /.*/
4210

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
7011
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:
7513
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:
8325
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 >>
9427
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.
10630
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

.circleci/test-deploy.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
version: 2.1
2+
orbs:
3+
orb-hashicorp-vault-cli: smaeda-ks/orb-hashicorp-vault-cli@dev:<<pipeline.git.revision>>
4+
orb-tools: circleci/[email protected]
5+
6+
filters: &filters
7+
tags:
8+
only: /.*/
9+
10+
jobs:
11+
integration-test:
12+
machine: true
13+
steps:
14+
- checkout
15+
- run:
16+
name: Start local Vault dev server (Docker)
17+
command: |
18+
docker run -d --cap-add=IPC_LOCK -p 8200:8200 -e 'VAULT_DEV_ROOT_TOKEN_ID=myroot' vault
19+
- orb-hashicorp-vault-cli/install
20+
- run: vault --version
21+
- run:
22+
name: Set up Vault dev server
23+
command: |
24+
vault auth enable jwt
25+
26+
vault write auth/jwt/config \
27+
bound_issuer="https://oidc.circleci.com/org/${CIRCLECI_ORG_ID}" \
28+
oidc_discovery_url="https://oidc.circleci.com/org/${CIRCLECI_ORG_ID}"
29+
30+
vault kv put secret/circleci/orb test=foo
31+
32+
vault policy write circleci-orb-dev -\<<EOF
33+
path "secret/data/circleci/orb" {
34+
capabilities = ["read"]
35+
}
36+
EOF
37+
38+
vault write auth/jwt/role/circleci-orb-dev -\<<EOF
39+
{
40+
"role_type": "jwt",
41+
"user_claim": "sub",
42+
"bound_claims": {
43+
"aud": "${CIRCLECI_ORG_ID}"
44+
},
45+
"policies": ["circleci-orb-dev"],
46+
"ttl": "1h"
47+
}
48+
EOF
49+
exit 0
50+
environment:
51+
VAULT_TOKEN: myroot
52+
VAULT_ADDR: "http://localhost:8200"
53+
- orb-hashicorp-vault-cli/auth-oidc:
54+
vault-address: "http://localhost:8200"
55+
vault-role: "circleci-orb-dev"
56+
- run: vault kv get -field=test secret/circleci/orb
57+
workflows:
58+
test-deploy:
59+
jobs:
60+
# Make sure to include "filters: *filters" in every test job you want to run as part of your deployment.
61+
- integration-test:
62+
filters: *filters
63+
context: orb-publishing
64+
- orb-tools/pack:
65+
filters: *filters
66+
- orb-tools/publish:
67+
orb-name: smaeda-ks/orb-hashicorp-vault-cli
68+
vcs-type: <<pipeline.project.type>>
69+
pub-type: production
70+
enable-pr-comment: false
71+
requires:
72+
- orb-tools/pack
73+
- integration-test
74+
context: orb-publishing
75+
filters:
76+
branches:
77+
ignore: /.*/
78+
tags:
79+
only: /^v[0-9]+\.[0-9]+\.[0-9]+$/

0 commit comments

Comments
 (0)