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
33 changes: 31 additions & 2 deletions .github/actions/acceptance-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,36 @@ runs:
run: |
echo "PR_NUMBER=${{ inputs.targetEnvironment }}" >> $GITHUB_ENV

- name: Run test - ${{ inputs.testType }}
- name: Run component tests
shell: bash
run: |
make test-${{ inputs.testType }}
make test-component

- name: Check if e2e tests should run
id: check_e2e
shell: bash
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
run: |
# Extract PR number from environment name (e.g., pr123 -> 123)
if [[ "${{ inputs.targetEnvironment }}" =~ ^pr([0-9]+)$ ]]; then
pr_number="${BASH_REMATCH[1]}"
labels=$(gh pr view "$pr_number" --json labels --jq '.labels[].name' 2>/dev/null || echo "")

if echo "$labels" | grep -Fxq 'deploy-proxy'; then
echo "deploy-proxy label found; e2e tests will run."
echo "run_e2e=true" >> $GITHUB_OUTPUT
else
echo "deploy-proxy label not found; e2e tests will be skipped."
echo "run_e2e=false" >> $GITHUB_OUTPUT
fi
else
echo "Not a PR environment; e2e tests will run."
echo "run_e2e=true" >> $GITHUB_OUTPUT
fi

- name: Run e2e tests
if: steps.check_e2e.outputs.run_e2e == 'true'
shell: bash
run: |
make .internal-dev-test
2 changes: 1 addition & 1 deletion .github/actions/test-types.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[
"component"
"acceptance"
]
22 changes: 22 additions & 0 deletions .github/workflows/cicd-1-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
does_pull_request_exist: ${{ steps.pr_exists.outputs.does_pull_request_exist }}
pr_number: ${{ steps.pr_exists.outputs.pr_number }}
skip_trivy_package: ${{ steps.skip_trivy.outputs.skip_trivy_package }}
deploy_proxy: ${{ steps.deploy_proxy.outputs.deploy_proxy }}
steps:
- name: "Checkout code"
uses: actions/checkout@v5
Expand Down Expand Up @@ -87,6 +88,26 @@ jobs:
else
echo "skip_trivy_package=false" >> $GITHUB_OUTPUT
fi
- name: "Determine if proxy should be deployed"
id: deploy_proxy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.pr_exists.outputs.pr_number }}
run: |
if [[ -z "$PR_NUMBER" ]]; then
echo "No pull request detected; proxy deployment will run."
echo "deploy_proxy=true" >> $GITHUB_OUTPUT
exit 0
fi

labels=$(gh pr view "$PR_NUMBER" --json labels --jq '.labels[].name')
echo "Labels on PR #$PR_NUMBER: $labels"

if echo "$labels" | grep -Fxq 'deploy-proxy'; then
echo "deploy_proxy=true" >> $GITHUB_OUTPUT
else
echo "deploy_proxy=false" >> $GITHUB_OUTPUT
fi
- name: "List variables"
run: |
export BUILD_DATETIME_LONDON="${{ steps.variables.outputs.build_datetime_london }}"
Expand Down Expand Up @@ -141,6 +162,7 @@ jobs:
terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
version: "${{ needs.metadata.outputs.version }}"
pr_number: "${{ needs.metadata.outputs.pr_number }}"
deploy_proxy: "${{ needs.metadata.outputs.deploy_proxy }}"
secrets: inherit
acceptance-stage: # Recommended maximum execution time is 10 minutes
name: "Acceptance stage"
Expand Down
17 changes: 12 additions & 5 deletions .github/workflows/stage-3-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ on:
description: "PR Number if it exists"
required: false
type: string
deploy_proxy:
description: "True if the APIM proxy should be deployed"
required: true
type: string

permissions:
id-token: write # This is required for requesting the JWT
Expand Down Expand Up @@ -133,9 +137,13 @@ jobs:
pr-create-dynamic-environment:
name: Create Dynamic Environment
runs-on: ubuntu-latest
if: inputs.pr_number != ''
outputs:
environment_name: ${{ steps.set-environment.outputs.environment_name }}
steps:
- uses: actions/checkout@v5
- name: Set environment name
id: set-environment
run: echo "environment_name=${{ inputs.pr_number != '' && format('pr{0}', inputs.pr_number) || 'main' }}" >> $GITHUB_OUTPUT
- name: Trigger dynamic environment creation
env:
APP_CLIENT_ID: ${{ secrets.APP_CLIENT_ID }}
Expand All @@ -148,7 +156,7 @@ jobs:
--infraRepoName "$(echo ${{ github.repository }} | cut -d'/' -f2)" \
--releaseVersion ${{ github.head_ref || github.ref_name }} \
--targetWorkflow "dispatch-deploy-dynamic-env.yaml" \
--targetEnvironment "pr${PR_NUMBER}" \
--targetEnvironment "${{ steps.set-environment.outputs.environment_name }}" \
--targetComponent "api" \
--targetAccountGroup "nhs-notify-supplier-api-dev" \
--terraformAction "apply" \
Expand All @@ -157,12 +165,11 @@ jobs:
artefact-proxies:
name: "Build proxies"
runs-on: ubuntu-latest
if: inputs.pr_number != ''
if: inputs.deploy_proxy == 'true'
needs: [artefact-oas-spec-sandbox, pr-create-dynamic-environment]
timeout-minutes: 10
env:
PROXYGEN_API_NAME: nhs-notify-supplier
PR_NUMBER: ${{ inputs.pr_number }}
APP_CLIENT_ID: ${{ secrets.APP_CLIENT_ID }}
APP_PEM_FILE: ${{ secrets.APP_PEM_FILE }}
steps:
Expand All @@ -172,7 +179,7 @@ jobs:
uses: ./.github/actions/build-proxies
with:
version: "${{ inputs.version }}"
environment: ${{ inputs.pr_number != '' && format('pr{0}', inputs.pr_number) || 'main' }}
environment: ${{ needs.pr-create-dynamic-environment.outputs.environment_name }}
apimEnv: "internal-dev-sandbox"
runId: "${{ github.run_id }}"
buildSandbox: true
Expand Down
6 changes: 4 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@
"name": "nhs-notify-supplier-api",
"overrides": {
"axios": "^1.13.5",
"fast-xml-parser": "^5.3.4",
"@isaacs/brace-expansion": "^5.0.1",
"pretty-format": {
"react-is": "19.0.0"
},
"react": "^19.0.0",
"fast-xml-parser": "^5.3.4"
"fast-xml-parser": "^5.3.6"

},
"scripts": {
Expand Down
Loading