Skip to content

Commit 3f3e903

Browse files
authored
Merge branch 'master' into VED-789-Validation-Schema
2 parents 016238b + 10166f4 commit 3f3e903

File tree

90 files changed

+689
-729
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+689
-729
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Continuous Deployment Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
deploy-internal-dev-backend:
10+
uses: ./.github/workflows/deploy-backend.yml
11+
with:
12+
apigee_environment: internal-dev
13+
create_mns_subscription: true
14+
environment: dev
15+
sub_environment: internal-dev
16+
17+
run-internal-dev-sandbox-tests:
18+
# Technically the first step is not a pre-requisite - sandbox backend deployment is handled by APIM
19+
# Stipulating this condition simply makes it more likely the environment will be ready when tests are invoked
20+
needs: [deploy-internal-dev-backend]
21+
uses: ./.github/workflows/run-e2e-tests.yml
22+
with:
23+
apigee_environment: internal-dev-sandbox
24+
environment: dev
25+
sub_environment: internal-dev-sandbox
26+
secrets:
27+
APIGEE_PASSWORD: ${{ secrets.APIGEE_PASSWORD }}
28+
APIGEE_BASIC_AUTH_TOKEN: ${{ secrets.APIGEE_BASIC_AUTH_TOKEN }}
29+
APIGEE_OTP_KEY: ${{ secrets.APIGEE_OTP_KEY }}
30+
STATUS_API_KEY: ${{ secrets.STATUS_API_KEY }}
31+
32+
run-sandbox-tests:
33+
needs: [run-internal-dev-sandbox-tests]
34+
uses: ./.github/workflows/run-e2e-tests.yml
35+
with:
36+
apigee_environment: sandbox
37+
environment: dev
38+
sub_environment: sandbox
39+
secrets:
40+
APIGEE_PASSWORD: ${{ secrets.APIGEE_PASSWORD }}
41+
APIGEE_BASIC_AUTH_TOKEN: ${{ secrets.APIGEE_BASIC_AUTH_TOKEN }}
42+
APIGEE_OTP_KEY: ${{ secrets.APIGEE_OTP_KEY }}
43+
STATUS_API_KEY: ${{ secrets.STATUS_API_KEY }}
44+
45+
run-internal-dev-tests:
46+
needs: [deploy-internal-dev-backend]
47+
uses: ./.github/workflows/run-e2e-tests.yml
48+
with:
49+
apigee_environment: internal-dev
50+
environment: dev
51+
sub_environment: internal-dev
52+
secrets:
53+
APIGEE_PASSWORD: ${{ secrets.APIGEE_PASSWORD }}
54+
APIGEE_BASIC_AUTH_TOKEN: ${{ secrets.APIGEE_BASIC_AUTH_TOKEN }}
55+
APIGEE_OTP_KEY: ${{ secrets.APIGEE_OTP_KEY }}
56+
STATUS_API_KEY: ${{ secrets.STATUS_API_KEY }}
57+
58+
deploy-higher-dev-envs:
59+
needs: [run-internal-dev-tests]
60+
strategy:
61+
matrix:
62+
sub_environment_name: [ref, int]
63+
uses: ./.github/workflows/deploy-backend.yml
64+
with:
65+
apigee_environment: ${{ matrix.sub_environment_name }}
66+
create_mns_subscription: true
67+
environment: dev
68+
sub_environment: ${{ matrix.sub_environment_name }}
69+
70+
run-higher-dev-env-tests:
71+
needs: [deploy-higher-dev-envs]
72+
strategy:
73+
matrix:
74+
sub_environment_name: [ref, int]
75+
uses: ./.github/workflows/run-e2e-tests.yml
76+
with:
77+
apigee_environment: ${{ matrix.sub_environment_name }}
78+
environment: dev
79+
sub_environment: ${{ matrix.sub_environment_name }}
80+
secrets:
81+
APIGEE_PASSWORD: ${{ secrets.APIGEE_PASSWORD }}
82+
APIGEE_BASIC_AUTH_TOKEN: ${{ secrets.APIGEE_BASIC_AUTH_TOKEN }}
83+
APIGEE_OTP_KEY: ${{ secrets.APIGEE_OTP_KEY }}
84+
STATUS_API_KEY: ${{ secrets.STATUS_API_KEY }}

.github/workflows/deploy-backend.yml

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ on:
2727
- ref
2828
- prod
2929
create_mns_subscription:
30-
description: Create an MNS Subscription. Only available in dev
30+
description: Create an MNS Subscription programatically. Only available in AWS dev
3131
required: false
3232
type: boolean
3333
default: true
3434
environment:
35-
type: string
35+
type: choice
3636
description: Select the backend environment
3737
options:
3838
- dev
@@ -42,67 +42,59 @@ on:
4242
type: string
4343
description: Set the sub environment name e.g. pr-xxx, or green/blue in higher environments
4444

45+
env: # Sonarcloud - do not allow direct usage of untrusted data
46+
APIGEE_ENVIRONMENT: ${{ inputs.apigee_environment }}
47+
ENVIRONMENT: ${{ inputs.environment }}
48+
SUB_ENVIRONMENT: ${{ inputs.sub_environment }}
49+
50+
permissions:
51+
id-token: write
52+
contents: read
53+
4554
jobs:
4655
terraform-plan:
4756
runs-on: ubuntu-latest
4857
environment:
4958
name: ${{ inputs.environment }}
50-
env: # Sonarcloud - do not allow direct usage of untrusted data
51-
APIGEE_ENVIRONMENT: ${{ inputs.apigee_environment }}
52-
BACKEND_ENVIRONMENT: ${{ inputs.environment }}
53-
BACKEND_SUB_ENVIRONMENT: ${{ inputs.sub_environment }}
54-
permissions:
55-
id-token: write
56-
contents: read
5759
steps:
60+
- name: Checkout
61+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
62+
5863
- name: Connect to AWS
59-
uses: aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838
64+
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8
6065
with:
6166
aws-region: eu-west-2
6267
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/auto-ops
6368
role-session-name: github-actions
6469

65-
- name: Whoami
66-
run: aws sts get-caller-identity
67-
68-
- name: Checkout
69-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
70-
7170
- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd
7271
with:
7372
terraform_version: "1.12.2"
7473

7574
- name: Terraform Init
76-
working-directory: ${{ vars.TERRAFORM_DIR_PATH }}
77-
run: make init apigee_environment=$APIGEE_ENVIRONMENT environment=$BACKEND_ENVIRONMENT sub_environment=$BACKEND_SUB_ENVIRONMENT
75+
working-directory: terraform
76+
run: make init
7877

7978
- name: Terraform Plan
80-
working-directory: ${{ vars.TERRAFORM_DIR_PATH }}
81-
run: make plan-ci apigee_environment=$APIGEE_ENVIRONMENT environment=$BACKEND_ENVIRONMENT sub_environment=$BACKEND_SUB_ENVIRONMENT
79+
working-directory: terraform
80+
run: make plan-ci
8281

8382
- name: Save Terraform Plan
8483
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
8584
with:
86-
name: tfplan
87-
path: ${{ vars.TERRAFORM_DIR_PATH }}/tfplan
85+
name: ${{ env.ENVIRONMENT }}-${{ env.SUB_ENVIRONMENT }}-tfplan
86+
path: terraform/tfplan
8887

8988
terraform-apply:
9089
needs: terraform-plan
9190
runs-on: ubuntu-latest
9291
environment:
9392
name: ${{ inputs.environment }}
94-
env: # Sonarcloud - do not allow direct usage of untrusted data
95-
APIGEE_ENVIRONMENT: ${{ inputs.apigee_environment }}
96-
BACKEND_ENVIRONMENT: ${{ inputs.environment }}
97-
BACKEND_SUB_ENVIRONMENT: ${{ inputs.sub_environment }}
98-
permissions:
99-
id-token: write
100-
contents: read
10193
steps:
10294
- name: Checkout
10395
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
10496

105-
- uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a
97+
- uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8
10698
with:
10799
aws-region: eu-west-2
108100
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/auto-ops
@@ -115,17 +107,17 @@ jobs:
115107
- name: Retrieve Terraform Plan
116108
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
117109
with:
118-
name: tfplan
119-
path: ${{ vars.TERRAFORM_DIR_PATH }}
110+
name: ${{ env.ENVIRONMENT }}-${{ env.SUB_ENVIRONMENT }}-tfplan
111+
path: terraform
120112

121113
- name: Terraform Init
122-
working-directory: ${{ vars.TERRAFORM_DIR_PATH }}
123-
run: make init apigee_environment=$APIGEE_ENVIRONMENT environment=$BACKEND_ENVIRONMENT sub_environment=$BACKEND_SUB_ENVIRONMENT
114+
working-directory: terraform
115+
run: make init
124116

125117
- name: Terraform Apply
126-
working-directory: ${{ vars.TERRAFORM_DIR_PATH }}
118+
working-directory: terraform
127119
run: |
128-
make apply-ci apigee_environment=$APIGEE_ENVIRONMENT environment=$BACKEND_ENVIRONMENT sub_environment=$BACKEND_SUB_ENVIRONMENT
120+
make apply-ci
129121
echo "ID_SYNC_QUEUE_ARN=$(make -s output name=id_sync_queue_arn)" >> $GITHUB_ENV
130122
131123
- name: Install poetry
@@ -137,12 +129,14 @@ jobs:
137129
with:
138130
python-version: 3.11
139131
cache: "poetry"
132+
cache-dependency-path: |
133+
lambdas/mns_subscription/poetry.lock
134+
lambdas/shared/poetry.lock
140135
141136
- name: Create MNS Subscription
142137
if: ${{ inputs.environment == 'dev' && inputs.create_mns_subscription }}
143138
working-directory: "./lambdas/mns_subscription"
144139
env:
145-
APIGEE_ENVIRONMENT: ${{ inputs.apigee_environment }}
146140
SQS_ARN: ${{ env.ID_SYNC_QUEUE_ARN }}
147141
run: |
148142
poetry install --no-root
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: PR Deploy and Test
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
jobs:
8+
deploy-pr-backend:
9+
uses: ./.github/workflows/deploy-backend.yml
10+
with:
11+
apigee_environment: internal-dev
12+
create_mns_subscription: true
13+
environment: dev
14+
sub_environment: pr-${{github.event.pull_request.number}}
15+
16+
run-e2e-tests:
17+
needs: [deploy-pr-backend]
18+
strategy:
19+
matrix:
20+
apigee_environment_name: [internal-dev, internal-dev-sandbox]
21+
uses: ./.github/workflows/run-e2e-tests.yml
22+
with:
23+
apigee_environment: ${{ matrix.apigee_environment_name }}
24+
environment: dev
25+
sub_environment: pr-${{github.event.pull_request.number}}
26+
secrets:
27+
APIGEE_PASSWORD: ${{ secrets.APIGEE_PASSWORD }}
28+
APIGEE_BASIC_AUTH_TOKEN: ${{ secrets.APIGEE_BASIC_AUTH_TOKEN }}
29+
APIGEE_OTP_KEY: ${{ secrets.APIGEE_OTP_KEY }}
30+
STATUS_API_KEY: ${{ secrets.STATUS_API_KEY }}

.github/workflows/pr-teardown.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626

2727
steps:
2828
- name: Connect to AWS
29-
uses: aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838
29+
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8
3030
with:
3131
aws-region: eu-west-2
3232
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/auto-ops
@@ -43,7 +43,7 @@ jobs:
4343
terraform_version: "1.12.2"
4444

4545
- name: Terraform Init and extract MNS SQS QUEUE ARN
46-
working-directory: ${{ vars.TERRAFORM_DIR_PATH }}
46+
working-directory: terraform
4747
run: |
4848
make init apigee_environment=$APIGEE_ENVIRONMENT environment=$BACKEND_ENVIRONMENT sub_environment=$BACKEND_SUB_ENVIRONMENT
4949
make workspace apigee_environment=$APIGEE_ENVIRONMENT environment=$BACKEND_ENVIRONMENT sub_environment=$BACKEND_SUB_ENVIRONMENT
@@ -56,6 +56,9 @@ jobs:
5656
with:
5757
python-version: 3.11
5858
cache: "poetry"
59+
cache-dependency-path: |
60+
lambdas/mns_subscription/poetry.lock
61+
lambdas/shared/poetry.lock
5962
6063
- name: Unsubscribe MNS
6164
working-directory: "./lambdas/mns_subscription"
@@ -68,6 +71,6 @@ jobs:
6871
make unsubscribe
6972
7073
- name: Terraform Destroy
71-
working-directory: ${{ vars.TERRAFORM_DIR_PATH }}
74+
working-directory: terraform
7275
run: |
7376
make destroy apigee_environment=$APIGEE_ENVIRONMENT environment=$BACKEND_ENVIRONMENT sub_environment=$BACKEND_SUB_ENVIRONMENT

0 commit comments

Comments
 (0)