Skip to content

Commit aef9500

Browse files
Merge branch 'main' into feature/APIM-tests
2 parents a82bba8 + 4302a12 commit aef9500

File tree

114 files changed

+8067
-2805
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+8067
-2805
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,6 @@ trim_trailing_whitespace = unset
6767
indent_style = unset
6868
indent_size = unset
6969
generated_code = true
70+
71+
[/internal/events/**/*.schema.json]
72+
insert_final_newline = unset

.github/actions/build-proxies/action.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ inputs:
2525
description: "Name of the Component to deploy"
2626
required: true
2727
default: 'api'
28+
nodejs_version:
29+
description: "Node.js version, set by the CI/CD pipeline workflow"
30+
required: true
2831

2932
runs:
3033
using: composite
@@ -34,7 +37,16 @@ runs:
3437
uses: actions/checkout@v4
3538
- uses: actions/setup-node@v4
3639
with:
37-
node-version: 24
40+
node-version: ${{ inputs.nodejs_version }}
41+
42+
- name: "Cache node_modules"
43+
uses: actions/cache@v4
44+
with:
45+
path: |
46+
**/node_modules
47+
key: ${{ runner.os }}-node-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}
48+
restore-keys: |
49+
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
3850
3951
- name: Npm install
4052
working-directory: .

.github/workflows/pr_closed.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,90 @@ jobs:
6262
--targetAccountGroup "nhs-notify-supplier-api-dev" \
6363
--targetComponent "${{ matrix.component }}" \
6464
--terraformAction "apply"
65+
66+
check-event-schemas-version-change:
67+
name: Check for event schemas package version change
68+
needs: check-merge-or-workflow-dispatch
69+
if: needs.check-merge-or-workflow-dispatch.outputs.deploy == 'true'
70+
outputs:
71+
version_changed: ${{ steps.check-version.outputs.version_changed }}
72+
runs-on: ubuntu-latest
73+
permissions:
74+
contents: read
75+
packages: read
76+
steps:
77+
- name: Checkout code
78+
uses: actions/[email protected]
79+
80+
- name: Setup NodeJS
81+
uses: actions/setup-node@v4
82+
with:
83+
node-version: ${{ inputs.nodejs_version }}
84+
85+
- name: check if local version differs from latest published version
86+
id: check-version
87+
run: |
88+
published_version=$(npm view @nhsdigital/nhs-notify-event-schemas-supplier-api --json 2>/dev/null | jq -r '.["dist-tags"].latest // "null"')
89+
echo "Published version: $published_version"
90+
91+
local_version=$(jq -r '.version' internal/events/package.json)
92+
echo "Local version: $local_version"
93+
94+
if [[ $local_version = $published_version ]]; then
95+
echo "Local version is the same as the latest published version - skipping publish"
96+
echo "version_changed=false" >> $GITHUB_OUTPUT
97+
else
98+
echo "Local version is different to the latest published version - publishing new version"
99+
echo "version_changed=true" >> $GITHUB_OUTPUT
100+
fi
101+
102+
test-contract-provider:
103+
name: "Test contracts (provider)"
104+
needs: check-event-schemas-version-change
105+
if: needs.check-event-schemas-version-change.outputs.version_changed == 'true'
106+
runs-on: ubuntu-latest
107+
permissions:
108+
contents: read
109+
packages: read
110+
steps:
111+
- name: "Checkout code"
112+
uses: actions/[email protected]
113+
- name: Setup NodeJS
114+
uses: actions/setup-node@v4
115+
with:
116+
node-version: ${{ inputs.nodejs_version }}
117+
- name: "Install dependencies"
118+
run: npm ci
119+
- name: "Run provider contract tests"
120+
run: make test-contract-provider
121+
env:
122+
GITHUB_PACKAGES_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123+
124+
publish-event-schemas:
125+
name: Publish event schemas package to GitHub package registry
126+
needs:
127+
- check-event-schemas-version-change
128+
- test-contract-provider
129+
if: needs.check-event-schemas-version-change.outputs.version_changed == 'true'
130+
runs-on: ubuntu-latest
131+
permissions:
132+
contents: read
133+
packages: write
134+
135+
steps:
136+
- name: Checkout code
137+
uses: actions/[email protected]
138+
139+
- name: Setup NodeJS
140+
uses: actions/setup-node@v4
141+
with:
142+
node-version: ${{ inputs.nodejs_version }}
143+
registry-url: 'https://npm.pkg.github.com'
144+
145+
- name: Install dependencies
146+
run: npm ci
147+
148+
- name: Publish to GitHub Packages
149+
run: npm publish --workspace internal/events
150+
env:
151+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pr_destroy_dynamic_env.yaml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ concurrency:
88
group: ${{ github.workflow }}-${{ github.ref }}
99
cancel-in-progress: false
1010

11+
permissions:
12+
id-token: write
13+
contents: read
14+
1115
jobs:
12-
create-dynamic-environment:
16+
destroy-dynamic-environment:
1317
name: Destroy Dynamic Environment
1418
runs-on: ubuntu-latest
1519

@@ -32,3 +36,25 @@ jobs:
3236
--terraformAction "destroy" \
3337
--overrideProjectName "nhs" \
3438
--overrideRoleName "nhs-main-acct-supplier-api-github-deploy"
39+
40+
destroy-dynamic-proxy:
41+
name: Destroy Dynamic Proxy
42+
runs-on: ubuntu-latest
43+
44+
steps:
45+
- uses: actions/checkout@v5
46+
47+
- name: Trigger dynamic proxy destruction
48+
env:
49+
APP_CLIENT_ID: ${{ secrets.APP_CLIENT_ID }}
50+
APP_PEM_FILE: ${{ secrets.APP_PEM_FILE }}
51+
shell: bash
52+
run: |
53+
.github/scripts/dispatch_internal_repo_workflow.sh \
54+
--infraRepoName "nhs-notify-supplier-api" \
55+
--releaseVersion "main" \
56+
--targetComponent "api" \
57+
--targetWorkflow "proxy-destroy.yaml" \
58+
--targetEnvironment "pr${{ github.event.number }}" \
59+
--apimEnvironment "internal-dev-sandbox" \
60+
--boundedContext "notify-supplier"

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ jobs:
6868
# Upload the results to GitHub's code scanning dashboard (optional).
6969
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
7070
- name: "Upload to code-scanning"
71-
uses: github/codeql-action/upload-sarif@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v4.31.0
71+
uses: github/codeql-action/upload-sarif@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2
7272
with:
7373
sarif_file: results.sarif

.github/workflows/stage-1-commit.yaml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,94 @@ jobs:
199199
idp_aws_report_upload_region: "${{ secrets.IDP_AWS_REPORT_UPLOAD_REGION }}"
200200
idp_aws_report_upload_role_name: "${{ secrets.IDP_AWS_REPORT_UPLOAD_ROLE_NAME }}"
201201
idp_aws_report_upload_bucket_endpoint: "${{ secrets.IDP_AWS_REPORT_UPLOAD_BUCKET_ENDPOINT }}"
202+
203+
detect-event-schema-package-changes:
204+
name: "Check for changes to event schema package compared to main branch"
205+
runs-on: ubuntu-latest
206+
permissions:
207+
contents: read
208+
outputs:
209+
changed: ${{ steps.check.outputs.changed }}
210+
main_version: ${{ steps.check.outputs.main_version }}
211+
212+
steps:
213+
- name: "Checkout code"
214+
uses: actions/checkout@v4
215+
with:
216+
fetch-depth: 0
217+
218+
- name: Detect package changes and current version
219+
id: check
220+
run: |
221+
git fetch origin main
222+
223+
if git diff --quiet origin/main...HEAD -- internal/events; then
224+
echo "No changes in event schemas package"
225+
echo "changed=false" >> $GITHUB_OUTPUT
226+
else
227+
echo "Changes detected in event schemas"
228+
echo "changed=true" >> $GITHUB_OUTPUT
229+
fi
230+
231+
if content=$(git show origin/main:internal/events/package.json 2>/dev/null); then
232+
version=$(jq -r .version <<< $content);
233+
else
234+
version=null;
235+
fi
236+
237+
echo "Detected package version $version in main branch"
238+
echo "main_version=$version" >> $GITHUB_OUTPUT
239+
240+
# check-schemas-generated:
241+
# name: Check event schemas have been regenerated
242+
# needs: detect-event-schema-package-changes
243+
# if: needs.detect-event-schema-package-changes.outputs.changed == 'true'
244+
# runs-on: ubuntu-latest
245+
# permissions:
246+
# contents: read
247+
# steps:
248+
# - name: "Checkout code"
249+
# uses: actions/checkout@v4
250+
#
251+
# - name: "Cache node_modules"
252+
# uses: actions/cache@v4
253+
# with:
254+
# path: |
255+
# **/node_modules
256+
# key: ${{ runner.os }}-node-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}
257+
# restore-keys: |
258+
# ${{ runner.os }}-node-${{ inputs.nodejs_version }}-
259+
#
260+
# - name: "Re-generate schemas"
261+
# run: |
262+
# npm ci
263+
# npm --workspace internal/events run gen:jsonschema
264+
#
265+
# - name: Check for schema changes
266+
# run: git diff --quiet internal/events/schemas
267+
268+
check-schema-version-change:
269+
name: Check event schema version has been updated
270+
needs: detect-event-schema-package-changes
271+
if: needs.detect-event-schema-package-changes.outputs.changed == 'true'
272+
runs-on: ubuntu-latest
273+
permissions:
274+
contents: read
275+
steps:
276+
- name: Checkout code
277+
uses: actions/checkout@v4
278+
279+
- name: Check schema versions
280+
run: |
281+
source scripts/is_valid_increment.sh
282+
283+
main_version="${{ needs.detect-event-schema-package-changes.outputs.main_version }}"
284+
echo "Main version: ${{ needs.detect-event-schema-package-changes.outputs.main_version }}"
285+
286+
local_version=$(jq -r '.version' internal/events/package.json)
287+
echo "Local version: $local_version"
288+
289+
if ! is_valid_increment "$main_version" "$local_version" ; then
290+
echo "Error: Event Schema package has changed, but new version ($local_version) is not a valid increment from latest version on main branch ($main_version)."
291+
exit 1
292+
fi

.github/workflows/stage-2-test.yaml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ jobs:
4848
steps:
4949
- name: "Checkout code"
5050
uses: actions/checkout@v5
51+
- name: "Cache node_modules"
52+
uses: actions/cache@v4
53+
with:
54+
path: |
55+
**/node_modules
56+
key: ${{ runner.os }}-node-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}
57+
restore-keys: |
58+
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
5159
- name: "Repo setup"
5260
run: |
5361
npm ci
@@ -62,6 +70,14 @@ jobs:
6270
steps:
6371
- name: "Checkout code"
6472
uses: actions/checkout@v5
73+
- name: "Cache node_modules"
74+
uses: actions/cache@v4
75+
with:
76+
path: |
77+
**/node_modules
78+
key: ${{ runner.os }}-node-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}
79+
restore-keys: |
80+
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
6581
- name: "Repo setup"
6682
run: |
6783
npm ci
@@ -90,6 +106,14 @@ jobs:
90106
steps:
91107
- name: "Checkout code"
92108
uses: actions/checkout@v5
109+
- name: "Cache node_modules"
110+
uses: actions/cache@v4
111+
with:
112+
path: |
113+
**/node_modules
114+
key: ${{ runner.os }}-node-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}
115+
restore-keys: |
116+
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
93117
- name: "Repo setup"
94118
run: |
95119
npm ci
@@ -106,6 +130,14 @@ jobs:
106130
steps:
107131
- name: "Checkout code"
108132
uses: actions/checkout@v5
133+
- name: "Cache node_modules"
134+
uses: actions/cache@v4
135+
with:
136+
path: |
137+
**/node_modules
138+
key: ${{ runner.os }}-node-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}
139+
restore-keys: |
140+
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
109141
- name: "Repo setup"
110142
run: |
111143
npm ci
@@ -143,7 +175,7 @@ jobs:
143175
with:
144176
fetch-depth: 0 # Full history is needed to improving relevancy of reporting
145177
- name: "Download coverage report for SONAR"
146-
uses: actions/download-artifact@v5
178+
uses: actions/download-artifact@v6
147179
with:
148180
name: code-coverage-report
149181
- name: "Perform static analysis"

.github/workflows/stage-3-build.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,4 @@ jobs:
109109
runId: "${{ github.run_id }}"
110110
buildSandbox: true
111111
releaseVersion: ${{ github.head_ref || github.ref_name }}
112+
nodejs_version: ${{ inputs.nodejs_version }}

0 commit comments

Comments
 (0)