Skip to content

Commit

Permalink
Redo CI pipeline (#47)
Browse files Browse the repository at this point in the history
* add config file redo

* add new workflow

* PR review
  • Loading branch information
Gita Vahdatinia authored Nov 22, 2022
1 parent 7d7fe9e commit bf25050
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 129 deletions.
118 changes: 26 additions & 92 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ default_build_environment: &default_build_environment
username: codainternaltools
password: $DOCKERHUB_PASSWORD

setup: true

orbs:
utils: coda/utils@<<pipeline.parameters.dev-orb-version>>
orb-tools: circleci/orb-tools@10.0.3
orb-tools: circleci/orb-tools@11.5.0
bats: circleci/bats@1.0
shellcheck: circleci/shellcheck@2.0

Expand All @@ -31,115 +32,48 @@ parameters:
type: string
default: ''

commands:
bootstrap_pipeline_circleci_user:
steps:
- run:
name: Initialize CIRCLE_USERNAME from pipeline
command: |
echo "export CIRCLE_USERNAME=<< pipeline.parameters.circleci-user >>" >> $BASH_ENV
source $BASH_ENV
jobs:
integration-test-notify:
<<: *default_build_environment
steps:
- checkout
- utils/notify:
on_success: true

integration-test-slack:
<<: *default_build_environment
steps:
- checkout
- bootstrap_pipeline_circleci_user
- utils/slack-notify-waiting-for-approval:
slack_bot_token: ${SLACK_ACCESS_TOKEN}

integration-test-cancel-older-jobs:
<<: *default_build_environment
steps:
- checkout
- utils/cancel-older-awaiting-approvals

workflows:
test-pack:
unless: << pipeline.parameters.run-integration-tests >>
lint-pack:
jobs:
- orb-tools/pack:
context:
- dockerhub
- orb-tools/pack
# https://www.shellcheck.net/wiki/SC2002
- shellcheck/check:
context:
- dockerhub
dir: ./src/scripts
- bats/run:
context:
- dockerhub
- slack
path: ./src/tests
- hold-for-dev-publish:
context:
exclude: 'SC2002'
- orb-tools/publish:
context:
- dockerhub
type: approval
- orb-publishing
orb-name: coda/utils
requires:
- orb-tools/pack
- bats/run
- shellcheck/check
# Publish development version of the orb.
- orb-tools/publish-dev:
publish-token-variable: ORB_PUBLISHING_TOKEN
context:
- dockerhub
- orb-publishing
orb-name: coda/utils
requires: [hold-for-dev-publish]
# dev:${CIRCLE_SHA1:0:7} version of your orb
- orb-tools/trigger-integration-tests-workflow:
name: trigger-integration-dev
token-variable: ORB_PUBLISHING_TOKEN
vcs-type: github
- orb-tools/continue:
context:
- dockerhub
- orb-publishing
- util
- ops-genie
pipeline-number: << pipeline.number >>
requires:
- orb-tools/publish-dev
pipeline-param-map: '{\"run-integration-tests\": true, \"dev-orb-version\": \"dev:${CIRCLE_SHA1:0:7}\", \"circleci-user\": \"${CIRCLE_USERNAME}\"}'
- orb-tools/publish
vcs-type: << pipeline.project.type >>
filters:
branches:
ignore: main

integration-test_deploy:
when: << pipeline.parameters.run-integration-tests >>
publish:
jobs:
- integration-test-notify:
context:
- dockerhub
- orb-publishing
- util
- ops-genie
- integration-test-slack:
context:
- dockerhub
- orb-publishing
- util
- slack
- utils/cancel-older-awaiting-approvals:
context:
- orb-tools/publish:
context:
- dockerhub
- orb-publishing
- util
- orb-tools/dev-promote-prod-from-commit-subject:
orb-name: coda/utils
context:
- dockerhub
- orb-publishing
- util
publish-token-variable: ORB_PUBLISHING_TOKEN
add-pr-comment: false
fail-if-semver-not-indicated: true
publish-version-tag: false
requires:
- integration-test-notify
- integration-test-slack
- utils/cancel-older-awaiting-approvals
filters:
branches:
only:
- main
orb-name: coda/utils
pub-type: production
vcs-type: << pipeline.project.type >>
72 changes: 72 additions & 0 deletions .circleci/test-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
version: '2.1'
orbs:
utils: coda/utils@dev:<<pipeline.git.revision>>
orb-tools: circleci/orb-tools@11.1
bats: circleci/bats@1.0

default_build_environment: &default_build_environment
docker:
- image: cimg/base:stable
auth:
username: codainternaltools
password: $DOCKERHUB_PASSWORD

parameters:
circleci-user:
description: The user who published orb changes
type: string
default: ''

commands:
bootstrap_pipeline_circleci_user:
steps:
- run:
name: Initialize CIRCLE_USERNAME from pipeline
command: |
echo "export CIRCLE_USERNAME=<< pipeline.parameters.circleci-user >>" >> $BASH_ENV
source $BASH_ENV
jobs:
integration-test-notify:
<<: *default_build_environment
steps:
- checkout
- utils/notify:
on_success: true

integration-test-slack:
<<: *default_build_environment
steps:
- checkout
- bootstrap_pipeline_circleci_user
- utils/slack-notify-waiting-for-approval:
slack_bot_token: ${SLACK_ACCESS_TOKEN}

integration-test-cancel-older-jobs:
<<: *default_build_environment
steps:
- checkout
- utils/cancel-older-awaiting-approvals

workflows:
test-deploy:
jobs:
- integration-test-notify:
context:
- dockerhub
- orb-publishing
- util
- ops-genie
- integration-test-slack:
context:
- dockerhub
- orb-publishing
- util
- slack
- utils/cancel-older-awaiting-approvals:
context:
- dockerhub
- orb-publishing
- util
- ops-genie

15 changes: 0 additions & 15 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
<!---
Must include [semver:<type>] in PR title in order to publish new version
-->

**SEMVER Update Type:**
- [ ] Major
- [ ] Minor
- [ ] Patch

## Description:

<!---
Describe your changes in detail, preferably in an imperative mood,
i.e., "add `commandA` to `jobB`"
-->

## Motivation:

<!---
Share any open issues this PR references or otherwise describe the motivation to submit this pull request.
-->
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,7 @@
### How to Publish
* Create and push a branch with your new features.
* When ready to publish a new production version, create a Pull Request from fore _feature branch_ to `main`.
* The title of the pull request must contain a special semver tag: `[semver:<segement>]` where `<segment>` is replaced by one of the following values.

| Increment | Description|
| ----------| -----------|
| major | Issue a 1.0.0 incremented release|
| minor | Issue a x.1.0 incremented release|
| patch | Issue a x.x.1 incremented release|
| skip | Do not issue a release|

Example: `[semver:major]`

* Squash and merge. Ensure the semver tag is preserved and entered as a part of the commit message.
* On merge, after manual approval, the orb will automatically be published to the Orb Registry.
### How to Publish Dev Version

Push your branch and CI will trigger dev published version of orb with the commit hash as the version.
Expand Down
12 changes: 4 additions & 8 deletions src/@orb.yml
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
version: 2.1

description: >
Utility orb for Coda
Allows for:
- Push alerts to opsgenie
- Push Slack notifications
- Cancel older CI alerts waiting for approval
Utility orb for Coda Allows for: - Push alerts to opsgenie - Push Slack
notifications - Cancel older CI alerts waiting for approval
display:
source_url: "https://github.com/coda/circleci-utils"
source_url: 'https://github.com/coda/circleci-utils'

2 changes: 1 addition & 1 deletion src/commands/bootstrap-aws-context-creds.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
description: |
Each CI context can inject an AWS credential to the environment.
Unpack them all and combine into a single credentials file inside ~/.aws/credentials
Unpack and combine into a single file inside ~/.aws/credentials
steps:
- run:
name: Iterate through all context variables and unpack them
Expand Down
3 changes: 2 additions & 1 deletion src/executors/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ description: >
resource_class: small
docker:
- image: circleci/buildpack-deps:buster-curl
- image: circleci/buildpack-deps:buster-curl

0 comments on commit bf25050

Please sign in to comment.