Skip to content

Commit 6cd613f

Browse files
committed
ci(circleci): setup pact can-i-use
1 parent 1b61633 commit 6cd613f

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

.circleci/config.yml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,31 @@ jobs:
123123
version_path: /tmp/workspace
124124
- run:
125125
name: Publish production pacts to broker
126-
command: cd /tmp/workspace && npx pact-broker publish pacts --consumer-app-version=$VERSION --auto-detect-version-properties --broker-base-url=${PACT_BROKER_BASE_URL}
126+
command: |
127+
cd /tmp/workspace && \
128+
npx pact-broker publish pacts \
129+
--consumer-app-version=$VERSION \
130+
--auto-detect-version-properties \
131+
--broker-base-url=${PACT_BROKER_BASE_URL}
132+
# - jobstatus
133+
134+
pact-can-i-use:
135+
executor: build-executor
136+
steps:
137+
- attach_workspace:
138+
at: /tmp/workspace
139+
- setup_environment:
140+
version_path: /tmp/workspace
141+
- run:
142+
name: Verify pacts
143+
command: |
144+
cd /tmp/workspace && \
145+
npx pact-broker can-i-deploy \
146+
--pacticipant w3w-node-wrapper \
147+
--broker-username ${PACT_BROKER_USERNAME} \
148+
--broker-password ${PACT_BROKER_PASSWORD} \
149+
--broker-base-url ${PACT_BROKER_BASE_URL} \
150+
--latest
127151
# - jobstatus
128152

129153
npm-publish:
@@ -175,11 +199,20 @@ workflows:
175199
filters:
176200
branches:
177201
only: master
202+
- pact-can-i-use:
203+
context:
204+
- org-global
205+
- w3w-pact
206+
requires:
207+
- pact-publish-prod
208+
filters:
209+
branches:
210+
only: master
178211
- npm-publish:
179212
context:
180213
- org-global
181214
requires:
182-
- build_test
215+
- pact-can-i-use
183216
filters:
184217
branches:
185218
only: master

test/client/autosuggest-session.spec.ts renamed to test/client/autosuggest-session.pact.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ describe('Autosuggest Session Pact', () => {
3939
).getValue() as never;
4040
const apiVersion = ApiVersion.Version3;
4141
const provider = PactUtils.createPact({
42-
consumer: 'w3w-node-wrapper',
4342
provider: 'api-server',
4443
});
4544

test/pact-utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import { Pact, RequestOptions, ResponseOptions } from '@pact-foundation/pact';
22
import { PactOptions } from '@pact-foundation/pact/src/dsl/options';
3-
import path from 'path';
3+
import * as path from 'path';
44

55
/**
66
* Create a pre-configured Pact provider
77
*/
8-
function createPact(opts: PactOptions) {
8+
function createPact(opts: Omit<PactOptions, 'consumer'>) {
99
return new Pact({
1010
log: path.resolve(process.cwd(), 'logs', 'pact.log'),
1111
dir: path.resolve(process.cwd(), 'pacts'),
1212
logLevel: 'info',
1313
pactfileWriteMode: 'overwrite',
1414
port: 9000,
15+
consumer: 'w3w-node-wrapper',
1516
...opts,
1617
});
1718
}

0 commit comments

Comments
 (0)