Skip to content

Commit 91a9f8e

Browse files
committed
Merge branch 'main' into feature/CCM-10555-client-config-endpoint-2
2 parents 0ef9be4 + 1b35643 commit 91a9f8e

File tree

27 files changed

+522
-580
lines changed

27 files changed

+522
-580
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Acceptance tests
2+
description: "Run acceptance tests for this repo"
3+
4+
inputs:
5+
testType:
6+
description: Type of test to run
7+
required: true
8+
9+
targetEnvironment:
10+
description: Name of the environment under test
11+
required: true
12+
13+
targetAccountGroup:
14+
description: Name of the account group under test
15+
default: nhs-notify-template-management-dev
16+
required: true
17+
18+
targetComponent:
19+
description: Name of the component under test
20+
required: true
21+
22+
runs:
23+
using: "composite"
24+
25+
steps:
26+
- name: Fetch terraform output
27+
uses: actions/download-artifact@v4
28+
with:
29+
name: terraform-output-${{ inputs.targetComponent }}
30+
- name: "Repo setup"
31+
shell: bash
32+
run: |
33+
npm ci
34+
35+
- name: Generate outputs file
36+
shell: bash
37+
run: |
38+
root_dir=${GITHUB_WORKSPACE}
39+
mv ./terraform_output.json ./sandbox_tf_outputs.json
40+
npm run generate-outputs sandbox-output
41+
42+
- name: Run test - ${{ inputs.testType }}
43+
shell: bash
44+
run: |
45+
make test-${{ inputs.testType }}
46+
47+
- name: Archive ui-e2e test results
48+
if: ${{ inputs.testType == 'ui-e2e' }}
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: UI E2E test report
52+
path: "tests/test-team/playwright-report"
53+
54+
- name: Archive ui-component test results
55+
if: ${{ inputs.testType == 'ui-component' }}
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: UI-component test report
59+
path: "tests/test-team/playwright-report"
60+
61+
- name: Archive api test results
62+
if: ${{ inputs.testType == 'api' }}
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: API test report
66+
path: "tests/test-team/playwright-report"
67+
68+
- name: Archive accessibility results
69+
if: ${{ inputs.testType == 'accessibility' }}
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: accessibility
73+
path: "tests/accessibility/.reports/accessibility"

.github/actions/normalize-branch-name/action.yaml

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,40 @@ name: "Normalize branch name"
22
description: "Normalize branch name"
33
outputs:
44
normalized_branch_name:
5-
description: 10 character branch identifier (0000-branch)
5+
description: generare a short branch identifier that can be used for an environment name
66
value: ${{ steps.normalize_branch_name.outputs.normalized_branch_name }}
77
runs:
88
using: "composite"
99
steps:
1010
- id: normalize_branch_name
11+
env:
12+
BRANCH: ${{ github.head_ref || github.ref_name }}
1113
shell: bash
1214
run: |
13-
branch=$(git rev-parse --abbrev-ref HEAD)
14-
stripped=$(echo $branch | sed -e 's/[^a-zA-Z0-9-]//g' | tr '[:upper:]' '[:lower:]')
15-
starting_from_jira_ref=$(echo $stripped | sed -n 's/.*\([0-9]\{4,\}.*\)/\1/p')
16-
with_fallback=${starting_from_jira_ref:-$stripped}
17-
chopped=$(echo $with_fallback | head -c 10)
18-
echo "normalized_branch_name=$chopped" >> $GITHUB_OUTPUT
15+
# Example: feature/CCM-00000_branch-description
16+
echo "BRANCH: $BRANCH"
17+
18+
# Example: feature/ccm-00000_branch-description
19+
LOWER_CASE_BRANCH=$(echo $BRANCH | tr '[:upper:]' '[:lower:]')
20+
21+
# Example: 00000_branch-description
22+
LEADING_STRIPPED=(${LOWER_CASE_BRANCH##*ccm-})
23+
24+
if [[ $LOWER_CASE_BRANCH == $LEADING_STRIPPED ]]; then
25+
# No CCM ref detected
26+
TICKET_NUMBER=""
27+
else
28+
# Example: 00000
29+
TICKET_NUMBER=${LEADING_STRIPPED%%[_-]*}
30+
fi
31+
32+
# Example: 04f106adc56fc0460853351c314b670d -
33+
HASH=$(md5sum <<<"$BRANCH")
34+
35+
# Example: 0000004f106adc56fc0460853351c314b670d -
36+
LONG_SANDBOX_NAME="$TICKET_NUMBER""$HASH"
37+
38+
# Example: 0000004f
39+
SANDBOX_NAME=${LONG_SANDBOX_NAME:0:8}
40+
echo "$SANDBOX_NAME"
41+
echo "normalized_branch_name=$SANDBOX_NAME" >> $GITHUB_OUTPUT

.github/actions/test-types.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
"accessibility",
3+
"ui-component",
4+
"ui-e2e",
5+
"api"
6+
]

.github/workflows/cicd-1-pull-request.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,4 @@ jobs:
9696
name: "Acceptance stage"
9797
needs: [metadata, test-stage]
9898
uses: ./.github/workflows/stage-4-acceptance.yaml
99-
with:
100-
build_datetime: "${{ needs.metadata.outputs.build_datetime }}"
101-
build_timestamp: "${{ needs.metadata.outputs.build_timestamp }}"
102-
build_epoch: "${{ needs.metadata.outputs.build_epoch }}"
103-
nodejs_version: "${{ needs.metadata.outputs.nodejs_version }}"
104-
python_version: "${{ needs.metadata.outputs.python_version }}"
105-
terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
106-
version: "${{ needs.metadata.outputs.version }}"
10799
secrets: inherit
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: Call Notify Internal Infrastructure Workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
jobName:
7+
type: string
8+
description: The name of the job triggering the remote workflow
9+
required: true
10+
infraRepoName:
11+
type: string
12+
description: Repository (this one) in the NHSDigital Github Org to deploy from
13+
default: ""
14+
releaseVersion:
15+
type: string
16+
description: The Github release version, commit, or tag.
17+
default: main
18+
targetWorkflow:
19+
type: string
20+
description: The name of the github workflow to call.
21+
required: true
22+
targetEnvironment:
23+
type: string
24+
description: The Terraform environment to deploy
25+
default: main
26+
targetComponent:
27+
type: string
28+
description: The Terraform component to deploy
29+
required: true
30+
targetAccountGroup:
31+
type: string
32+
description: The Terraform group to deploy
33+
required: true
34+
terraformAction:
35+
type: string
36+
description: The Terraform action to run
37+
default: ""
38+
internalRef:
39+
type: string
40+
description: Internal repo reference (branch or tag)
41+
default: "main"
42+
43+
permissions:
44+
id-token: write
45+
contents: read
46+
47+
concurrency:
48+
group: ${{ inputs.targetEnvironment }}-${{ inputs.targetAccountGroup }}-${{ inputs.targetComponent }}-${{ inputs.terraformAction }}
49+
50+
jobs:
51+
trigger:
52+
name: ${{ inputs.jobName }}
53+
runs-on: ubuntu-latest
54+
55+
steps:
56+
- uses: actions/checkout@v4
57+
58+
- name: Trigger nhs-notify-internal workflow
59+
shell: bash
60+
run: |
61+
DISPATCH_EVENT=$(jq -ncM \
62+
--arg infraRepoName "${{ inputs.infraRepoName }}" \
63+
--arg releaseVersion ${{ inputs.releaseVersion }} \
64+
--arg targetEnvironment ${{ inputs.targetEnvironment }} \
65+
--arg targetAccountGroup ${{ inputs.targetAccountGroup }} \
66+
--arg targetComponent ${{ inputs.targetComponent }} \
67+
--arg terraformAction "${{ inputs.terraformAction }}" \
68+
'{
69+
"ref": "${{ inputs.internalRef }}",
70+
"inputs": (
71+
(if $infraRepoName != "" then { "infraRepoName": $infraRepoName } else {} end) +
72+
(if $terraformAction != "" then { "terraformAction": $terraformAction } else {} end) +
73+
{
74+
"releaseVersion": $releaseVersion,
75+
"targetEnvironment": $targetEnvironment,
76+
"targetAccountGroup": $targetAccountGroup,
77+
"targetComponent": $targetComponent
78+
}
79+
)
80+
}')
81+
82+
# Trigger The workflow
83+
curl -L \
84+
--fail \
85+
--silent \
86+
-X POST \
87+
-H "Accept: application/vnd.github+json" \
88+
-H "Authorization: Bearer ${{ secrets.PR_TRIGGER_PAT }}" \
89+
-H "X-GitHub-Api-Version: 2022-11-28" \
90+
"https://api.github.com/repos/NHSDigital/nhs-notify-internal/actions/workflows/${{ inputs.targetWorkflow }}/dispatches" \
91+
-d "${DISPATCH_EVENT}"
92+
93+
echo "Workflow triggered. Waiting for the workflow to complete.."
94+
95+
# Poll GitHub API to check the workflow status
96+
workflow_run_url=""
97+
for i in {1..12}; do
98+
workflow_run_url=$(curl -s \
99+
-H "Accept: application/vnd.github+json" \
100+
-H "Authorization: Bearer ${{ secrets.PR_TRIGGER_PAT }}" \
101+
-H "X-GitHub-Api-Version: 2022-11-28" \
102+
"https://api.github.com/repos/NHSDigital/nhs-notify-internal/actions/runs?event=workflow_dispatch&status=in_progress" \
103+
| jq -r '.workflow_runs[]
104+
| select(.name
105+
| contains("'${{ inputs.targetEnvironment }}'") and
106+
contains("'${{ inputs.targetAccountGroup }}'") and
107+
contains("'${{ inputs.targetComponent }}'") and
108+
contains("'${{ inputs.terraformAction }}'"))
109+
| .url')
110+
111+
if [[ -n "$workflow_run_url" && "$workflow_run_url" != null ]]; then
112+
ui_url=${workflow_run_url/api./}
113+
ui_url=${ui_url/\/repos/}
114+
echo "Found workflow run url: $ui_url"
115+
echo "workflow_run_url=$workflow_run_url" >> $GITHUB_ENV
116+
break
117+
fi
118+
119+
echo "Waiting for workflow to start..."
120+
sleep 10
121+
done
122+
123+
if [[ -z "$workflow_run_url" || "$workflow_run_url" == null ]]; then
124+
echo "Failed to get the workflow run url. Exiting."
125+
exit 1
126+
fi
127+
128+
# Wait for workflow completion
129+
while true; do
130+
sleep 10
131+
response=$(curl -s -L \
132+
-H "Authorization: Bearer ${{ secrets.PR_TRIGGER_PAT }}" \
133+
-H "Accept: application/vnd.github+json" \
134+
$workflow_run_url)
135+
136+
status=$(echo "$response" | jq -r '.status')
137+
conclusion=$(echo "$response" | jq -r '.conclusion')
138+
139+
if [ "$status" == "completed" ]; then
140+
if [ "$conclusion" == "success" ]; then
141+
echo "Workflow completed successfully."
142+
exit 0
143+
else
144+
echo "Workflow failed with conclusion: $conclusion"
145+
exit 1
146+
fi
147+
fi
148+
149+
echo "Workflow still running..."
150+
sleep 20
151+
done

.github/workflows/pr_create_dynamic_env.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
name: PR Create Environment
23

34
on:

0 commit comments

Comments
 (0)