Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ENVIRONMENT=$ENV_NAME
API_KEY=
HEADERAUTH=
PR_NUMBER=prxx # remove if needs to run against main
NHSD_APIM_TOKEN=
51 changes: 51 additions & 0 deletions .github/actions/acceptance-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Acceptance tests
description: "Run acceptance tests for this repo"

inputs:
testType:
description: Type of test to run
required: true

targetEnvironment:
description: Name of the environment under test
required: true

targetAccountGroup:
description: Name of the account group under test
default: nhs-notify-template-management-dev
required: true

targetComponent:
description: Name of the component under test
required: true

runs:
using: "composite"

steps:
- name: Fetch terraform output
uses: actions/download-artifact@v5
with:
name: terraform-output-${{ inputs.targetComponent }}

- name: Get Node version
id: nodejs_version
shell: bash
run: |
echo "nodejs_version=$(grep "^nodejs\s" .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT

- name: "Repo setup"
uses: ./.github/actions/node-install
with:
node-version: ${{ steps.nodejs_version.outputs.nodejs_version }}
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}

- name: "Set PR NUMBER"
shell: bash
run: |
echo "PR_NUMBER=${{ inputs.targetEnvironment }}" >> $GITHUB_ENV

- name: Run test - ${{ inputs.testType }}
shell: bash
run: |
make test-${{ inputs.testType }}
3 changes: 3 additions & 0 deletions .github/actions/test-types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
"component"
]
170 changes: 27 additions & 143 deletions .github/workflows/stage-4-acceptance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,152 +35,36 @@ on:
required: true
type: string

jobs:
# environment-set-up:
# name: "Environment set up"
# runs-on: ubuntu-latest
# timeout-minutes: 5
# steps:
# - name: "Checkout code"
# uses: actions/checkout@v5
# - name: "Create infractructure"
# run: |
# echo "Creating infractructure..."
# - name: "Update database"
# run: |
# echo "Updating database..."
# - name: "Deploy application"
# run: |
# echo "Deploying application..."
permissions:
id-token: write
contents: read

test-contract:
name: "Contract test"
jobs:
run-acceptance-tests:
name: Run Acceptance Tests
runs-on: ubuntu-latest
# needs: environment-set-up
timeout-minutes: 10
steps:
- name: "Checkout code"
uses: actions/checkout@v5
- name: "Cache node_modules"
uses: actions/cache@v4
- uses: actions/checkout@v5.0.0

- name: "Use Node.js"
uses: actions/setup-node@v6
with:
path: |
**/node_modules
key: ${{ runner.os }}-node-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
- name: "Run contract test"
run: |
make test-contract
node-version: "${{ inputs.nodejs_version }}"
registry-url: "https://npm.pkg.github.com"
scope: "@nhsdigital"

- name: Trigger Acceptance Tests
shell: bash
env:
GITHUB_PACKAGES_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Save result"
APP_PEM_FILE: ${{ secrets.APP_PEM_FILE }}
APP_CLIENT_ID: ${{ secrets.APP_CLIENT_ID }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Nothing to save"

# Environment-based tests should run from notify-internal repo, not in public repo
# test-security:
# name: "Security test"
# runs-on: ubuntu-latest
# needs: environment-set-up
# timeout-minutes: 10
# steps:
# - name: "Checkout code"
# uses: actions/checkout@v5
# - name: "Run security test"
# run: |
# make test-security
# - name: "Save result"
# run: |
# echo "Nothing to save"
# test-ui:
# name: "UI test"
# runs-on: ubuntu-latest
# needs: environment-set-up
# timeout-minutes: 10
# steps:
# - name: "Checkout code"
# uses: actions/checkout@v5
# - name: "Run UI test"
# run: |
# make test-ui
# - name: "Save result"
# run: |
# echo "Nothing to save"
# test-ui-performance:
# name: "UI performance test"
# runs-on: ubuntu-latest
# needs: environment-set-up
# timeout-minutes: 10
# steps:
# - name: "Checkout code"
# uses: actions/checkout@v5
# - name: "Run UI performance test"
# run: |
# make test-ui-performance
# - name: "Save result"
# run: |
# echo "Nothing to save"
# test-integration:
# name: "Integration test"
# runs-on: ubuntu-latest
# needs: environment-set-up
# timeout-minutes: 10
# steps:
# - name: "Checkout code"
# uses: actions/checkout@v5
# - name: "Run integration test"
# run: |
# make test-integration
# - name: "Save result"
# run: |
# echo "Nothing to save"
# test-accessibility:
# name: "Accessibility test"
# runs-on: ubuntu-latest
# needs: environment-set-up
# timeout-minutes: 10
# steps:
# - name: "Checkout code"
# uses: actions/checkout@v5
# - name: "Run accessibility test"
# run: |
# make test-accessibility
# - name: "Save result"
# run: |
# echo "Nothing to save"
# test-load:
# name: "Load test"
# runs-on: ubuntu-latest
# needs: environment-set-up
# timeout-minutes: 10
# steps:
# - name: "Checkout code"
# uses: actions/checkout@v5
# - name: "Run load tests"
# run: |
# make test-load
# - name: "Save result"
# run: |
# echo "Nothing to save"
# environment-tear-down:
# name: "Environment tear down"
# runs-on: ubuntu-latest
# needs:
# [
# test-accessibility,
# test-contract,
# test-integration,
# test-load,
# test-security,
# test-ui-performance,
# test-ui,
# ]
# if: always()
# timeout-minutes: 5
# steps:
# - name: "Checkout code"
# uses: actions/checkout@v5
# - name: "Tear down environment"
# run: |
# echo "Tearing down environment..."
.github/scripts/dispatch_internal_repo_workflow.sh \
--targetWorkflow "dispatch-contextual-tests-dynamic-env.yaml" \
--infraRepoName "nhs-notify-supplier-api" \
--releaseVersion "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" \
--overrideProjectName "nhs" \
--targetEnvironment "pr${{ inputs.pr_number }}" \
--targetAccountGroup "nhs-notify-supplier-api-dev" \
--targetComponent "api"
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# Package is scoped under @org, set registry for that scope
@nhsdigital:registry=https://npm.pkg.github.com
19 changes: 15 additions & 4 deletions docs/assets/diagrams/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,27 @@ erDiagram
erDiagram
MI {
string id
string supplierId "ref: Supplier"
string specificationId
string groupId
string lineItem
string timestamp
number quantity
string specificationId
string groupId
number stockRemaining
string supplierId
string createdAt
string updatedAt
number ttl "min: -9007199254740991, max: 9007199254740991"
}
```

## Supplier schema

```mermaid
erDiagram
Supplier {
string id
string name
string apimId
string status "enum: ENABLED, DISABLED"
}
MI }o--|| Supplier : "supplierId"
```
3 changes: 3 additions & 0 deletions infrastructure/terraform/components/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ No requirements.
|------|-------------|------|---------|:--------:|
| <a name="input_aws_account_id"></a> [aws\_account\_id](#input\_aws\_account\_id) | The AWS Account ID (numeric) | `string` | n/a | yes |
| <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 |
| <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 |
| <a name="input_component"></a> [component](#input\_component) | The variable encapsulating the name of this component | `string` | `"supapi"` | no |
| <a name="input_core_account_id"></a> [core\_account\_id](#input\_core\_account\_id) | AWS Account ID for Core | `string` | `"000000000000"` | no |
| <a name="input_core_environment"></a> [core\_environment](#input\_core\_environment) | Environment of Core | `string` | `"prod"` | no |
| <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 |
| <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 |
| <a name="input_enable_backups"></a> [enable\_backups](#input\_enable\_backups) | Enable backups | `bool` | `false` | no |
| <a name="input_environment"></a> [environment](#input\_environment) | The name of the tfscaffold environment | `string` | n/a | yes |
| <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 |
Expand Down Expand Up @@ -61,6 +63,7 @@ No requirements.
| Name | Description |
|------|-------------|
| <a name="output_api_urll"></a> [api\_urll](#output\_api\_urll) | n/a |
| <a name="output_deployment"></a> [deployment](#output\_deployment) | Deployment details used for post-deployment scripts |
<!-- vale on -->
<!-- markdownlint-enable -->
<!-- END_TF_DOCS -->
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ resource "aws_api_gateway_rest_api" "main" {
name = local.csi
body = local.openapi_spec
description = "Suppliers API"
disable_execute_api_endpoint = true
disable_execute_api_endpoint = var.disable_gateway_execute_endpoint
}
13 changes: 13 additions & 0 deletions infrastructure/terraform/components/api/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
output "api_urll" {
value = aws_api_gateway_stage.main.invoke_url
}

output "deployment" {
description = "Deployment details used for post-deployment scripts"
value = {
aws_region = var.region
aws_account_id = var.aws_account_id
project = var.project
environment = var.environment
group = var.group
component = var.component
commit_id = var.commit_id
}
}
Loading
Loading