Skip to content
Open
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
53 changes: 53 additions & 0 deletions .github/actions/acceptance-tests/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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-client-callbacks-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@v4
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:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}

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

- name: Run test - ${{ inputs.testType }}
shell: bash
env:
PROJECT: nhs
COMPONENT: ${{ inputs.targetComponent }}
run: |
make test-${{ inputs.testType }}
24 changes: 24 additions & 0 deletions .github/actions/node-install/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 'npm install and setup'
description: 'Setup node, authenticate github package repository and perform clean npm install'

inputs:
GITHUB_TOKEN:
description: "Token for access to github package registry"
required: true

runs:
using: 'composite'
steps:
- name: 'Use Node.js'
uses: actions/setup-node@v4
with:
node-version-file: '.tool-versions'
registry-url: 'https://npm.pkg.github.com'
scope: '@nhsdigital'

- name: 'Install dependencies'
shell: bash
env:
NODE_AUTH_TOKEN: ${{ inputs.GITHUB_TOKEN }}
run: |
npm ci
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 @@
[
"integration"
]
6 changes: 4 additions & 2 deletions .github/workflows/cicd-1-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,11 @@ jobs:
--overrides "branch_name=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
acceptance-stage: # Recommended maximum execution time is 10 minutes
name: "Acceptance stage"
needs: [metadata, build-stage]
needs: [metadata, build-stage, pr-create-dynamic-environment]
uses: ./.github/workflows/stage-4-acceptance.yaml
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')
if: >-
contains(fromJSON('["success", "skipped"]'), needs.pr-create-dynamic-environment.result) &&
(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'))
with:
build_datetime: "${{ needs.metadata.outputs.build_datetime }}"
build_timestamp: "${{ needs.metadata.outputs.build_timestamp }}"
Expand Down
164 changes: 31 additions & 133 deletions .github/workflows/stage-4-acceptance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,139 +36,37 @@ on:
required: true
type: string

permissions:
id-token: write
contents: read

jobs:
environment-set-up:
name: "Environment set up"
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Create infractructure"
run: |
echo "Creating infractructure..."
- name: "Update database"
run: |
echo "Updating database..."
- name: "Deploy application"
run: |
echo "Deploying application..."
test-contract:
name: "Contract test"
runs-on: ubuntu-latest
needs: environment-set-up
timeout-minutes: 10
steps:
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Run contract test"
run: |
make test-contract
- name: "Save result"
run: |
echo "Nothing to save"
test-security:
name: "Security test"
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@v4
- 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@v4
- 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@v4
- 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@v4
- 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@v4
- 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@v4
- 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@v4
- name: "Tear down environment"
run: |
echo "Tearing down environment..."
- uses: actions/checkout@v4

- name: "Use Node.js"
uses: actions/setup-node@v4
with:
node-version: "${{ inputs.nodejs_version }}"
registry-url: "https://npm.pkg.github.com"
scope: "@nhsdigital"

- name: Trigger Acceptance Tests
shell: bash
env:
APP_PEM_FILE: ${{ secrets.APP_PEM_FILE }}
APP_CLIENT_ID: ${{ secrets.APP_CLIENT_ID }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TARGET_ENVIRONMENT: ${{ inputs.target_environment }}
run: |
.github/scripts/dispatch_internal_repo_workflow.sh \
--targetWorkflow "dispatch-contextual-tests-dynamic-env.yaml" \
--infraRepoName "nhs-notify-client-callbacks" \
--releaseVersion "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" \
--overrideProjectName "nhs" \
--targetEnvironment "$TARGET_ENVIRONMENT" \
--targetAccountGroup "nhs-notify-client-callbacks-dev" \
--targetComponent "callbacks"
1 change: 1 addition & 0 deletions infrastructure/terraform/components/callbacks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

| Name | Description |
|------|-------------|
| <a name="output_deployment"></a> [deployment](#output\_deployment) | Deployment details used for post-deployment scripts |
| <a name="output_mock_webhook_lambda_log_group_name"></a> [mock\_webhook\_lambda\_log\_group\_name](#output\_mock\_webhook\_lambda\_log\_group\_name) | CloudWatch log group name for mock webhook lambda (for integration test queries) |
| <a name="output_mock_webhook_url"></a> [mock\_webhook\_url](#output\_mock\_webhook\_url) | URL endpoint for mock webhook (for TEST\_WEBHOOK\_URL environment variable) |
<!-- vale on -->
Expand Down
16 changes: 15 additions & 1 deletion infrastructure/terraform/components/callbacks/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
# Define the outputs for the component. The outputs may well be referenced by other component in the same or different environments using terraform_remote_state data sources...
##
# Deployment details
##

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
}
}

##
# Mock Webhook Lambda Outputs (test/dev environments only)
Expand Down
Loading
Loading