Skip to content

Commit 340eb95

Browse files
committed
CCM-13038: test publish contracts on package contract change
1 parent b58f81b commit 340eb95

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

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

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ jobs:
5252
- uses: actions/setup-node@v4
5353
with:
5454
node-version: 22
55-
registry-url: 'https://npm.pkg.github.com'
5655
- name: "Cache node_modules"
5756
uses: actions/cache@v4
5857
with:
@@ -112,6 +111,38 @@ jobs:
112111
with:
113112
name: code-coverage-report
114113
path: ".reports/lcov.info"
114+
test-pact:
115+
name: "Pact tests"
116+
runs-on: ubuntu-latest
117+
timeout-minutes: 5
118+
steps:
119+
- name: "Checkout code"
120+
uses: actions/checkout@v5
121+
- uses: actions/setup-node@v4
122+
with:
123+
node-version: 22
124+
- name: "Cache node_modules"
125+
uses: actions/cache@v4
126+
with:
127+
path: |
128+
**/node_modules
129+
key: ${{ runner.os }}-node-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}
130+
restore-keys: |
131+
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
132+
- name: "Repo setup"
133+
env:
134+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135+
run: |
136+
npm ci
137+
- name: "Generate dependencies"
138+
run: |
139+
npm run generate-dependencies --workspaces --if-present
140+
- name: "Run PACT tests"
141+
run: |
142+
npm run test:pact --workspace tests
143+
- name: Publish Pact Contracts
144+
run: |
145+
./scripts/publish-pact-contracts.sh
115146
test-lint:
116147
name: "Linting"
117148
runs-on: ubuntu-latest

infrastructure/terraform/components/api/pre.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# # This script is run before the Terraform apply command.
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.
4+
echo "Running pre.sh"
45

56
npm ci
67

scripts/publish-pact-contracts.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env bash
22

3-
set -euo pipefail
4-
53
published_version=$(npm view @nhsdigital/notify-supplier-api-consumer-contracts --json 2>/dev/null | jq -r '.["dist-tags"].latest')
64

5+
set -euo pipefail
6+
77
# Fail if there are uncommitted changes as this indicates unexpected changes to the contracts
88
git diff --quiet tests/pact-tests
99

@@ -22,4 +22,4 @@ if [[ $local_version == $published_version ]]; then
2222
fi
2323

2424
echo "Local version is different to the latest published version - publishing new version"
25-
npm publish ./pact-contracts
25+
npm pack ./pact-contracts

0 commit comments

Comments
 (0)