Skip to content

Commit

Permalink
ci: setup nock bdc actions flow
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Mar 31, 2022
1 parent a280278 commit 14a30eb
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
41 changes: 37 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,73 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
pact_provider: ['pactflow-example-provider-dredd','pactflow-example-provider-restassured','pactflow-example-provider-postman', 'pactflow-example-provider']
pact_provider:
[
"pactflow-example-provider-dredd",
"pactflow-example-provider-restassured",
"pactflow-example-provider-postman",
"pactflow-example-provider",
],
pact_consumer:
[
"pactflow-example-consumer",
"pactflow-example-consumer-nock"
]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2-beta
with:
node-version: '12'
node-version: "12"
- name: Install for ${{ matrix.pact_provider }}
run: npm i
- name: Test
run: make test
run: [[ ${{ matrix.pact_provider }} = 'pactflow-example-consumer-nock' ]] && make test_nock || make test
env:
PACTICIPANT: ${{ matrix.pact_consumer }}
PACT_PROVIDER: ${{ matrix.pact_provider }}
- name: Publish pacts for ${{ matrix.pact_provider }}
run: GIT_BRANCH=${GIT_REF:11} make publish_pacts
env:
PACTICIPANT: ${{ matrix.pact_consumer }}
PACT_PROVIDER: ${{ matrix.pact_provider }}

# Runs on branches as well, so we know the status of our PRs
can-i-deploy:
runs-on: ubuntu-latest
needs: test
strategy:
matrix:
pact_consumer:
[
"pactflow-example-consumer",
"pactflow-example-consumer-nock"
]
steps:
- uses: actions/checkout@v2
- run: docker pull pactfoundation/pact-cli:latest
- name: Can I deploy?
run: GIT_BRANCH=${GIT_REF:11} make can_i_deploy
env:
PACTICIPANT: ${{ matrix.pact_consumer }}
PACT_PROVIDER: ${{ matrix.pact_provider }}

# Only deploy from master
deploy:
runs-on: ubuntu-latest
needs: can-i-deploy
strategy:
matrix:
pact_consumer:
[
"pactflow-example-consumer",
"pactflow-example-consumer-nock"
]
steps:
- uses: actions/checkout@v2
- run: docker pull pactfoundation/pact-cli:latest
- name: Deploy
run: GIT_BRANCH=${GIT_REF:11} make deploy
if: github.ref == 'refs/heads/master'
if: github.ref == 'refs/heads/master'
env:
PACTICIPANT: ${{ matrix.pact_consumer }}
PACT_PROVIDER: ${{ matrix.pact_provider }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ test: .env

test_nock: .env
@echo "\n========== STAGE: test (nock) ==========\n"
npm run test:nock
PACTICIPANT=${PACTICIPANT_NOCK} npm run test:nock

## =====================
## Deploy tasks
Expand Down
2 changes: 1 addition & 1 deletion src/api.record.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const convertNockToPact = () => {
const scopes = require(path.join(__dirname, "..", nockBack.fixtures, filename))

const pact = {
consumer: { name: "pactflow-example-consumer" },
consumer: { name: "pactflow-example-consumer-nock" },
provider: { name: process.env.PACT_PROVIDER ? process.env.PACT_PROVIDER : 'pactflow-example-provider' },
interactions: [],
metadata: {
Expand Down

0 comments on commit 14a30eb

Please sign in to comment.