Skip to content

Commit f737922

Browse files
committed
Invoke test from internal repo, so secrets are not in public repo
1 parent 855e83b commit f737922

4 files changed

Lines changed: 47 additions & 19 deletions

File tree

.github/actions/test-types.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[
22
"component",
3+
"e2e",
34
"sandbox"
45
]

.github/scripts/dispatch_internal_repo_workflow.sh

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
# ./dispatch_internal_repo_workflow.sh \
77
# --infraRepoName <repo> \
88
# --releaseVersion <version> \
9-
# --targetWorkflow <workflow.yaml> \
9+
# --targ echo " targetDomain: $targetDomain"
10+
echo " version: $version"
11+
12+
DISPATCH_EVENT=$(jq -ncM \rkflow <workflow.yaml> \
1013
# --targetEnvironment <env> \
1114
# --targetComponent <component> \
1215
# --targetAccountGroup <group> \
@@ -17,7 +20,11 @@
1720
# --overrideRoleName <name>
1821
1922
#
20-
# All arguments are required except terraformAction, and internalRef.
23+
# Required arguments are:
24+
# infraRepoName, releaseVersion, targetWorkflow, targetEnvironment, targetComponent, targetAccountGroup.
25+
#
26+
# All other arguments are optional.
27+
#
2128
# Example:
2229
# ./dispatch_internal_repo_workflow.sh \
2330
# --infraRepoName "nhs-notify-web-template-management" \
@@ -30,7 +37,9 @@
3037
# --internalRef "main" \
3138
# --overrides "tf_var=someString" \
3239
# --overrideProjectName nhs \
33-
# --overrideRoleName nhs-service-iam-role
40+
# --overrideRoleName nhs-service-iam-role \
41+
# --extraSecretNames '["MY_API_KEY"]'
42+
3443
3544
set -e
3645
@@ -104,6 +113,14 @@ while [[ $# -gt 0 ]]; do
104113
version="$2"
105114
shift 2
106115
;;
116+
--extraSecretNames) # JSON array of secret names to fetch in the internal repo (optional)
117+
extraSecretNames="$2"
118+
shift 2
119+
;;
120+
--testsToRun) # JSON array of test types to run, overriding test-types.json (optional)
121+
testsToRun="$2"
122+
shift 2
123+
;;
107124
*)
108125
echo "[ERROR] Unknown argument: $1"
109126
exit 1
@@ -202,6 +219,14 @@ if [[ -z "$version" ]]; then
202219
version=""
203220
fi
204221
222+
if [[ -z "$extraSecretNames" ]]; then
223+
extraSecretNames=""
224+
fi
225+
226+
if [[ -z "$testsToRun" ]]; then
227+
testsToRun=""
228+
fi
229+
205230
echo "==================== Workflow Dispatch Parameters ===================="
206231
echo " infraRepoName: $infraRepoName"
207232
echo " releaseVersion: $releaseVersion"
@@ -240,6 +265,8 @@ DISPATCH_EVENT=$(jq -ncM \
240265
--arg boundedContext "$boundedContext" \
241266
--arg targetDomain "$targetDomain" \
242267
--arg version "$version" \
268+
--argjson extraSecretNames "${extraSecretNames:-null}" \
269+
--argjson testsToRun "${testsToRun:-null}" \
243270
'{
244271
"ref": "'"$internalRef"'",
245272
"inputs": (
@@ -255,6 +282,8 @@ DISPATCH_EVENT=$(jq -ncM \
255282
(if $boundedContext != "" then { "boundedContext": $boundedContext } else {} end) +
256283
(if $targetDomain != "" then { "targetDomain": $targetDomain } else {} end) +
257284
(if $version != "" then { "version": $version } else {} end) +
285+
(if $extraSecretNames != null then { "extraSecretNames": ($extraSecretNames | tojson) } else {} end) +
286+
(if $testsToRun != null then { "testsToRun": ($testsToRun | tojson) } else {} end) +
258287
(if $targetAccountGroup != "" then { "targetAccountGroup": $targetAccountGroup } else {} end) +
259288
{
260289
"releaseVersion": $releaseVersion,

.github/workflows/stage-4-acceptance.yaml

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ jobs:
6666
echo "ENVIRONMENT=main" >> $GITHUB_ENV
6767
fi
6868
69+
- name: "Set tests to run"
70+
shell: bash
71+
run: |
72+
if [ "${{ inputs.proxy_deployed }}" == "true" ]; then
73+
echo 'TESTS_TO_RUN=["component","e2e","sandbox"]' >> $GITHUB_ENV
74+
else
75+
echo 'TESTS_TO_RUN=["component","sandbox"]' >> $GITHUB_ENV
76+
fi
77+
6978
- name: Trigger Acceptance Tests
7079
shell: bash
7180
env:
@@ -80,19 +89,6 @@ jobs:
8089
--overrideProjectName "nhs" \
8190
--targetEnvironment "$ENVIRONMENT" \
8291
--targetAccountGroup "nhs-notify-supplier-api-dev" \
83-
--targetComponent "api"
84-
85-
run-e2e-tests:
86-
name: Run End-to-End Tests
87-
runs-on: ubuntu-latest
88-
if: inputs.proxy_deployed == 'true'
89-
steps:
90-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
91-
92-
- name: "Run e2e tests"
93-
uses: ./.github/actions/e2e-tests
94-
env:
95-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96-
NON_PROD_API_KEY: ${{ secrets.NON_PROD_API_KEY }}
97-
INTERNAL_DEV_TEST_PEM: ${{ secrets.INTERNAL_DEV_TEST_PEM }}
98-
STATUS_ENDPOINT_API_KEY: ${{ secrets.STATUS_ENDPOINT_API_KEY }}
92+
--targetComponent "api" \
93+
--extraSecretNames '["INTERNAL_DEV_TEST_PEM","NON_PROD_API_KEY","STATUS_ENDPOINT_API_KEY"]' \
94+
--testsToRun "$TESTS_TO_RUN"

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ test-component:
107107
test-sandbox:
108108
(cd tests && npm install && npm run test:sandbox)
109109

110+
test-e2e: .internal-dev-test
111+
110112
test-performance:
111113
(cd tests && npm install && npm run test:performance)
112114

0 commit comments

Comments
 (0)