Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.
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
60 changes: 60 additions & 0 deletions .azuredevops/pipelines/cd-infrastructure-dev-audit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---

name: $(Build.SourceBranchName)-$(Date:yyyyMMdd)_$(Rev:r)

trigger: none
pr: none

pool:
# vmImage: ubuntu-latest
name: private-pool-dev-uks

resources:
repositories:
- repository: dtos-devops-templates
type: github
name: NHSDigital/dtos-devops-templates
ref: f8141ab50ec0f3630044fa0f531952d2dbbd1e85
endpoint: NHSDigital

variables:
- group: DEV_audit_backend
- group: DEV_hub_backend_remote_state
- name: TF_DIRECTORY
value: $(System.DefaultWorkingDirectory)/$(System.TeamProject)/infrastructure/tf-audit
- name: TF_VERSION
value: 1.9.2
- name: TF_PLAN_ARTIFACT
value: tf_plan_audit_DEV
- name: ENVIRONMENT
value: development

stages:
- stage: terraform_plan
displayName: Terraform Plan
condition: eq(variables['Build.Reason'], 'Manual')
variables:
tfVarsFile: environments/$(ENVIRONMENT).tfvars
jobs:
- job: init_and_plan
displayName: Init, plan, store artifact
steps:
- checkout: self
- checkout: dtos-devops-templates
- template: .azuredevops/templates/steps/tf_plan.yaml@dtos-devops-templates

- stage: terraform_apply
displayName: Terraform Apply
dependsOn: [terraform_plan]
condition: and(eq(dependencies.terraform_plan.outputs['init_and_plan.TerraformPlan.changesPresent'], 'true'), eq(variables['Build.Reason'], 'Manual'))
jobs:
- deployment: terraform_apply
displayName: Init, get plan artifact, apply
environment: $(ENVIRONMENT)
strategy:
runOnce:
deploy:
steps:
- checkout: self
- checkout: dtos-devops-templates
- template: .azuredevops/templates/steps/tf_apply.yaml@dtos-devops-templates
61 changes: 61 additions & 0 deletions .azuredevops/pipelines/cd-infrastructure-dev-core.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---

name: $(Build.SourceBranchName)-$(Date:yyyyMMdd)_$(Rev:r)

trigger: none
pr: none

pool:
# vmImage: ubuntu-latest
name: private-pool-dev-uks

resources:
repositories:
- repository: dtos-devops-templates
type: github
name: NHSDigital/dtos-devops-templates
ref: f8141ab50ec0f3630044fa0f531952d2dbbd1e85
endpoint: NHSDigital

variables:
- group: DEV_core_backend
- group: DEV_audit_backend_remote_state
- group: DEV_hub_backend_remote_state
- name: TF_DIRECTORY
value: $(System.DefaultWorkingDirectory)/$(System.TeamProject)/infrastructure/tf-core
- name: TF_VERSION
value: 1.9.2
- name: TF_PLAN_ARTIFACT
value: tf_plan_core_DEV
- name: ENVIRONMENT
value: development

stages:
- stage: terraform_plan
displayName: Terraform Plan
condition: eq(variables['Build.Reason'], 'Manual')
variables:
tfVarsFile: environments/$(ENVIRONMENT).tfvars
jobs:
- job: init_and_plan
displayName: Init, plan, store artifact
steps:
- checkout: self
- checkout: dtos-devops-templates
- template: .azuredevops/templates/steps/tf_plan.yaml@dtos-devops-templates

- stage: terraform_apply
displayName: Terraform Apply
dependsOn: [terraform_plan]
condition: and(eq(dependencies.terraform_plan.outputs['init_and_plan.TerraformPlan.changesPresent'], 'true'), eq(variables['Build.Reason'], 'Manual'))
jobs:
- deployment: terraform_apply
displayName: Init, get plan artifact, apply
environment: $(ENVIRONMENT)
strategy:
runOnce:
deploy:
steps:
- checkout: self
- checkout: dtos-devops-templates
- template: .azuredevops/templates/steps/tf_apply.yaml@dtos-devops-templates
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ trim_trailing_whitespace = true
[*.md]
indent_size = unset

[*.cs]
indent_size = 4

[*.py]
indent_size = 4

Expand Down
62 changes: 48 additions & 14 deletions .github/actions/perform-static-analysis/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,60 @@ description: "Perform static analysis"
inputs:
sonar_organisation_key:
description: "Sonar organisation key, used to identify the project"
required: false
required: true
sonar_project_key:
description: "Sonar project key, used to identify the project"
required: false
required: true
sonar_token:
description: "Sonar token, the API key"
required: false
required: true
runs:
using: "composite"
steps:
- name: "Check prerequisites for performing static analysis"
shell: bash
id: check
run: echo "secret_exist=${{ inputs.sonar_token != '' }}" >> $GITHUB_OUTPUT
- name: "Perform static analysis"
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "zulu" # Alternative distribution options are available.
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Install .NET SDK 9 (or your required version)
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x # C
- name: Cache SonarQube Cloud packages
uses: actions/cache@v4
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarQube Cloud scanner
id: cache-sonar-scanner
uses: actions/cache@v4
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarQube Cloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: bash # Change from powershell to bash
run: |
mkdir -p .sonar/scanner
dotnet tool install dotnet-sonarscanner --tool-path ./.sonar/scanner
dotnet tool install dotnet-coverage --tool-path ./.sonar/scanner
- name: Build and analyze
shell: bash
if: steps.check.outputs.secret_exist == 'true'
run: |
export BRANCH_NAME=${GITHUB_HEAD_REF:-$(echo $GITHUB_REF | sed 's#refs/heads/##')}
export SONAR_ORGANISATION_KEY=${{ inputs.sonar_organisation_key }}
export SONAR_PROJECT_KEY=${{ inputs.sonar_project_key }}
export SONAR_TOKEN=${{ inputs.sonar_token }}
./scripts/reports/perform-static-analysis.sh
echo "${{ inputs.sonar_project_key }}"
echo "${{ inputs.sonar_organisation_key }}"
echo "${{ inputs.sonar_token }}"
./.sonar/scanner/dotnet-sonarscanner begin /k:"${{ inputs.sonar_project_key }}" /o:"${{ inputs.sonar_organisation_key }}" /d:sonar.token="${{ inputs.sonar_token }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths="coverage.xml" /d:sonar.typescript.lcov.reportsPaths="src/web/coverage/lcov.info" /d:sonar.lang.patterns.ts=**/*.ts,**/*.tsx,**/*.cts,**/*.mts /d:sonar.lang.patterns.js=**/*.js,**/*.jsx,**/*.cjs,**/*.mjs,**/*.vue /d:sonar.javascript.enabled=false
dotnet build src/api/ParticipantManager.API.sln
./.sonar/scanner/dotnet-coverage collect -f xml -o coverage.xml dotnet test src/api/ServiceLayer.API.sln
cd src/web
npm ci
npm run test:unit:coverage -- --coverageDirectory=coverage --coverageReporters=lcov
sed -i 's|^SF:|SF:src/web/|g' coverage/lcov.info
cd ../..
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ inputs.sonar_token }}"
5 changes: 5 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ updates:
schedule:
interval: "daily"

- package-ecosystem: "nuget"
directory: "/"
schedule:
interval: "daily"

- package-ecosystem: "npm"
directory: "/"
schedule:
Expand Down
59 changes: 41 additions & 18 deletions .github/workflows/cicd-1-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ on:
types: [opened, reopened]

jobs:

metadata:
name: "Set CI/CD metadata"
name: Set CI/CD metadata
runs-on: ubuntu-latest
timeout-minutes: 1
permissions:
pull-requests: read
outputs:
build_datetime_london: ${{ steps.variables.outputs.build_datetime_london }}
build_datetime: ${{ steps.variables.outputs.build_datetime }}
Expand All @@ -22,11 +25,14 @@ jobs:
nodejs_version: ${{ steps.variables.outputs.nodejs_version }}
python_version: ${{ steps.variables.outputs.python_version }}
terraform_version: ${{ steps.variables.outputs.terraform_version }}
environment_tag: ${{ steps.variables.outputs.environment_tag }}
version: ${{ steps.variables.outputs.version }}
does_pull_request_exist: ${{ steps.pr_exists.outputs.does_pull_request_exist }}
steps:
- name: "Checkout code"
uses: actions/checkout@v4
with:
submodules: 'true'
- name: "Set CI/CD variables"
id: variables
run: |
Expand All @@ -40,10 +46,11 @@ jobs:
echo "python_version=$(grep "^nodejs" .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT
echo "terraform_version=$(grep "^terraform" .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT
echo "version=$(head -n 1 .version 2> /dev/null || echo unknown)" >> $GITHUB_OUTPUT
echo "environment_tag=development" >> $GITHUB_OUTPUT
- name: "Check if pull request exists for this branch"
id: pr_exists
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ github.token }}
run: |
branch_name=${GITHUB_HEAD_REF:-$(echo $GITHUB_REF | sed 's#refs/heads/##')}
echo "Current branch is '$branch_name'"
Expand All @@ -54,7 +61,7 @@ jobs:
echo "Pull request doesn't exist"
echo "does_pull_request_exist=false" >> $GITHUB_OUTPUT
fi
- name: "List variables"
- name: List variables
run: |
export BUILD_DATETIME_LONDON="${{ steps.variables.outputs.build_datetime_london }}"
export BUILD_DATETIME="${{ steps.variables.outputs.build_datetime }}"
Expand All @@ -63,11 +70,12 @@ jobs:
export NODEJS_VERSION="${{ steps.variables.outputs.nodejs_version }}"
export PYTHON_VERSION="${{ steps.variables.outputs.python_version }}"
export TERRAFORM_VERSION="${{ steps.variables.outputs.terraform_version }}"
export ENVIRONMENT_TAG="${{ steps.variables.outputs.environment_tag }}"
export VERSION="${{ steps.variables.outputs.version }}"
export DOES_PULL_REQUEST_EXIST="${{ steps.pr_exists.outputs.does_pull_request_exist }}"
make list-variables
commit-stage: # Recommended maximum execution time is 2 minutes
name: "Commit stage"
name: Commit stage
needs: [metadata]
uses: ./.github/workflows/stage-1-commit.yaml
with:
Expand All @@ -92,23 +100,21 @@ jobs:
terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
version: "${{ needs.metadata.outputs.version }}"
secrets: inherit
build-stage: # Recommended maximum execution time is 3 minutes
name: "Build stage"
needs: [metadata, test-stage]
uses: ./.github/workflows/stage-3-build.yaml
if: needs.metadata.outputs.does_pull_request_exist == 'true' || (github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened'))
build-image-stage: # Recommended maximum execution time is 3 minutes
name: Image build stage
needs: [metadata, commit-stage, test-stage]
uses: NHSDigital/dtos-devops-templates/.github/workflows/stage-3-build-images.yaml@main
if: needs.metadata.outputs.does_pull_request_exist == 'true' || github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened'))
with:
build_datetime: "${{ needs.metadata.outputs.build_datetime }}"
build_timestamp: "${{ needs.metadata.outputs.build_timestamp }}"
build_epoch: "${{ needs.metadata.outputs.build_epoch }}"
nodejs_version: "${{ needs.metadata.outputs.nodejs_version }}"
python_version: "${{ needs.metadata.outputs.python_version }}"
terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
version: "${{ needs.metadata.outputs.version }}"
docker_compose_file: ./compose.yaml
excluded_containers_csv_list: azurite,azurite-setup,sql-database,database-setup
environment_tag: ${{ needs.metadata.outputs.environment_tag }}
function_app_source_code_path: src
project_name: service-layer
secrets: inherit
acceptance-stage: # Recommended maximum execution time is 10 minutes
name: "Acceptance stage"
needs: [metadata, build-stage]
name: Acceptance stage
needs: [metadata, build-image-stage]
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'))
with:
Expand All @@ -120,3 +126,20 @@ jobs:
terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
version: "${{ needs.metadata.outputs.version }}"
secrets: inherit
validate-title-stage:
name: Validate PR title
runs-on: ubuntu-latest
permissions:
pull-requests: write
env:
GITHUB_TOKEN: ${{ github.token }}
if: github.event_name == 'pull_request'
steps:
- uses: amannn/action-semantic-pull-request@v5
id: validate

- uses: thollander/actions-comment-pull-request@v3
if: ${{ failure() && steps.validate.conclusion == 'failure' }}
with:
message: |
Your Pull Request title must meet the conventional commit standards, please see the following documentation - https://www.conventionalcommits.org/en/v1.0.0/#specification
2 changes: 2 additions & 0 deletions .github/workflows/cicd-2-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
steps:
- name: "Checkout code"
uses: actions/checkout@v4
with:
submodules: 'true'
- name: "Set CI/CD variables"
id: variables
run: |
Expand Down
20 changes: 1 addition & 19 deletions .github/workflows/stage-1-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history is needed to scan all commits
submodules: 'true'
- name: "Scan secrets"
uses: ./.github/actions/scan-secrets
check-file-format:
Expand Down Expand Up @@ -105,22 +106,3 @@ jobs:
idp_aws_report_upload_region: "${{ secrets.IDP_AWS_REPORT_UPLOAD_REGION }}"
idp_aws_report_upload_role_name: "${{ secrets.IDP_AWS_REPORT_UPLOAD_ROLE_NAME }}"
idp_aws_report_upload_bucket_endpoint: "${{ secrets.IDP_AWS_REPORT_UPLOAD_BUCKET_ENDPOINT }}"
scan-dependencies:
name: "Scan dependencies"
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
timeout-minutes: 2
steps:
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Scan dependencies"
uses: ./.github/actions/scan-dependencies
with:
build_datetime: "${{ inputs.build_datetime }}"
build_timestamp: "${{ inputs.build_timestamp }}"
idp_aws_report_upload_account_id: "${{ secrets.IDP_AWS_REPORT_UPLOAD_ACCOUNT_ID }}"
idp_aws_report_upload_region: "${{ secrets.IDP_AWS_REPORT_UPLOAD_REGION }}"
idp_aws_report_upload_role_name: "${{ secrets.IDP_AWS_REPORT_UPLOAD_ROLE_NAME }}"
idp_aws_report_upload_bucket_endpoint: "${{ secrets.IDP_AWS_REPORT_UPLOAD_BUCKET_ENDPOINT }}"
6 changes: 6 additions & 0 deletions .github/workflows/stage-2-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ jobs:
steps:
- name: "Checkout code"
uses: actions/checkout@v4
with:
submodules: "true"
- name: "Setup dotnet"
uses: actions/setup-dotnet@v4
with:
dotnet-version: "9.x"
- name: "Run unit test suite"
run: |
make test-unit
Expand Down
Loading
Loading