Skip to content

Commit b148626

Browse files
CCM-12180: Component Tests on pipelines (#334)
* tests * lock
1 parent 3b03d45 commit b148626

78 files changed

Lines changed: 13834 additions & 18145 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.template

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ENVIRONMENT=$ENV_NAME
2+
API_KEY=
3+
HEADERAUTH=
4+
PR_NUMBER=prxx # remove if needs to run against main
5+
NHSD_APIM_TOKEN=
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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@v5
28+
with:
29+
name: terraform-output-${{ inputs.targetComponent }}
30+
31+
- name: Get Node version
32+
id: nodejs_version
33+
shell: bash
34+
run: |
35+
echo "nodejs_version=$(grep "^nodejs\s" .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT
36+
37+
- name: "Repo setup"
38+
uses: ./.github/actions/node-install
39+
with:
40+
node-version: ${{ steps.nodejs_version.outputs.nodejs_version }}
41+
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
42+
43+
- name: "Set PR NUMBER"
44+
shell: bash
45+
run: |
46+
echo "PR_NUMBER=${{ inputs.targetEnvironment }}" >> $GITHUB_ENV
47+
48+
- name: Run test - ${{ inputs.testType }}
49+
shell: bash
50+
run: |
51+
make test-${{ inputs.testType }}

.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+
"component"
3+
]

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

Lines changed: 27 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -35,152 +35,36 @@ on:
3535
required: true
3636
type: string
3737

38-
jobs:
39-
# environment-set-up:
40-
# name: "Environment set up"
41-
# runs-on: ubuntu-latest
42-
# timeout-minutes: 5
43-
# steps:
44-
# - name: "Checkout code"
45-
# uses: actions/checkout@v5
46-
# - name: "Create infractructure"
47-
# run: |
48-
# echo "Creating infractructure..."
49-
# - name: "Update database"
50-
# run: |
51-
# echo "Updating database..."
52-
# - name: "Deploy application"
53-
# run: |
54-
# echo "Deploying application..."
38+
permissions:
39+
id-token: write
40+
contents: read
5541

56-
test-contract:
57-
name: "Contract test"
42+
jobs:
43+
run-acceptance-tests:
44+
name: Run Acceptance Tests
5845
runs-on: ubuntu-latest
59-
# needs: environment-set-up
60-
timeout-minutes: 10
6146
steps:
62-
- name: "Checkout code"
63-
uses: actions/checkout@v5
64-
- name: "Cache node_modules"
65-
uses: actions/cache@v4
47+
- uses: actions/checkout@v5.0.0
48+
49+
- name: "Use Node.js"
50+
uses: actions/setup-node@v6
6651
with:
67-
path: |
68-
**/node_modules
69-
key: ${{ runner.os }}-node-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}
70-
restore-keys: |
71-
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
72-
- name: "Run contract test"
73-
run: |
74-
make test-contract
52+
node-version: "${{ inputs.nodejs_version }}"
53+
registry-url: "https://npm.pkg.github.com"
54+
scope: "@nhsdigital"
55+
56+
- name: Trigger Acceptance Tests
57+
shell: bash
7558
env:
76-
GITHUB_PACKAGES_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77-
- name: "Save result"
59+
APP_PEM_FILE: ${{ secrets.APP_PEM_FILE }}
60+
APP_CLIENT_ID: ${{ secrets.APP_CLIENT_ID }}
61+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7862
run: |
79-
echo "Nothing to save"
80-
81-
# Environment-based tests should run from notify-internal repo, not in public repo
82-
# test-security:
83-
# name: "Security test"
84-
# runs-on: ubuntu-latest
85-
# needs: environment-set-up
86-
# timeout-minutes: 10
87-
# steps:
88-
# - name: "Checkout code"
89-
# uses: actions/checkout@v5
90-
# - name: "Run security test"
91-
# run: |
92-
# make test-security
93-
# - name: "Save result"
94-
# run: |
95-
# echo "Nothing to save"
96-
# test-ui:
97-
# name: "UI test"
98-
# runs-on: ubuntu-latest
99-
# needs: environment-set-up
100-
# timeout-minutes: 10
101-
# steps:
102-
# - name: "Checkout code"
103-
# uses: actions/checkout@v5
104-
# - name: "Run UI test"
105-
# run: |
106-
# make test-ui
107-
# - name: "Save result"
108-
# run: |
109-
# echo "Nothing to save"
110-
# test-ui-performance:
111-
# name: "UI performance test"
112-
# runs-on: ubuntu-latest
113-
# needs: environment-set-up
114-
# timeout-minutes: 10
115-
# steps:
116-
# - name: "Checkout code"
117-
# uses: actions/checkout@v5
118-
# - name: "Run UI performance test"
119-
# run: |
120-
# make test-ui-performance
121-
# - name: "Save result"
122-
# run: |
123-
# echo "Nothing to save"
124-
# test-integration:
125-
# name: "Integration test"
126-
# runs-on: ubuntu-latest
127-
# needs: environment-set-up
128-
# timeout-minutes: 10
129-
# steps:
130-
# - name: "Checkout code"
131-
# uses: actions/checkout@v5
132-
# - name: "Run integration test"
133-
# run: |
134-
# make test-integration
135-
# - name: "Save result"
136-
# run: |
137-
# echo "Nothing to save"
138-
# test-accessibility:
139-
# name: "Accessibility test"
140-
# runs-on: ubuntu-latest
141-
# needs: environment-set-up
142-
# timeout-minutes: 10
143-
# steps:
144-
# - name: "Checkout code"
145-
# uses: actions/checkout@v5
146-
# - name: "Run accessibility test"
147-
# run: |
148-
# make test-accessibility
149-
# - name: "Save result"
150-
# run: |
151-
# echo "Nothing to save"
152-
# test-load:
153-
# name: "Load test"
154-
# runs-on: ubuntu-latest
155-
# needs: environment-set-up
156-
# timeout-minutes: 10
157-
# steps:
158-
# - name: "Checkout code"
159-
# uses: actions/checkout@v5
160-
# - name: "Run load tests"
161-
# run: |
162-
# make test-load
163-
# - name: "Save result"
164-
# run: |
165-
# echo "Nothing to save"
166-
# environment-tear-down:
167-
# name: "Environment tear down"
168-
# runs-on: ubuntu-latest
169-
# needs:
170-
# [
171-
# test-accessibility,
172-
# test-contract,
173-
# test-integration,
174-
# test-load,
175-
# test-security,
176-
# test-ui-performance,
177-
# test-ui,
178-
# ]
179-
# if: always()
180-
# timeout-minutes: 5
181-
# steps:
182-
# - name: "Checkout code"
183-
# uses: actions/checkout@v5
184-
# - name: "Tear down environment"
185-
# run: |
186-
# echo "Tearing down environment..."
63+
.github/scripts/dispatch_internal_repo_workflow.sh \
64+
--targetWorkflow "dispatch-contextual-tests-dynamic-env.yaml" \
65+
--infraRepoName "nhs-notify-supplier-api" \
66+
--releaseVersion "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" \
67+
--overrideProjectName "nhs" \
68+
--targetEnvironment "pr${{ inputs.pr_number }}" \
69+
--targetAccountGroup "nhs-notify-supplier-api-dev" \
70+
--targetComponent "api"

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
# Package is scoped under @org, set registry for that scope
12
@nhsdigital:registry=https://npm.pkg.github.com

docs/assets/diagrams/types.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,27 @@ erDiagram
3131
erDiagram
3232
MI {
3333
string id
34-
string supplierId "ref: Supplier"
35-
string specificationId
36-
string groupId
3734
string lineItem
35+
string timestamp
3836
number quantity
37+
string specificationId
38+
string groupId
3939
number stockRemaining
40+
string supplierId
4041
string createdAt
4142
string updatedAt
43+
number ttl "min: -9007199254740991, max: 9007199254740991"
4244
}
45+
```
46+
47+
## Supplier schema
48+
49+
```mermaid
50+
erDiagram
4351
Supplier {
52+
string id
53+
string name
54+
string apimId
55+
string status "enum: ENABLED, DISABLED"
4456
}
45-
MI }o--|| Supplier : "supplierId"
4657
```

infrastructure/terraform/components/api/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ No requirements.
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 |
1313
| <a name="input_ca_pem_filename"></a> [ca\_pem\_filename](#input\_ca\_pem\_filename) | Filename for the CA truststore file within the s3 bucket | `string` | `null` | no |
14+
| <a name="input_commit_id"></a> [commit\_id](#input\_commit\_id) | The commit to deploy. Must be in the tree for branch\_name | `string` | `"HEAD"` | no |
1415
| <a name="input_component"></a> [component](#input\_component) | The variable encapsulating the name of this component | `string` | `"supapi"` | no |
1516
| <a name="input_core_account_id"></a> [core\_account\_id](#input\_core\_account\_id) | AWS Account ID for Core | `string` | `"000000000000"` | no |
1617
| <a name="input_core_environment"></a> [core\_environment](#input\_core\_environment) | Environment of Core | `string` | `"prod"` | no |
1718
| <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 |
19+
| <a name="input_disable_gateway_execute_endpoint"></a> [disable\_gateway\_execute\_endpoint](#input\_disable\_gateway\_execute\_endpoint) | Disable the execution endpoint for the API Gateway | `bool` | `true` | no |
1820
| <a name="input_enable_backups"></a> [enable\_backups](#input\_enable\_backups) | Enable backups | `bool` | `false` | no |
1921
| <a name="input_environment"></a> [environment](#input\_environment) | The name of the tfscaffold environment | `string` | n/a | yes |
2022
| <a name="input_eventpub_control_plane_bus_arn"></a> [eventpub\_control\_plane\_bus\_arn](#input\_eventpub\_control\_plane\_bus\_arn) | ARN of the EventBridge control plane bus for eventpub | `string` | `""` | no |
@@ -61,6 +63,7 @@ No requirements.
6163
| Name | Description |
6264
|------|-------------|
6365
| <a name="output_api_urll"></a> [api\_urll](#output\_api\_urll) | n/a |
66+
| <a name="output_deployment"></a> [deployment](#output\_deployment) | Deployment details used for post-deployment scripts |
6467
<!-- vale on -->
6568
<!-- markdownlint-enable -->
6669
<!-- END_TF_DOCS -->

infrastructure/terraform/components/api/api_gateway_rest_api.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ resource "aws_api_gateway_rest_api" "main" {
22
name = local.csi
33
body = local.openapi_spec
44
description = "Suppliers API"
5-
disable_execute_api_endpoint = true
5+
disable_execute_api_endpoint = var.disable_gateway_execute_endpoint
66
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
11
output "api_urll" {
22
value = aws_api_gateway_stage.main.invoke_url
33
}
4+
5+
output "deployment" {
6+
description = "Deployment details used for post-deployment scripts"
7+
value = {
8+
aws_region = var.region
9+
aws_account_id = var.aws_account_id
10+
project = var.project
11+
environment = var.environment
12+
group = var.group
13+
component = var.component
14+
commit_id = var.commit_id
15+
}
16+
}

0 commit comments

Comments
 (0)