Skip to content

Commit 9158018

Browse files
merge
2 parents 52513c2 + 3e099d1 commit 9158018

36 files changed

+17135
-11145
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,6 @@ generated_code = true
7070

7171
[/internal/events/**/*.schema.json]
7272
insert_final_newline = unset
73+
74+
[/pact-contracts/pacts/**/*.json]
75+
insert_final_newline = unset
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: "Build OAS Spec"
2+
description: "Build OAS Spec"
3+
4+
inputs:
5+
version:
6+
description: "Version number"
7+
required: true
8+
apimEnv:
9+
description: "APIM environment"
10+
required: true
11+
buildSandbox:
12+
description: "Whether to build the sandbox OAS spec"
13+
required: false
14+
default: false
15+
nodejs_version:
16+
description: "Node.js version, set by the CI/CD pipeline workflow"
17+
required: true
18+
NODE_AUTH_TOKEN:
19+
description: "Token for access to github package registry"
20+
required: true
21+
22+
runs:
23+
using: composite
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
- uses: actions/setup-node@v4
29+
with:
30+
node-version: ${{ inputs.nodejs_version }}
31+
registry-url: 'https://npm.pkg.github.com'
32+
33+
- name: "Cache node_modules"
34+
uses: actions/cache@v4
35+
with:
36+
path: |
37+
**/node_modules
38+
key: ${{ runner.os }}-node-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}
39+
restore-keys: |
40+
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
41+
42+
- name: Npm install
43+
working-directory: .
44+
env:
45+
NODE_AUTH_TOKEN: ${{ inputs.NODE_AUTH_TOKEN }}
46+
run: npm ci
47+
shell: bash
48+
49+
- name: Build ${{ inputs.apimEnv }} oas
50+
working-directory: .
51+
env:
52+
APIM_ENV: ${{ inputs.apimEnv }}
53+
shell: bash
54+
run: |
55+
if [ ${{ env.APIM_ENV }} == "internal-dev-sandbox" ] && [ ${{ inputs.buildSandbox }} == true ]
56+
then
57+
echo "Building sandbox OAS spec"
58+
make build-json-oas-spec APIM_ENV=sandbox
59+
else
60+
echo "Building env specific OAS spec"
61+
make build-json-oas-spec APIM_ENV=${{ env.APIM_ENV }}
62+
fi
63+
64+
- name: Upload API OAS specification artifact
65+
uses: actions/upload-artifact@v4
66+
with:
67+
path: "build"
68+
name: api-oas-specification-${{ inputs.apimEnv }}${{ inputs.version != '' && format('-{0}', inputs.version) || '' }}

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

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,16 @@ 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
31-
NODE_AUTH_TOKEN:
32-
description: "Token for access to github package registry"
33-
required: true
3428

3529
runs:
3630
using: composite
3731

3832
steps:
39-
- name: Checkout
40-
uses: actions/checkout@v4
41-
- uses: actions/setup-node@v4
42-
with:
43-
node-version: ${{ inputs.nodejs_version }}
44-
registry-url: 'https://npm.pkg.github.com'
45-
46-
- name: "Cache node_modules"
47-
uses: actions/cache@v4
33+
- name: Download OAS Spec artifact
34+
uses: actions/download-artifact@v4
4835
with:
49-
path: |
50-
**/node_modules
51-
key: ${{ runner.os }}-node-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}
52-
restore-keys: |
53-
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
54-
55-
- name: Npm install
56-
working-directory: .
57-
env:
58-
NODE_AUTH_TOKEN: ${{ inputs.NODE_AUTH_TOKEN }}
59-
run: npm ci
60-
shell: bash
36+
name: api-oas-specification-${{ inputs.apimEnv }}${{ inputs.version != '' && format('-{0}', inputs.version) || '' }}
37+
path: ./build
6138

6239
- name: Setup Proxy Name and target
6340
shell: bash
@@ -87,21 +64,10 @@ runs:
8764
echo "MTLS_NAME=notify-supplier-mtls-pr$PR_NUMBER" >> $GITHUB_ENV
8865
fi
8966
90-
- name: Build ${{ inputs.apimEnv }} oas
91-
working-directory: .
92-
env:
93-
APIM_ENV: ${{ inputs.apimEnv }}
67+
- name: Set APIM_ENV
9468
shell: bash
9569
run: |
96-
if [ ${{ env.APIM_ENV }} == "internal-dev-sandbox" ] && [ ${{ inputs.buildSandbox }} == true ]
97-
then
98-
echo "Building sandbox OAS spec"
99-
make build-json-oas-spec APIM_ENV=sandbox
100-
else
101-
echo "Building env specific OAS spec"
102-
make build-json-oas-spec APIM_ENV=${{ env.APIM_ENV }}
103-
fi
104-
70+
APIM_ENV="${{ inputs.apimEnv }}"
10571
if [[ $APIM_ENV == *-pr ]]; then
10672
echo "Removing pr suffix from APIM_ENV after building OAS and calling proxygen"
10773
APIM_ENV=$(echo "$APIM_ENV" | sed 's/-pr$//')

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ runs:
5555
run: |
5656
make build VERSION="${{ inputs.version }}"
5757
58-
- name: Upload API OAS specification artifact
59-
uses: actions/upload-artifact@v4
60-
with:
61-
path: "build"
62-
name: api-oas-specification-${{ inputs.version }}
63-
6458
- name: Upload html artifact
6559
uses: actions/upload-artifact@v4
6660
with:
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: 'npm install and setup'
2+
description: 'Setup node, authenticate github package repository and perform clean npm install'
3+
4+
inputs:
5+
node-version:
6+
description: 'Node.js version'
7+
required: true
8+
GITHUB_TOKEN:
9+
description: "Token for access to github package registry"
10+
required: true
11+
12+
runs:
13+
using: 'composite'
14+
steps:
15+
- name: 'Use Node.js'
16+
uses: actions/setup-node@v6
17+
with:
18+
node-version: '${{ inputs.node-version }}'
19+
registry-url: 'https://npm.pkg.github.com'
20+
scope: '@nhsdigital'
21+
22+
- name: 'Install dependencies'
23+
shell: bash
24+
env:
25+
NODE_AUTH_TOKEN: ${{ inputs.GITHUB_TOKEN }}
26+
run: |
27+
npm ci

.github/workflows/manual-proxy-environment-deploy.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ jobs:
7777
echo "ENVIRONMENT=$ENVIRONMENT" >> $GITHUB_ENV
7878
echo "APIM_ENV=$APIM_ENV" >> $GITHUB_ENV
7979
80+
- name: "Build OAS spec"
81+
uses: ./.github/actions/build-oas-spec
82+
with:
83+
apimEnv: "${{ env.APIM_ENV }}"
84+
buildSandbox: ${{ inputs.build_sandbox }}
85+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86+
8087
- name: "Build proxies"
8188
env:
8289
PROXYGEN_API_NAME: nhs-notify-supplier
@@ -90,4 +97,3 @@ jobs:
9097
runId: "${{ github.run_id }}"
9198
buildSandbox: ${{ inputs.build_sandbox }}
9299
releaseVersion: ${{ github.ref_name }}
93-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

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

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ jobs:
5858
restore-keys: |
5959
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
6060
- name: "Repo setup"
61-
env:
62-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63-
run: |
64-
npm ci
61+
uses: ./.github/actions/node-install
62+
with:
63+
node-version: ${{ inputs.nodejs_version }}
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6565
- name: "Generate dependencies"
6666
run: |
6767
npm run generate-dependencies --workspaces --if-present
@@ -82,10 +82,10 @@ jobs:
8282
restore-keys: |
8383
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
8484
- name: "Repo setup"
85-
env:
86-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87-
run: |
88-
npm ci
85+
uses: ./.github/actions/node-install
86+
with:
87+
node-version: ${{ inputs.nodejs_version }}
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8989
- name: "Generate dependencies"
9090
run: |
9191
npm run generate-dependencies --workspaces --if-present
@@ -104,6 +104,37 @@ jobs:
104104
with:
105105
name: code-coverage-report
106106
path: ".reports/lcov.info"
107+
test-pact:
108+
name: "Pact tests"
109+
runs-on: ubuntu-latest
110+
timeout-minutes: 5
111+
env:
112+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113+
permissions:
114+
packages: write
115+
contents: read
116+
steps:
117+
- name: "Checkout code"
118+
uses: actions/checkout@v5
119+
- name: "Cache node_modules"
120+
uses: actions/cache@v4
121+
with:
122+
path: |
123+
**/node_modules
124+
key: ${{ runner.os }}-node-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}
125+
restore-keys: |
126+
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
127+
- name: "Repo setup"
128+
uses: ./.github/actions/node-install
129+
with:
130+
node-version: ${{ inputs.nodejs_version }}
131+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
132+
- name: "Generate dependencies"
133+
run: npm run generate-dependencies --workspaces --if-present
134+
- name: "Run PACT tests"
135+
run: npm run test:pact --workspace tests
136+
- name: Publish Pact Contracts
137+
run: ./scripts/publish-pact-contracts.sh
107138
test-lint:
108139
name: "Linting"
109140
runs-on: ubuntu-latest
@@ -120,10 +151,10 @@ jobs:
120151
restore-keys: |
121152
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
122153
- name: "Repo setup"
123-
env:
124-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125-
run: |
126-
npm ci
154+
uses: ./.github/actions/node-install
155+
with:
156+
node-version: ${{ inputs.nodejs_version }}
157+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127158
- name: "Generate dependencies"
128159
run: |
129160
npm run generate-dependencies --workspaces --if-present
@@ -146,10 +177,10 @@ jobs:
146177
restore-keys: |
147178
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
148179
- name: "Repo setup"
149-
env:
150-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
151-
run: |
152-
npm ci
180+
uses: ./.github/actions/node-install
181+
with:
182+
node-version: ${{ inputs.nodejs_version }}
183+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
153184
- name: "Generate dependencies"
154185
run: |
155186
npm run generate-dependencies --workspaces --if-present

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

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,48 @@ jobs:
5555
version: "${{ inputs.version }}"
5656
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5757

58+
artefact-oas-spec:
59+
name: "Build OAS spec (${{ matrix.apimEnv }})"
60+
if: (github.event_name == 'push' && github.ref == 'refs/heads/main')
61+
runs-on: ubuntu-latest
62+
needs: [artefact-jekyll-docs]
63+
timeout-minutes: 10
64+
strategy:
65+
matrix:
66+
apimEnv: [internal-dev-pr, internal-dev, int, ref, prod]
67+
steps:
68+
- name: "Checkout code"
69+
uses: actions/checkout@v5
70+
- name: "Build OAS spec"
71+
uses: ./.github/actions/build-oas-spec
72+
with:
73+
version: "${{ inputs.version }}"
74+
apimEnv: "${{ matrix.apimEnv }}"
75+
buildSandbox: false
76+
nodejs_version: ${{ inputs.nodejs_version }}
77+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
79+
artefact-oas-spec-sandbox:
80+
name: "Build OAS spec for sandbox"
81+
runs-on: ubuntu-latest
82+
needs: [artefact-jekyll-docs]
83+
timeout-minutes: 10
84+
steps:
85+
- name: "Checkout code"
86+
uses: actions/checkout@v5
87+
- name: "Build proxies"
88+
uses: ./.github/actions/build-oas-spec
89+
with:
90+
version: "${{ inputs.version }}"
91+
apimEnv: "internal-dev-sandbox"
92+
buildSandbox: true
93+
nodejs_version: ${{ inputs.nodejs_version }}
94+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95+
5896
artefact-sdks:
5997
name: "Build SDKs"
6098
runs-on: ubuntu-latest
99+
needs: [artefact-oas-spec]
61100
timeout-minutes: 10
62101
steps:
63102
- name: "Checkout code"
@@ -94,6 +133,7 @@ jobs:
94133
pr-create-dynamic-environment:
95134
name: Create Dynamic Environment
96135
runs-on: ubuntu-latest
136+
if: inputs.pr_number != ''
97137
steps:
98138
- uses: actions/checkout@v5
99139
- name: Trigger dynamic environment creation
@@ -117,7 +157,8 @@ jobs:
117157
artefact-proxies:
118158
name: "Build proxies"
119159
runs-on: ubuntu-latest
120-
needs: [pr-create-dynamic-environment]
160+
if: inputs.pr_number != ''
161+
needs: [artefact-oas-spec-sandbox, pr-create-dynamic-environment]
121162
timeout-minutes: 10
122163
env:
123164
PROXYGEN_API_NAME: nhs-notify-supplier
@@ -136,5 +177,3 @@ jobs:
136177
runId: "${{ github.run_id }}"
137178
buildSandbox: true
138179
releaseVersion: ${{ github.head_ref || github.ref_name }}
139-
nodejs_version: ${{ inputs.nodejs_version }}
140-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)