Skip to content

Commit 55609ef

Browse files
CCM-12732: Component tests framework (#94)
1 parent 6703a70 commit 55609ef

File tree

24 files changed

+1072
-236
lines changed

24 files changed

+1072
-236
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
default: main
9+
10+
targetEnvironment:
11+
description: Name of the environment under test
12+
required: true
13+
default: main
14+
15+
targetAccountGroup:
16+
description: Name of the account group under test
17+
default: nhs-notify-digital-letters-dev
18+
required: true
19+
20+
targetComponent:
21+
description: Name of the component under test
22+
default: dl
23+
24+
runs:
25+
using: "composite"
26+
27+
steps:
28+
- name: "Repo setup"
29+
shell: bash
30+
run: |
31+
npm ci
32+
33+
- name: Run test - ${{ inputs.testType }}
34+
shell: bash
35+
run: |
36+
set -euo pipefail
37+
case "$TEST_TYPE" in
38+
main|integration|unit)
39+
make "test-$TEST_TYPE"
40+
;;
41+
*)
42+
echo "Invalid testType: $TEST_TYPE" >&2
43+
exit 1
44+
;;
45+
esac
46+
env:
47+
TEST_TYPE: ${{ inputs.testType }}
48+
ENVIRONMENT: ${{ inputs.targetEnvironment }}
49+
50+
- name: Archive integration test results
51+
if: ${{ inputs.testType == 'integration' }}
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: Integration test report
55+
path: "tests/playwright/playwright-report"

.github/actions/test-types.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[
2+
"integration"
3+
]

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,15 @@ jobs:
151151
--overrides "branch_name=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
152152
acceptance-stage: # Recommended maximum execution time is 10 minutes
153153
name: "Acceptance stage"
154-
needs: [metadata, build-stage]
154+
needs: [metadata, pr-create-dynamic-environment]
155155
uses: ./.github/workflows/stage-4-acceptance.yaml
156156
if: needs.metadata.outputs.does_pull_request_exist == 'true' || (github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened')) || (github.event_name == 'push' && github.ref == 'refs/heads/main')
157157
with:
158-
build_datetime: "${{ needs.metadata.outputs.build_datetime }}"
159-
build_timestamp: "${{ needs.metadata.outputs.build_timestamp }}"
160-
build_epoch: "${{ needs.metadata.outputs.build_epoch }}"
161-
nodejs_version: "${{ needs.metadata.outputs.nodejs_version }}"
162-
python_version: "${{ needs.metadata.outputs.python_version }}"
163-
terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
164-
version: "${{ needs.metadata.outputs.version }}"
165-
secrets: inherit
158+
target_environment: "pr${{ needs.metadata.outputs.pr_number }}"
159+
target_account_group: nhs-notify-digital-letters-dev
160+
secrets:
161+
APP_PEM_FILE: ${{ secrets.APP_PEM_FILE }}
162+
APP_CLIENT_ID: ${{ secrets.APP_CLIENT_ID }}
166163
publish-stage: # Recommended maximum execution time is 10 minutes
167164
name: "Publish stage"
168165
needs: [metadata, acceptance-stage]

.github/workflows/pr_closed.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,15 @@ jobs:
6262
--targetAccountGroup "nhs-notify-digital-letters-dev" \
6363
--targetComponent "${{ matrix.component }}" \
6464
--terraformAction "apply"
65+
66+
acceptance-stage: # Recommended maximum execution time is 10 minutes
67+
name: "Acceptance stage"
68+
needs: [ deploy-main]
69+
uses: ./.github/workflows/stage-4-acceptance.yaml
70+
secrets:
71+
APP_PEM_FILE: ${{ secrets.APP_PEM_FILE }}
72+
APP_CLIENT_ID: ${{ secrets.APP_CLIENT_ID }}
73+
with:
74+
target_release_version: main
75+
target_environment: main
76+
target_account_group: nhs-notify-digital-letters-dev

.github/workflows/release_created.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ jobs:
4949
with:
5050
target_environment: "main"
5151
target_account_group: nhs-notify-digital-letters-nonprod
52+
target_release_version: ${{ github.event.release.tag_name }}

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

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,22 @@ name: "Acceptance stage"
22

33
on:
44
workflow_call:
5-
inputs:
6-
build_datetime:
7-
description: "Build datetime, set by the CI/CD pipeline workflow"
5+
secrets:
6+
APP_PEM_FILE:
87
required: true
9-
type: string
10-
build_timestamp:
11-
description: "Build timestamp, set by the CI/CD pipeline workflow"
12-
required: true
13-
type: string
14-
build_epoch:
15-
description: "Build epoch, set by the CI/CD pipeline workflow"
16-
required: true
17-
type: string
18-
nodejs_version:
19-
description: "Node.js version, set by the CI/CD pipeline workflow"
20-
required: true
21-
type: string
22-
python_version:
23-
description: "Python version, set by the CI/CD pipeline workflow"
8+
APP_CLIENT_ID:
249
required: true
10+
inputs:
11+
target_release_version:
12+
description: "Version of the software, set by the CI/CD pipeline workflow"
13+
required: false
2514
type: string
26-
terraform_version:
27-
description: "Terraform version, set by the CI/CD pipeline workflow"
15+
target_environment:
16+
description: "Environment being tested"
2817
required: true
2918
type: string
30-
version:
31-
description: "Version of the software, set by the CI/CD pipeline workflow"
19+
target_account_group:
20+
description: "Account for the environment being tested"
3221
required: true
3322
type: string
3423

@@ -109,16 +98,27 @@ jobs:
10998
name: "Integration test"
11099
runs-on: ubuntu-latest
111100
needs: environment-set-up
112-
timeout-minutes: 10
113101
steps:
114-
- name: "Checkout code"
115-
uses: actions/checkout@v5
116-
- name: "Run integration test"
117-
run: |
118-
make test-integration
119-
- name: "Save result"
120-
run: |
121-
echo "Nothing to save"
102+
- uses: actions/checkout@v5.0.0
103+
# Calls out to the nhs-notify-internal repo.
104+
# The nhs-notify-internal repo will run the tests
105+
# setup in ./.github/actions/acceptance-tests/action.yaml
106+
- name: Trigger Acceptance Tests
107+
shell: bash
108+
env:
109+
APP_PEM_FILE: ${{ secrets.APP_PEM_FILE }}
110+
APP_CLIENT_ID: ${{ secrets.APP_CLIENT_ID }}
111+
TARGET_ENVIRONMENT: ${{ inputs.target_environment }}
112+
TARGET_ACCOUNT_GROUP: ${{ inputs.target_account_group }}
113+
run: |
114+
.github/scripts/dispatch_internal_repo_workflow.sh \
115+
--infraRepoName "nhs-notify-digital-letters" \
116+
--overrideProjectName "nhs" \
117+
--releaseVersion "${{ inputs.target_release_version || github.head_ref || github.ref_name }}" \
118+
--targetWorkflow "dispatch-contextual-tests-dynamic-env.yaml" \
119+
--targetEnvironment "$TARGET_ENVIRONMENT" \
120+
--targetAccountGroup "$TARGET_ACCOUNT_GROUP" \
121+
--targetComponent "dl"
122122
test-accessibility:
123123
name: "Accessibility test"
124124
runs-on: ubuntu-latest

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ node_modules
2222
dist
2323
.DS_Store
2424
.reports
25+
**/playwright-report
26+
**/test-results

.gitleaksignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ cd9c0efec38c5d63053dd865e5d4e207c0760d91:docs/guides/Perform_static_analysis.md:
44
cd9c0efec38c5d63053dd865e5d4e207c0760d91:docs/guides/Perform_static_analysis.md:sonar-api-token:37
55
96096685ab3d6876671e2bc9a6ff4d48fc56e521:src/helloworld/helloworld.sln:ipv4:4
66
4f4e8c15629b2cb09356a7fed4d72953590227ce:docs/Gemfile.lock:ipv4:4
7+
52386bca9b88c0c8c7dee52ab0ec69d04fb72c46:src/TESTING_PLAN.md:ipv4:145

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ gitleaks 8.24.0
33
jq 1.6
44
nodejs 22.11.0
55
pre-commit 3.6.0
6+
python 3.13.2
67
terraform 1.10.1
78
terraform-docs 0.19.0
89
trivy 0.61.0

infrastructure/terraform/components/dl/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ No requirements.
1010
| Name | Description | Type | Default | Required |
1111
|------|-------------|------|---------|:--------:|
1212
| <a name="input_aws_account_id"></a> [aws\_account\_id](#input\_aws\_account\_id) | The AWS Account ID (numeric) | `string` | n/a | yes |
13+
| <a name="input_component"></a> [component](#input\_component) | The variable encapsulating the name of this component | `string` | `"dl"` | no |
1314
| <a name="input_default_tags"></a> [default\_tags](#input\_default\_tags) | A map of default tags to apply to all taggable resources within the component | `map(string)` | `{}` | no |
1415
| <a name="input_enable_dynamodb_delete_protection"></a> [enable\_dynamodb\_delete\_protection](#input\_enable\_dynamodb\_delete\_protection) | Enable DynamoDB Delete Protection on all Tables | `bool` | `true` | no |
1516
| <a name="input_environment"></a> [environment](#input\_environment) | The name of the tfscaffold environment | `string` | n/a | yes |
@@ -38,7 +39,9 @@ No requirements.
3839
| <a name="module_ttl_poll"></a> [ttl\_poll](#module\_ttl\_poll) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.24/terraform-lambda.zip | n/a |
3940
## Outputs
4041

41-
No outputs.
42+
| Name | Description |
43+
|------|-------------|
44+
| <a name="output_deployment"></a> [deployment](#output\_deployment) | Deployment details used for post-deployment scripts |
4245
<!-- vale on -->
4346
<!-- markdownlint-enable -->
4447
<!-- END_TF_DOCS -->

0 commit comments

Comments
 (0)