Skip to content

Commit 178ba2c

Browse files
authored
[WM-2016] CBAS contract tests (#4155)
1 parent 12e24ef commit 178ba2c

File tree

7 files changed

+991
-0
lines changed

7 files changed

+991
-0
lines changed

.github/workflows/publish-pacts.yaml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish Pacts
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ dev ]
7+
8+
jobs:
9+
setup-and-test:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
pact-b64: ${{ steps.encode.outputs.pact-b64 }}
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Set up Node
16+
uses: actions/setup-node@v3
17+
with:
18+
node-version: 18
19+
20+
- name: Install dependencies
21+
run: |
22+
yarn install
23+
24+
- name: Run tests
25+
run: yarn test Cbas.test.js # As of now, this is the only contract test file in terra-ui.
26+
# When another test file is added, a naming convention for contract tests should be established,
27+
# so that contract tests can be run in isolation.
28+
29+
- name: Encode the pact as non-breaking base 64 string
30+
id: encode
31+
env:
32+
PACT_FULL_PATH: 'pacts/terra-ui-cbas.json' # Currently, workflows are limited to a single Pact file (see WM-1858).
33+
run: |
34+
NON_BREAKING_B64=$(cat $PACT_FULL_PATH | base64 -w 0)
35+
echo "pact-b64=${NON_BREAKING_B64}" >> $GITHUB_OUTPUT
36+
echo $NON_BREAKING_B64
37+
38+
publish-pact-workflow:
39+
runs-on: ubuntu-latest
40+
needs: [setup-and-test]
41+
permissions:
42+
contents: 'read'
43+
id-token: 'write'
44+
steps:
45+
- name: Publish Pact contracts
46+
uses: aurelien-baudet/workflow-dispatch@93e95b157d791ae7f42aef8f8a0d3d723eba1c31 #commit sha for v2.1.1
47+
with:
48+
workflow: publish-contracts.yaml
49+
repo: broadinstitute/terra-github-workflows
50+
ref: refs/heads/dev
51+
token: ${{ secrets.BROADBOT_TOKEN}} # github token for access to kick off a job in the private repo
52+
inputs: '{ "pact-b64": "${{ needs.setup-and-test.outputs.pact-b64 }}", "repo-owner": "DataBiosphere", "repo-name": "terra-ui", "repo-branch": "dev" }'

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ node_modules
66
# testing
77
/coverage
88
packages/*/coverage
9+
/pacts
910

1011
# production
1112
/build

.pnp.cjs

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
"save-build-info": "echo \\{\\\"gitRevision\\\": \\\"$(git rev-parse HEAD)\\\", \\\"buildTimestamp\\\": $(date -u '+%s000')\\} > public/build-info.json"
8585
},
8686
"devDependencies": {
87+
"setimmediate": "^1.0.5",
8788
"@axe-core/react": "^4.6.1",
8889
"@pact-foundation/pact": "10.2.2",
8990
"@terra-ui-packages/test-utils": "*",

0 commit comments

Comments
 (0)