Skip to content

Commit

Permalink
Merge branch 'main' into HOTT-4467
Browse files Browse the repository at this point in the history
  • Loading branch information
rasikasri committed Dec 12, 2023
2 parents 37537f9 + 76892df commit 6a93df7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 136 deletions.
146 changes: 12 additions & 134 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ filter-release: &filter-release
orbs:
aws-cli: circleci/aws-cli@2.0.3
terraform: circleci/terraform@3.2.1
cloudfoundry: circleci/cloudfoundry@1.0
cypress: cypress-io/cypress@1.27.0
node: circleci/node@5
ruby: circleci/ruby@2
slack: circleci/slack@4.3.0
queue: eddiewebb/queue@1.6.4
tariff: trade-tariff/trade-tariff-ci-orb@0

executors:
Expand All @@ -43,78 +41,6 @@ executors:
TF_INPUT: 0
TF_IN_AUTOMATION: 1

commands:
cf-deploy-docker:
parameters:
docker_tag:
type: string
space:
type: string
environment_key:
type: string
app_domain_prefix:
type: string

steps:
- checkout
- tariff/cf-install:
space: << parameters.space >>

- tariff/deploy-dark-app:
aws_access_key_id: "$AWS_ACCESS_KEY_ID"
aws_secret_access_key: "$AWS_SECRET_ACCESS_KEY"
cf_app: tariff-duty-calculator
docker_image: tariff-dutycalculator
docker_tag: << parameters.docker_tag >>
ecr_repo: "$ECR_REPO"
environment_key: << parameters.environment_key >>
space: << parameters.space >>

- run:
name: Map dark routes
command: |
cf map-route \
"$CF_APP-<< parameters.environment_key >>-dark" \
london.cloudapps.digital \
-n "$CF_APP-<< parameters.environment_key >>-dark"
cf map-route \
"$CF_APP-<< parameters.environment_key >>-dark" \
<< parameters.app_domain_prefix >>.trade-tariff.service.gov.uk \
--path "/duty-calculator"
cf add-network-policy \
"$CF_APP-<< parameters.environment_key >>-dark" \
"$CF_BACKEND_APP_XI-<< parameters.environment_key >>" \
--protocol tcp \
--port 8080
cf add-network-policy \
"$CF_APP-<< parameters.environment_key >>-dark" \
"$CF_BACKEND_APP_UK-<< parameters.environment_key >>" \
--protocol tcp \
--port 8080
- tariff/test-dark-app:
cf_app: tariff-duty-calculator
environment_key: << parameters.environment_key >>
healthcheck_path: "/healthcheckz"

- tariff/pivot-dark-app:
app_domain_prefix: << parameters.app_domain_prefix >>
cf_app: tariff-duty-calculator
environment_key: << parameters.environment_key >>
space: << parameters.space >>

- slack/notify:
channel: deployments
event: fail
template: basic_fail_1
- slack/notify:
channel: deployments
event: pass
template: basic_success_1

jobs:
write-docker-tag:
parameters:
Expand Down Expand Up @@ -183,6 +109,17 @@ jobs:
backend_config_file: backends/<< parameters.environment >>.tfbackend
var_file: config_<< parameters.environment >>.tfvars
lock-timeout: 5m
- run:
name: Add curl
command: apk --no-cache add curl jq
- slack/notify:
channel: deployments
event: fail
template: basic_fail_1
- slack/notify:
channel: deployments
event: pass
template: basic_success_1

ruby-checks:
docker:
Expand All @@ -203,38 +140,6 @@ jobs:
- store_artifacts:
path: brakeman_results.html

build:
environment:
IMAGE_NAME: tariff-dutycalculator
parameters:
dev-build:
default: false
type: boolean
docker:
- image: cimg/base:2021.04
steps:
- checkout
- setup_remote_docker:
version: 20.10.11
docker_layer_caching: false
- aws-cli/install
- run:
name: "Set docker tag"
command: |
echo "export DOCKER_TAG=<<# parameters.dev-build >>dev-<</ parameters.dev-build >>${CIRCLE_SHA1}" >> $BASH_ENV
- run:
name: "Build Docker image"
command: |
export GIT_NEW_REVISION=$(git rev-parse --short HEAD)
echo $GIT_NEW_REVISION >REVISION
docker build -t $IMAGE_NAME:$DOCKER_TAG .
- run:
name: "Push image to ECR"
command: |
aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin $ECR_REPO
docker tag $IMAGE_NAME:$DOCKER_TAG $ECR_REPO/$IMAGE_NAME:$DOCKER_TAG
docker push $ECR_REPO/$IMAGE_NAME:$DOCKER_TAG
test:
docker:
- image: cimg/ruby:3.2.2-node
Expand All @@ -257,24 +162,6 @@ jobs:
event: fail
template: basic_fail_1

deploy-production:
docker:
- image: cimg/ruby:3.2.2
environment:
SENTRY_ENVIRONMENT: "production"
steps:
- cf-deploy-docker:
docker_tag: $CIRCLE_TAG
space: "production"
environment_key: "production"
app_domain_prefix: "www"
- tariff/sentry-release:
environment: production
- tariff/notify-production-release:
app-name: Duty Calculator
slack-channel: trade_tariff
release-tag: $CIRCLE_TAG

workflows:
version: 2

Expand Down Expand Up @@ -330,7 +217,7 @@ workflows:

- tariff/smoketests:
name: smoketest-dev
context: trade-tariff
context: trade-tariff-testing
url: https://dev.trade-tariff.service.gov.uk
yarn_run: dev-tariff-duty-calculator-smoketests
requires:
Expand Down Expand Up @@ -379,11 +266,6 @@ workflows:

deploy-to-production:
jobs:
- build:
name: build-live
context: trade-tariff
<<: *filter-main

- write-docker-tag:
name: write-docker-tag-prod
environment: production
Expand All @@ -407,10 +289,6 @@ workflows:
- promote-to-production?
<<: *filter-main

- deploy-production:
context: trade-tariff
<<: *filter-release

- write-docker-tag:
name: write-docker-tag-prod-release
environment: production
Expand Down
8 changes: 7 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
---
files: (^terraform\/\S+)|(.pre\-commit\-config.yaml)|(.circleci\/\S+)
files: |
(?x)^(
^terraform\/\S+ |
.circleci\/\S+ |
.pre\-commit\-config.yaml
)
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.83.5
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
nodejs 20.10.0
nodejs 20.8.0
yarn 1.22.10

0 comments on commit 6a93df7

Please sign in to comment.