Skip to content

Commit 24ae873

Browse files
authored
feat!: migrate to orb tools 11 | 2.0 release (#42)
1 parent 7e3870d commit 24ae873

21 files changed

+253
-228
lines changed

.circleci/config.yml

Lines changed: 25 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,35 @@
11
version: 2.1
2-
3-
# add your orb below, to be used in integration tests (note: a @dev:alpha
4-
# release must exist.);
2+
setup: true
53
orbs:
6-
heroku: circleci/heroku@<<pipeline.parameters.dev-orb-version>>
7-
orb-tools: circleci/orb-tools@10
8-
9-
# Pipeline parameters
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"
4+
orb-tools: circleci/[email protected]
5+
shellcheck: circleci/[email protected]
226

23-
jobs:
24-
# This job is an example of an integration testing job.
25-
# This job should execute a command from your orb and verify
26-
# the output is as expected, otherwise the job should fail.
27-
#
28-
# Rename this job and add more as needed.
29-
#
30-
integration-test-1:
31-
executor: heroku/default
32-
steps:
33-
- checkout
34-
- heroku/install
35-
- run:
36-
name: Check if Heroku is installed
37-
command: |
38-
if [[ $(command -v heroku) == "" ]]; then
39-
echo " Heroku is not installed! "; exit 1;
40-
else
41-
echo Heroku successfully installed.
42-
fi
43-
integration-test-review:
44-
executor: heroku/default
45-
steps:
46-
- run:
47-
name: Setup sample project
48-
command: |
49-
git clone --depth 1 https://github.com/CircleCI-Public/sample-python-cfd.git --branch main ~/project
50-
git branch $CIRCLE_BRANCH
51-
- run:
52-
name: Bundle sample project
53-
working_directory: ~/
54-
command: tar -czvf sample-python-cfd.tar.gz ~/project
55-
- store_artifacts:
56-
path: ~/sample-python-cfd.tar.gz
57-
- heroku/create-review:
58-
artifact-pattern: "*.tar.gz"
59-
pipeline: 389303dc-8a12-4f25-b943-8f7c6dbbdcaa
60-
circleci-api-key: CIRCLE_TOKEN
61-
integration-test-deploy:
62-
executor: heroku/default
63-
steps:
64-
- run:
65-
name: Setup sample project
66-
command: |
67-
git clone --depth 1 https://github.com/CircleCI-Public/sample-python-cfd.git --branch main ~/project
68-
git branch $CIRCLE_BRANCH
69-
- heroku/install
70-
- heroku/check-authentication
71-
- heroku/deploy-via-git:
72-
force: true
73-
app-name: sample-python-cfd
7+
filters: &filters
8+
tags:
9+
only: /.*/
7410

7511
workflows:
76-
# This `lint-pack_validate_publish-dev` workflow will run on any commit.
77-
lint_pack-validate_publish-dev:
78-
unless: << pipeline.parameters.run-integration-tests >>
12+
lint-pack:
7913
jobs:
80-
- orb-tools/lint
81-
# pack your orb YAML files to a single orb.yml
82-
# validate the orb.yml file to ensure it is well-formed
14+
- orb-tools/lint:
15+
filters: *filters
8316
- orb-tools/pack:
84-
requires:
85-
- orb-tools/lint
86-
87-
# release dev version of orb, for testing & possible publishing.
88-
# orb will be published as dev:alpha and dev:${CIRCLE_SHA1:0:7}.
89-
# requires a CircleCI API token to be stored as CIRCLE_TOKEN (default)
90-
# https://circleci.com/docs/2.0/managing-api-tokens
91-
# store CIRCLE_TOKEN as a project env var or Contexts resource
92-
# if using Contexts, add your context below
93-
- orb-tools/publish-dev:
17+
filters: *filters
18+
- orb-tools/review:
19+
filters: *filters
20+
- shellcheck/check:
21+
filters: *filters
22+
- orb-tools/publish:
9423
orb-name: circleci/heroku
95-
context: orb-publisher
24+
vcs-type: << pipeline.project.type >>
9625
requires:
97-
- orb-tools/pack
98-
99-
# trigger an integration workflow to test the
100-
# dev:${CIRCLE_SHA1:0:7} version of your orb
101-
- orb-tools/trigger-integration-tests-workflow:
102-
name: trigger-integration-dev
26+
[orb-tools/lint, orb-tools/review, orb-tools/pack, shellcheck/check]
27+
# Use a context to hold your publishing token.
10328
context: orb-publisher
104-
requires:
105-
- orb-tools/publish-dev
106-
107-
# This `integration-tests_prod-release` workflow will only run
108-
# when the run-integration-tests pipeline parameter is set to true.
109-
# It is meant to be triggered by the "trigger-integration-tests-workflow"
110-
# job, and run tests on <your orb>@dev:${CIRCLE_SHA1:0:7}.
111-
integration-tests_prod-release:
112-
when: << pipeline.parameters.run-integration-tests >>
113-
jobs:
114-
# your integration test jobs go here: essentially, run all your orb's
115-
# jobs and commands to ensure they behave as expected. or, run other
116-
# integration tests of your choosing
117-
118-
# an example job
119-
- integration-test-1
120-
- integration-test-deploy:
121-
context: heroku-orb
122-
- integration-test-review:
123-
context:
124-
- heroku-orb
125-
- orb-publisher
126-
# publish a semver version of the orb. relies on
127-
# the commit subject containing the text "[semver:patch|minor|major|skip]"
128-
# as that will determine whether a patch, minor or major
129-
# version will be published or if publishing should
130-
# be skipped.
131-
# e.g. [semver:patch] will cause a patch version to be published.
132-
- orb-tools/dev-promote-prod-from-commit-subject:
133-
orb-name: circleci/heroku
134-
context: orb-publisher
135-
add-pr-comment: true
136-
bot-token-variable: GHI_TOKEN
137-
bot-user: orb-publisher
138-
fail-if-semver-not-indicated: true
139-
publish-version-tag: false
140-
requires:
141-
- integration-test-1
142-
- integration-test-deploy
143-
filters:
144-
branches:
145-
only: master
29+
filters: *filters
30+
# Triggers the next workflow in the Orb Development Kit.
31+
- orb-tools/continue:
32+
pipeline-number: << pipeline.number >>
33+
vcs-type: << pipeline.project.type >>
34+
requires: [orb-tools/publish]
35+
filters: *filters

.circleci/test-deploy.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
version: 2.1
2+
orbs:
3+
heroku: circleci/heroku@dev:<<pipeline.git.revision>>
4+
orb-tools: circleci/[email protected]
5+
filters: &filters
6+
tags:
7+
only: /.*/
8+
jobs:
9+
# This job is an example of an integration testing job.
10+
# This job should execute a command from your orb and verify
11+
# the output is as expected, otherwise the job should fail.
12+
#
13+
# Rename this job and add more as needed.
14+
#
15+
integration-test-1:
16+
executor: heroku/default
17+
steps:
18+
- checkout
19+
- heroku/install
20+
- run:
21+
name: Check if Heroku is installed
22+
command: |
23+
if [[ $(command -v heroku) == "" ]]; then
24+
echo " Heroku is not installed! "; exit 1;
25+
else
26+
echo Heroku successfully installed.
27+
fi
28+
integration-test-review:
29+
executor: heroku/default
30+
steps:
31+
- run:
32+
name: Setup sample project
33+
command: |
34+
git clone https://github.com/CircleCI-Public/sample-python-cfd.git --branch main ~/project
35+
git branch $CIRCLE_BRANCH
36+
- run:
37+
name: Bundle sample project
38+
working_directory: ~/
39+
command: tar -czvf sample-python-cfd.tar.gz ~/project
40+
- store_artifacts:
41+
path: ~/sample-python-cfd.tar.gz
42+
- heroku/create-review:
43+
artifact-pattern: "*.tar.gz"
44+
pipeline: 389303dc-8a12-4f25-b943-8f7c6dbbdcaa
45+
circleci-api-key: CIRCLE_TOKEN
46+
integration-test-deploy:
47+
executor: heroku/default
48+
steps:
49+
- run:
50+
name: Setup sample project
51+
command: |
52+
git clone https://github.com/CircleCI-Public/sample-python-cfd.git --branch main ~/project
53+
git branch $CIRCLE_BRANCH
54+
- heroku/install
55+
- heroku/check-authentication
56+
- heroku/deploy-via-git:
57+
force: true
58+
app-name: sample-python-cfd
59+
workflows:
60+
test-deploy:
61+
jobs:
62+
# Make sure to include "filters: *filters" in every test job you want to run as part of your deployment.
63+
- integration-test-1:
64+
filters: *filters
65+
- integration-test-review:
66+
filters: *filters
67+
context: orb-publisher
68+
- integration-test-deploy:
69+
filters: *filters
70+
- orb-tools/pack:
71+
filters: *filters
72+
- orb-tools/publish:
73+
orb-name: circleci/heroku
74+
vcs-type: << pipeline.project.type >>
75+
pub-type: production
76+
requires:
77+
- orb-tools/pack
78+
- integration-test-1
79+
- integration-test-review
80+
- integration-test-deploy
81+
context: orb-publisher
82+
filters:
83+
branches:
84+
ignore: /.*/
85+
tags:
86+
only: /^v[0-9]+\.[0-9]+\.[0-9]+$/

.yamllint

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extends: relaxed
2+
3+
rules:
4+
line-length:
5+
max: 200
6+
allow-non-breakable-inline-mappings: true
7+

src/commands/check-authentication.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,7 @@ parameters:
99

1010
steps:
1111
- run:
12+
environment:
13+
PARAM_WHOAMI: <<parameters.print-whoami>>
1214
name: Verify HEROKU_API_KEY is set
13-
command: |
14-
if [[ $HEROKU_API_KEY == "" ]]; then
15-
echo "No Heroku API key set, please set the HEROKU_API_KEY environment variable."
16-
echo "This can be found by running the `heroku auth:token` command locally."
17-
exit 1
18-
else
19-
echo "Heroku API key found."
20-
<<#parameters.print-whoami>>
21-
heroku auth:whoami
22-
<</parameters.print-whoami>>
23-
fi
15+
command: <<include(scripts/check-auth.sh)>>

src/commands/create-review.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ parameters:
88
description: RegEx or filename of artifact to deploy to Heroku.
99
pipeline:
1010
type: string
11-
description: Heroku pipeline to dpeloy with (UUID).
11+
description: Heroku pipeline to deploy with (UUID).
1212
heroku-api-key:
1313
type: env_var_name
14-
description: Environment variable containing the Heroku API key
14+
description: The name of the environment variable containing your Heroku API Key.
1515
default: HEROKU_API_KEY
1616
circleci-api-key:
1717
type: env_var_name
1818
description: Environment variable containing the Heroku API key
19-
default: CIRCLECI_API_KEY
19+
default: CIRCLE_TOKEN
2020
steps:
2121
- run:
2222
command: <<include(scripts/create-review.sh)>>
2323
name: Create new Heroku Review app
2424
environment:
25-
C_API_KEY: $<<parameters.circleci-api-key>>
26-
API_KEY: $<<parameters.heroku-api-key>>
27-
ARTIFACT_PATTERN: <<parameters.artifact-pattern>>
28-
HEROKU_PIPELINE: <<parameters.pipeline>>
25+
PARAM_CIRCLE_TOKEN: <<parameters.circleci-api-key>>
26+
PARAM_HEROKU_KEY: <<parameters.heroku-api-key>>
27+
PARAM_ARTIFACT_PATTERN: <<parameters.artifact-pattern>>
28+
PARAM_HEROKU_PIPELINE: <<parameters.pipeline>>

src/commands/deploy-via-git.yml

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
description: >
2-
Replace this text with a description for this command.
3-
# What will this command do?
4-
# Descriptions should be short, simple, and clear.
2+
Use Git to push the changes of the current tag or branch to Heroku for deployment.
53
parameters:
64
app-name:
75
description:
8-
"The name of your Heroku App.
9-
For backwards compatibility the literal value
10-
`$HEROKU_APP_NAME` is the default, so you can
11-
easily use this command by setting an environment
12-
variable called HEROKU_APP_NAME"
6+
The name of your Heroku app. May also refer to an environment variable.
137
type: string
148
default: $HEROKU_APP_NAME
159
maintenance-mode:
@@ -22,12 +16,12 @@ parameters:
2216
default: HEROKU_API_KEY
2317
branch:
2418
type: string
25-
description: Deploy the given branch. The default value is your current branch.
26-
default: "$CIRCLE_BRANCH"
19+
description: Deploy the given branch. The default value is your current branch. Accepts strings which may contain an environment variable.
20+
default: $CIRCLE_BRANCH
2721
tag:
2822
type: string
2923
description: Deploy the given tag. The default value is your current tag.
30-
default: "$CIRCLE_TAG"
24+
default: $CIRCLE_TAG
3125
force:
3226
type: boolean
3327
description: Whether or not to force the git push (i.e. `git push -f`). Defaults to false.
@@ -47,21 +41,15 @@ steps:
4741
- run:
4842
no_output_timeout: << parameters.no_output_timeout >>
4943
name: Deploy branch or tag to Heroku via git push
50-
command: |
51-
if << parameters.force >>;then
52-
force="-f"
53-
fi
54-
55-
heroku_url="https://heroku:$<< parameters.api-key >>@git.heroku.com/<< parameters.app-name >>.git"
56-
57-
if [ -n "<< parameters.branch >>" ]; then
58-
git push $force $heroku_url << parameters.branch >>:main
59-
elif [ -n "<< parameters.tag >>" ]; then
60-
git push $force $heroku_url << parameters.tag >>^{}:main
61-
else
62-
echo "No branch or tag found."
63-
exit 1
64-
fi
44+
environment:
45+
PARAM_APP_NAME: <<parameters.app-name>>
46+
PARAM_MAINTENANCE_MODE: <<parameters.maintenance-mode>>
47+
PARAM_HEROKU_API_KEY: <<parameters.api-key>>
48+
PARAM_DEPLOY_BRANCH: <<parameters.branch>>
49+
PARAM_DEPLOY_TAG: <<parameters.tag>>
50+
PARAM_FORCE_PUSH: <<parameters.force>>
51+
PARAM_NO_OUTPUT_TIMEOUT: <<parameters.no_output_timeout>>
52+
command: <<include(scripts/deploy-via-git.sh)>>
6553
- when:
6654
condition: << parameters.maintenance-mode >>
6755
steps:

src/commands/install.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,4 @@ description: >
33
steps:
44
- run:
55
name: Install Heroku CLI (If not installed)
6-
command: |
7-
if [[ $(command -v heroku) == "" ]]; then
8-
curl https://cli-assets.heroku.com/install.sh | sh
9-
else
10-
echo "Heroku is already installed. No operation was performed."
11-
fi
6+
command: <<include(scripts/install.sh)>>

0 commit comments

Comments
 (0)