@@ -23,99 +23,17 @@ runs:
2323 using : " composite"
2424
2525 steps :
26- - name : Fetch terraform output
27- if : ${{ inputs.testType != 'e2e' }}
28- uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
29- with :
30- name : terraform-output-${{ inputs.targetComponent }}
3126
32- - name : Get Node version
27+ - name : Run component tests
3328 if : ${{ inputs.testType != 'e2e' }}
34- id : nodejs_version
35- shell : bash
36- run : |
37- echo "nodejs_version=$(grep "^nodejs\s" .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT
38-
39- - name : " Repo setup"
40- uses : ./.github/actions/node-install
29+ uses : ./.github/actions/acceptance-tests-component
4130 with :
42- GITHUB_TOKEN : ${{ env.GITHUB_TOKEN }}
43-
44- - name : " Set PR NUMBER"
45- if : ${{ inputs.testType == 'e2e' }}
46- id : set_pr_number
47- shell : bash
48- run : |
49- env="${{ inputs.targetEnvironment }}"
50- if [[ "$env" == main ]]; then
51- echo "pr_number=" >> $GITHUB_OUTPUT
52- elif [[ "$env" == pr* ]]; then
53- echo "pr_number=${env#pr}" >> $GITHUB_OUTPUT
54- else
55- echo "pr_number=$env" >> $GITHUB_OUTPUT
56- fi
57-
58- - name : Install poetry and e2e test dependencies
59- if : ${{ inputs.testType == 'e2e' }}
60- shell : bash
61- run : |
62- pipx install poetry
63- cd tests/e2e-tests && poetry install
31+ testType : ${{ inputs.testType }}
32+ targetEnvironment : ${{ inputs.targetEnvironment }}
33+ targetComponent : ${{ inputs.targetComponent }}
6434
65- - name : " Determine if proxy has been deployed "
35+ - name : Run e2e tests
6636 if : ${{ inputs.testType == 'e2e' }}
67- id : check_proxy_deployed
68- env :
69- GITHUB_TOKEN : ${{ env.GITHUB_TOKEN }}
70- PR_NUMBER : ${{ steps.set_pr_number.outputs.pr_number }}
71- shell : bash
72- run : |
73- if [[ -z "$PR_NUMBER" ]]; then
74- echo "No pull request detected; proxy was deployed."
75- echo "proxy_deployed=true" >> $GITHUB_OUTPUT
76- exit 0
77- fi
78-
79- branch_name=${GITHUB_HEAD_REF:-$(echo $GITHUB_REF | sed 's#refs/heads/##')}
80-
81- labels=$(gh pr view "$PR_NUMBER" --json labels --jq '.labels[].name')
82- echo "Labels on PR #$PR_NUMBER: $labels"
83-
84- if echo "$labels" | grep -Fxq 'deploy-proxy'; then
85- echo "proxy_deployed=true" >> $GITHUB_OUTPUT
86- else
87- echo "proxy_deployed=false" >> $GITHUB_OUTPUT
88- fi
89-
90- - name : Run test - ${{ inputs.testType }}
91- if : ${{ inputs.testType != 'e2e'}}
92- shell : bash
93- env :
94- TARGET_ENVIRONMENT : ${{ inputs.targetEnvironment }}
95- run : |
96- make test-${{ inputs.testType }}
97-
98- - name : Run test - e2e
99- if : ${{ inputs.testType == 'e2e' && steps.check_proxy_deployed.outputs.proxy_deployed == 'true'}}
100- shell : bash
101- env :
102- TARGET_ENVIRONMENT : ${{ inputs.targetEnvironment }}
103- PR_NUMBER : ${{ steps.set_pr_number.outputs.pr_number }}
104- run : |
105- PR_NUMBER=""
106- echo "$SUPPLIER_API_PRIVATE_KEY" > "${GITHUB_WORKSPACE}/internal-dev-test-1.pem"
107- chmod 600 "${GITHUB_WORKSPACE}/internal-dev-test-1.pem"
108- BASE_PROXY_NAME=nhs-notify-supplier--internal-dev--nhs-notify-supplier
109-
110- export API_ENVIRONMENT=internal-dev
111- if [[ -z "$PR_NUMBER" ]]; then
112- export PROXY_NAME="${BASE_PROXY_NAME}"
113- export NON_PROD_API_KEY="${APIM_API_KEY}"
114- else
115- export PROXY_NAME="${BASE_PROXY_NAME}-PR-${PR_NUMBER}"
116- export NON_PROD_API_KEY="${APIM_PR_API_KEY}"
117- fi
118-
119- export STATUS_ENDPOINT_API_KEY="${APIM_STATUS_API_KEY}"
120- export NON_PROD_PRIVATE_KEY="${GITHUB_WORKSPACE}/internal-dev-test-1.pem"
121- make .internal-dev-test
37+ uses : ./.github/actions/acceptance-tests-e2e
38+ with :
39+ targetEnvironment : ${{ inputs.targetEnvironment }}
0 commit comments