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
373 changes: 183 additions & 190 deletions .github/workflows/automated-deploy-dev.yml

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions .github/workflows/automated-sonarqube-cloud-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ on:
- main
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read
pull-requests: write

jobs:
sonarqube:
name: SonarQube
sonarqube_cloud:
name: SonarQube Cloud Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: SonarQube Scan

- name: SonarQube Cloud Scan
uses: SonarSource/sonarqube-scan-action@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/base-cleanup-lambda-edge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,14 @@ jobs:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- name: Display passed variables
run: |
echo Sandbox name: ${{ inputs.sandbox_name }}
echo Git branch/tag/sha: ${{ inputs.git_ref }}
echo Environment: ${{ inputs.environment }}

- name: Checkout
uses: actions/checkout@v5
with:
repository: 'nhsconnect/national-document-repository-infrastructure'
ref: ${{ inputs.git_ref }}
fetch-depth: '0'

- name: Set up Python 3.11
- name: Setup Python 3.11
uses: actions/setup-python@v6
with:
python-version: 3.11
Expand Down
19 changes: 4 additions & 15 deletions .github/workflows/base-cleanup-workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,10 @@ permissions:
contents: read # This is required for actions/checkout

jobs:
view_action_parameters:
name: View Deploy all input variables
runs-on: ubuntu-latest
steps:
- name: Display client passed variables
run: |
echo Sandbox name: ${{ inputs.sandbox_name }}
echo Git branch/tag/sha: ${{ inputs.git_ref }}
echo Environment: ${{ inputs.environment }}

cleanup_process:
name: Run Cleanup Versions script
name: Run Cleanup Versions Script
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}

steps:
- name: Checkout
uses: actions/checkout@v5
Expand All @@ -48,12 +37,12 @@ jobs:
ref: ${{ inputs.git_ref }}
fetch-depth: '0'

- name: Set up Python 3.11
- name: Setup Python 3.11
uses: actions/setup-python@v6
with:
python-version: 3.11

- name: Make virtual environment
- name: Make Virtual Environment
run: |
python3 -m venv ./venv
./venv/bin/pip3 install --upgrade pip
Expand All @@ -67,6 +56,6 @@ jobs:
aws-region: ${{ vars.AWS_REGION }}
mask-aws-account-id: true

- name: Run Version Cleanup Script
- name: Run Cleanup Versions Script
run: |
./venv/bin/python3 scripts/cleanup_versions.py ${{ inputs.sandbox_name }}
60 changes: 31 additions & 29 deletions .github/workflows/cron-daily-health-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ permissions:

jobs:
set_workspace:
name: Set Workspace (ndrd)
runs-on: ubuntu-latest
outputs:
workspace: ${{ steps.set-output.outputs.workspace }}
Expand All @@ -20,7 +21,8 @@ jobs:
id: set-output
run: echo 'workspace=ndrd' >> $GITHUB_OUTPUT

terraform_process:
terraform_plan_apply:
name: Terraform Plan/Apply (ndrd)
runs-on: ubuntu-latest
environment: development
needs: ['set_workspace']
Expand All @@ -38,68 +40,66 @@ jobs:
aws-region: ${{ vars.AWS_REGION }}
mask-aws-account-id: true

- name: View AWS Role
run: aws sts get-caller-identity

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.13.3
terraform_wrapper: false

- name: Terraform Init
- name: Initialise Terraform
id: init
run: terraform init -backend-config=backend.conf
working-directory: ./infrastructure
shell: bash

- name: Terraform Set Workspace
- name: Select Terraform Workspace
id: workspace
run: terraform workspace select -or-create ${{ needs.set_workspace.outputs.workspace }}
working-directory: ./infrastructure
shell: bash

- name: Terraform Format
- name: Check Terraform Formatting
run: terraform fmt -check
working-directory: ./infrastructure

- name: Terraform Plan
- name: Run Terraform Plan
id: plan
run: |
terraform plan -input=false -no-color -var-file="${{vars.TF_VARS_FILE}}" -out tf.plan
working-directory: ./infrastructure
shell: bash

- name: Terraform Apply
- name: Run Terraform Apply
run: terraform apply -auto-approve -input=false tf.plan
working-directory: ./infrastructure

lambda_test_job:
run_lambda_unit_tests:
name: Run Lambda Unit Tests
uses: nhsconnect/national-document-repository/.github/workflows/base-lambdas-reusable-test.yml@main
with:
python_version: "3.11"
build_branch: main

react_testing_job:
run_ui_unit_tests:
name: Run UI Unit Tests
uses: nhsconnect/national-document-repository/.github/workflows/base-vitest-test.yml@main
with:
build_branch: main

cypress-run-job:
run_cypress_tests:
name: Run Cypress Tests
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v5
with:
repository: nhsconnect/national-document-repository

- name: Cypress install
- name: npm install
run: npm install --legacy-peer-deps
working-directory: ./app

- name: Configure React environment vars
- name: Configure React Environment Vars
env:
ENDPOINT_DOC_STORE_API: http://localhost:3000
AWS_REGION: test region
Expand All @@ -112,18 +112,18 @@ jobs:
./react-environment-config.sh
working-directory: ./app

- name: Cypress build
- name: Cypress Build
uses: cypress-io/github-action@v6
with:
install: false
runTests: false
build: npm run build
working-directory: ./app

- name: Install NPM serve
- name: npm install serve -g
run: npm install serve -g

- name: Cypress run
- name: Run Cypress Tests (Chrome)
uses: cypress-io/github-action@v6
with:
install: false
Expand All @@ -134,23 +134,25 @@ jobs:
CYPRESS_BASE_URL: http://localhost:3000
CYPRESS_grepTags: 'regression'

- uses: actions/upload-artifact@v4
- name: Upload Artifacts (Screenshots)
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots-chrome
path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots
if-no-files-found: ignore

- uses: actions/upload-artifact@v4

- name: Upload Artifacts (Videos)
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-videos-chrome
path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/videos
if-no-files-found: ignore

publish_all_lambda_layers:
name: Publish all Lambda Layers
needs: ['set_workspace', 'terraform_process']
publish_lambda_layers:
name: Publish Lambda Layers
needs: ['set_workspace', 'terraform_plan_apply']
uses: nhsconnect/national-document-repository/.github/workflows/base-lambda-layer-reusable-publish-all.yml@main
with:
build_branch: main
Expand All @@ -160,10 +162,10 @@ jobs:
secrets:
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}

deploy_all_lambdas:
name: Deploy all Lambdas
deploy_lambdas:
name: Deploy Lambdas
uses: nhsconnect/national-document-repository/.github/workflows/base-lambdas-reusable-deploy-all.yml@main
needs: ['set_workspace', 'publish_all_lambda_layers']
needs: ['set_workspace', 'publish_lambda_layers']
with:
build_branch: main
sandbox: ${{ needs.set_workspace.outputs.workspace }}
Expand All @@ -176,7 +178,7 @@ jobs:
deploy_ui:
name: Deploy UI
uses: nhsconnect/national-document-repository/.github/workflows/base-deploy-ui.yml@main
needs: ['terraform_process', 'set_workspace']
needs: ['terraform_plan_apply', 'set_workspace']
with:
build_branch: main
sandbox: ${{ needs.set_workspace.outputs.workspace }}
Expand All @@ -186,8 +188,8 @@ jobs:

destroy_test_environment:
if: always()
name: Destroy the Sandbox Environment from previous job
needs: [ 'set_workspace', 'deploy_ui', 'deploy_all_lambdas' ]
name: Destroy Sandbox (ndrd)
needs: ['set_workspace', 'deploy_ui', 'deploy_lambdas']
uses: ./.github/workflows/tear-down-sandbox.yml
with:
git_ref: main
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/cron-tear-down-sandbox.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Z-CRON: Tear down - Sandbox'
name: 'Z-CRON: Tear down - Sandboxes'

on:
schedule:
Expand All @@ -11,7 +11,7 @@ permissions:

jobs:
destroy_process:
name: Destroy Sandbox Environments
name: Destroy Sandboxes
runs-on: ubuntu-latest
environment: development
steps:
Expand All @@ -28,7 +28,7 @@ jobs:
aws-region: ${{ vars.AWS_REGION }}
mask-aws-account-id: true

- name: Set up Python
- name: Setup Python 3.11
uses: actions/setup-python@v6
with:
python-version: 3.11
Expand Down
19 changes: 7 additions & 12 deletions .github/workflows/cron-tear-down-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
secrets:
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}

cleanup_versions_process:
name: Cleanup Versions Process
cleanup_versions:
name: Cleanup Versions
uses: ./.github/workflows/base-cleanup-workspace.yml
with:
git_ref: main
Expand All @@ -31,16 +31,15 @@ jobs:
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}

terraform_destroy_process:
name: Destroy Test Environment
runs-on: ubuntu-latest
environment: test
needs: [cleanup_versions_process]
needs: [cleanup_versions]
strategy:
matrix:
# Can't use an env var here unfortunately, we will have to update here with new sandbox environments
sandbox-name: [ndr-test]

steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v5
with:
Expand All @@ -54,23 +53,19 @@ jobs:
aws-region: ${{ vars.AWS_REGION }}
mask-aws-account-id: true

- name: View AWS Role
run: aws sts get-caller-identity

# Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.13.3
terraform_wrapper: false

- name: Terraform Init
- name: Initialise Terraform
id: init
run: terraform init -backend-config=backend-test.conf
working-directory: ./infrastructure
shell: bash

- name: Terraform Set Workspace
- name: Select Terraform Workspace
id: workspace
run: terraform workspace select ${{ matrix.sandbox-name }}
working-directory: ./infrastructure
Expand Down Expand Up @@ -101,7 +96,7 @@ jobs:
--region eu-west-2
done

- name: Terraform Destroy
- name: Run Terraform Destroy
id: destroy
run: terraform destroy -auto-approve -var-file="${{ vars.TF_VARS_FILE }}"
working-directory: ./infrastructure
Loading