Skip to content

Commit 82cf3b2

Browse files
bhansell1masl2
andauthored
CCM-13038: LetterRequestPrepared PACT tests (#296)
* CCM-13038: initial * CCM-13038: implement parsing on PACT consumer test * suppress leak warning for test data * CCM-13038: generate correct consumer pacts * CCM-13038: set GITHUB token when reading packages * CCM-13038: use node action * CCM-13038: use node action * CCM-13038: test publish contracts on package contract change * CCM-13038: set _authToken on gpr repo on CI * CCM-13038: pass GITHUB token to action * CCM-13038: ignore EOF lines for contracts * CCM-13038: use branch version of internal repo * CCM-13038: use script in pre.sh * CCM-13038: revert back to main * CCM-13038: redeploy * CCM-13038: update source * CCM-13038: loosen restrictions on dataschema minor and patch * CCM-13038: remove setup-github-token.sh from install action and use passed in node_version * CCM-13038: use NODE_AUTH_TOKEN for pact-test job --------- Co-authored-by: Mark Slowey <[email protected]>
1 parent 5bc4e0e commit 82cf3b2

File tree

18 files changed

+16490
-16234
lines changed

18 files changed

+16490
-16234
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: 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/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

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ dist
3232
/specification/api/components/security/security.yml
3333
/specification/api/components/parameters/authorization/authorization.yml
3434
/scripts/JWT/*.pem
35+
36+
# ignore PACTS
37+
.pacts

infrastructure/terraform/components/api/pre.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
# # It ensures all Node.js dependencies are installed, generates any required dependencies,
33
# # and builds all Lambda functions in the workspace before Terraform provisions infrastructure.
44

5+
echo "Running Pre.sh"
6+
7+
ROOT_DIR="$(git rev-parse --show-toplevel)"
8+
9+
echo "Running set-github-token.sh"
10+
11+
$ROOT_DIR/scripts/set-github-token.sh
12+
13+
echo "Completed."
14+
515
npm ci
616

717
npm run generate-dependencies --workspaces --if-present

0 commit comments

Comments
 (0)