@@ -48,73 +48,76 @@ permissions:
4848jobs :
4949 wait-for-deployment :
5050 runs-on : ubuntu-latest
51- environment : ${{ inputs.environment }}
51+ environment : ${{ inputs.apigee_environment }}
5252 steps :
5353 - name : Wait for API to be available
5454 run : |
55- set -ex
56-
5755 endpoint=""
58- if [[ $APIGEE_ENVIRONMENT =~ "prod" ]]; then
56+ if [[ ${ APIGEE_ENVIRONMENT} =~ "prod" ]]; then
5957 endpoint="https://api.service.nhs.uk/${SERVICE_BASE_PATH}/_status"
6058 else
6159 endpoint="https://${APIGEE_ENVIRONMENT}.api.service.nhs.uk/${SERVICE_BASE_PATH}/_status"
6260 fi
6361
6462 counter=0
65- while [[ $counter -lt 31 ]]; do
66- response=$(curl -H "apikey: ${STATUS_API_KEY}" -s "$endpoint")
67- response_code=$(jq -r '.checks.healthcheck.responseCode' <<< "$response")
68- response_body=$(jq -r '.checks.healthcheck.outcome' <<< "$response")
69- status=$(jq -r '.status' <<< "$response")
70- if [ "$response_code" -eq 200 ] && [ "$response_body" == "OK" ] && [ "$status" == "pass" ]; then
63+ while [[ ${ counter} -lt 31 ]]; do
64+ response=$(curl -H "apikey: ${STATUS_API_KEY}" -s "${ endpoint} ")
65+ response_code=$(jq -r '.checks.healthcheck.responseCode' <<< "${ response} ")
66+ response_body=$(jq -r '.checks.healthcheck.outcome' <<< "${ response} ")
67+ status=$(jq -r '.status' <<< "${ response} ")
68+ if [[ "${ response_code} " -eq 200 ]] && [[ "${ response_body} " == "OK" ]] && [[ "${ status} " == "pass" ] ]; then
7169 echo "Status test successful"
7270 break
7371 else
74- echo "Waiting for $endpoint to return a 200 response with 'OK' body..."
72+ echo "Waiting for ${ endpoint} to return a 200 response with 'OK' body..."
7573 ((counter=counter+1)) # Increment counter by 1
76- echo "Attempt $counter"
74+ echo "Attempt ${ counter} "
7775 sleep 30
7876 fi
7977 done
8078
81- if [ $ counter -eq 31 ]; then
79+ if [[ ${ counter} -eq 31 ] ]; then
8280 echo "Status test failed: Maximum number of attempts reached"
8381 echo "Last response received:"
84- echo "$response"
82+ echo "${ response} "
8583 exit 1
8684 fi
8785
8886 e2e-tests :
8987 runs-on : ubuntu-latest
9088 needs : [wait-for-deployment]
91- environment : ${{ inputs.environment }}
89+ environment : ${{ inputs.apigee_environment }}
9290 env :
9391 APIGEE_USERNAME : ${{ vars.APIGEE_USERNAME }}
9492 SOURCE_COMMIT_ID : ${{ github.sha }}
9593 steps :
94+ - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
95+
9696 - name : Connect to AWS
97+ if : ${{ vars.RUN_FULL_E2E_TESTS == 'true' }}
9798 uses : aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838
9899 with :
99100 aws-region : eu-west-2
100101 role-to-assume : arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/auto-ops
101102 role-session-name : github-actions
102103
103- - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
104-
105104 - uses : hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd
105+ if : ${{ vars.RUN_FULL_E2E_TESTS == 'true' }}
106106 with :
107107 terraform_version : " 1.12.2"
108108
109109 - name : Terraform Init
110+ if : ${{ vars.RUN_FULL_E2E_TESTS == 'true' }}
110111 working-directory : terraform
111112 run : make init
112113
113114 - name : Set Terraform workspace
115+ if : ${{ vars.RUN_FULL_E2E_TESTS == 'true' }}
114116 working-directory : terraform
115117 run : make workspace
116118
117119 - name : Read Terraform outputs
120+ if : ${{ vars.RUN_FULL_E2E_TESTS == 'true' }}
118121 working-directory : terraform
119122 run : |
120123 echo "IMMS_DELTA_TABLE_NAME=$(make -s output name=imms_delta_table_name)" >> $GITHUB_ENV
@@ -137,6 +140,7 @@ jobs:
137140 run : poetry install --no-root
138141
139142 - name : Get Apigee access token
143+ if : ${{ vars.RUN_FULL_E2E_TESTS == 'true' }}
140144 working-directory : e2e
141145 env :
142146 APIGEE_PASSWORD : ${{ secrets.APIGEE_PASSWORD }}
@@ -181,17 +185,17 @@ jobs:
181185 # Only actually depend on wait-for-deployment, but run after e2e-tests
182186 if : ${{ !cancelled() && needs.wait-for-deployment.result == 'success' && vars.RUN_BATCH_E2E_TESTS == 'true' }}
183187 runs-on : ubuntu-latest
184- environment : ${{ inputs.environment }}
188+ environment : ${{ inputs.apigee_environment }}
185189 steps :
190+ - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
191+
186192 - name : Connect to AWS
187193 uses : aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838
188194 with :
189195 aws-region : eu-west-2
190196 role-to-assume : arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/auto-ops
191197 role-session-name : github-actions
192198
193- - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
194-
195199 - name : Install poetry
196200 run : pip install poetry==2.1.4
197201
0 commit comments