Skip to content

Commit

Permalink
Align Staging and QA deployments (#529)
Browse files Browse the repository at this point in the history
* Health endpoint as var

* extra quote

* flow

* health endpoint

* wait for approval always

* Missing cloudsmith context

* Dont run tests on tags

* wrong tag

* Remove build and lint

* approval comes after tests

* deployment comes first

* fix tag

* health missing for staging

* e2e ID issue

* linter

* Change repo

* ctx

* Target staging

* Comments

* Back to main
  • Loading branch information
6l20 authored Mar 2, 2022
1 parent b9712d2 commit bb30c57
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 23 deletions.
62 changes: 40 additions & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ commands:
- run:
name: Set Quorum Key Manager Namespace
command: echo 'export QKM_NAMESPACE=<<parameters.environment_values>>-qkm' >> $BASH_ENV
- run:
name: Set Quorum Key Manager Health Endpoint
command: echo 'export QKM_HEALTH_ENDPOINT=health-<<parameters.environment_values>>-qkm.ops.consensys.net' >> $BASH_ENV

- unless:
condition: <<parameters.qkm_namespace>>
Expand Down Expand Up @@ -266,6 +269,10 @@ jobs:
port-frowarding:
default: $PORT_FORWARDING
type: string
health_url:
default: "health-qa-qkm.ops.consensys.net"
type: string

steps:
- run:
name: Uninstall Go
Expand All @@ -291,7 +298,7 @@ jobs:
seconds-between-retries: 3
timeout: 30
description: "Wait for deployment readiness"
sh-command: nc -z health-qa-qkm.ops.consensys.net 443
sh-command: nc -z << parameters.health_url >> 443
- run:
name: e2e tests
command: |
Expand Down Expand Up @@ -439,8 +446,10 @@ jobs:
- run:
name: Deploy staging environment
command: >-
QKM_TAG=${CIRCLE_TAG}
QKM_REPOSITORY=consensys/quorum-key-manager
QKM_TAG=${CIRCLE_SHA1:0:7}
QKM_REPOSITORY=${CLOUDSMITH_DEV_REPO}/quorum-key-manager
REGISTRY_USERNAME=${CLOUDSMITH_USER_RW}
REGISTRY_PASSWORD=${CLOUDSMITH_PASS_RW}
make deploy-remote-env
# --------------------------
Expand All @@ -458,42 +467,30 @@ workflows:
# Will run appropriate linting locally for each `/^v.*/` git tag and each commit
- lint:
filters:
tags:
only: /^v.*/
branches:
only: /.*/
# Will build locally for each `/^v.*/` git tag and each commit
- gobuild:
filters:
tags:
only: /^v.*/
branches:
only: /.*/
# Will run the unit tests locally for each `/^v.*/` git tag and each commit
- test:
filters:
tags:
only: /^v.*/
branches:
only: /.*/
# Will run the unit tests in race mode locally for each `/^v.*/` git tag and each commit
- race:
filters:
tags:
only: /^v.*/
branches:
only: /.*/
# Will run the acceptance tests locally for each `/^v.*/` git tag and each commit
- acceptance:
filters:
tags:
only: /^v.*/
branches:
only: /.*/
- sonarscan:
filters:
tags:
only: /^v.*/
branches:
only: /.*/
requires:
Expand Down Expand Up @@ -530,6 +527,7 @@ workflows:
# Will run the end 2 end tests locally for each `/^v.*/` git tag and every main commit
# requires successful Build, Unit and acceptance tests
- e2e:
name: e2e-qa
test_data: $QA_TEST_DATA
client_key: $QKM_CLIENT_KEY
client_auth_cert: $QKM_CLIENT_AUTH_CERT
Expand All @@ -542,9 +540,9 @@ workflows:
only: main
requires:
- deploy-qa
# Will build and push a dev image for each main commit
# Resulting image is tagged with develop
# Images are compliant with linux/amd64 architecture
# Will build and push a dev image for each main commit
# Resulting image is tagged with develop
# Images are compliant with linux/amd64 architecture
- build-docker-image: # Push Dev image
name: push-qkm-dev-image-develop
context:
Expand All @@ -559,18 +557,18 @@ workflows:
branches:
only: main
requires:
- e2e
- e2e-qa

# Is a pipeline blocker that requires a human decision and action
- wait-for-approval:
type: approval
requires:
- e2e
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
requires:
- e2e-staging
# Will build and push a prod (NON debug) image for each `/^v.*/` git tag
# Resulting image is tagged with both ${CIRCLE_TAG} and latest
# Images are compliant with both linux/amd64 and linux/arm64 architectures
Expand All @@ -580,6 +578,7 @@ workflows:
context:
- dockerhub-quorumengineering-rw
- dockerhub-opsquorum-dct
- cloudsmith-tanuki-rw
matrix:
parameters:
docker-image-tag: ["quorum-key-manager:${CIRCLE_TAG}", "quorum-key-manager:latest"]
Expand All @@ -600,6 +599,7 @@ workflows:
context:
- dockerhub-quorumengineering-rw
- dockerhub-opsquorum-dct
- cloudsmith-tanuki-rw
docker-image-platforms: linux/amd64
docker-distroless-version: debug-nonroot
docker-image-tag: "quorum-key-manager:${CIRCLE_TAG}-debug"
Expand All @@ -614,13 +614,31 @@ workflows:
# Will deploy the staging env
# requires a successful release image (latest tag) pushed
- deploy-staging:
context:
- cloudsmith-tanuki-rw
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/

# Will run the end 2 end tests locally for each `/^v.*/` git tag and every main commit
# requires successful Build, Unit and acceptance tests
- e2e:
name: e2e-staging
test_data: $STAGING_TEST_DATA
client_key: $QKM_CLIENT_KEY
client_auth_cert: $QKM_CLIENT_AUTH_CERT
client_no_auth_key: $QKM_CLIENT_NO_AUTH_KEY
client_no_auth_cert: $QKM_CLIENT_NO_AUTH_CERT
health_url: "health-staging-qkm.ops.consensys.net"
filters:
tags:
only: /^v.*/
branches:
only: main
requires:
- release-tag-quorum-key-manager:latest
- deploy-staging

# --------------------------
# End of workflows definition definitions
Expand Down
5 changes: 4 additions & 1 deletion src/stores/api/types/testutils/faker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package testutils
import (
"encoding/base64"

cmn "github.com/consensys/quorum-key-manager/pkg/common"

ethtypes "github.com/ethereum/go-ethereum/core/types"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -45,8 +47,9 @@ func FakeSignBase64PayloadRequest() *types.SignBase64PayloadRequest {
}

func FakeCreateEthAccountRequest() *types.CreateEthAccountRequest {
randID := cmn.RandString(10)
return &types.CreateEthAccountRequest{
KeyID: "my-key-account",
KeyID: "my-key-account-" + randID,
Tags: testutils.FakeTags(),
}
}
Expand Down

0 comments on commit bb30c57

Please sign in to comment.