Skip to content

Commit

Permalink
ci: test
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Oct 14, 2024
1 parent 7f343a4 commit de0f0dd
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 8 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Build

env:
PACT_BROKER_WEBHOOK_HOST_WHITELIST: localhost

on:
push:
workflow_dispatch:
Expand All @@ -14,8 +17,11 @@ jobs:
node-version: '20'
- run: docker compose up -d
- run: npm i
- run: npm run start --prefix broker-webhook &
- run: nohup npm run start --prefix broker-webhook > out.log 2>&1 &
- run: npm run create-webhook --prefix broker-webhook
- run: npm test --prefix consumer
- run: npm run pact:publish --prefix consumer
- run: sleep 30
- run: |
npm run pact:publish --prefix consumer > publish.out
curl "$(cat publish.out | grep "View logs at" | sed -E 's/.*View logs at \x1b\[35m(.*)\x1b\[0m/\1/')" --user pact_workshop:pact_workshop -H "Accept: */*"
- run: sleep 15
- run: cat out.log
2 changes: 1 addition & 1 deletion broker-webhook/broker-create-body.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
],
"request": {
"method": "POST",
"url": "http://host.docker.internal:9090",
"url": "http://localhost:9090",
"headers": {
"Content-Type": "application/json"
},
Expand Down
31 changes: 28 additions & 3 deletions broker-webhook/create_webhook.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
curl http://localhost:8000/webhooks \
-X POST --user pact_workshop:pact_workshop \
-H "Content-Type: application/json" -d @broker-create-body.json -v
#!/bin/bash
set -e

json_payload='{
"events": [
{
"name": "contract_content_changed"
}
],
"request": {
"method": "POST",
"url": "'http://"${PACT_BROKER_WEBHOOK_HOST_WHITELIST:-host.docker.internal}":9090'",
"headers": {
"Content-Type": "application/json"
},
"body": {
"state": "${pactbroker.githubVerificationStatus}",
"description": "Pact Verification Tests ${pactbroker.providerVersionTags}",
"context": "${pactbroker.providerName}",
"target_url": "${pactbroker.verificationResultUrl}"
}
}
}'

echo $json_payload
curl http://localhost:8000/webhooks/204430af-f8c8-4feb-8135-f027df8ecf34 \
-X PUT --user pact_workshop:pact_workshop \
-H "Content-Type: application/json" -d "${json_payload}" -v
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ services:
PACT_BROKER_DATABASE_CONNECT_MAX_RETRIES: "10"
PACT_BROKER_PUBLIC_HEARTBEAT: "true"
PACT_BROKER_WEBHOOK_SCHEME_WHITELIST: http
PACT_BROKER_WEBHOOK_HOST_WHITELIST: host.docker.internal
PACT_BROKER_WEBHOOK_HOST_WHITELIST: ${PACT_BROKER_WEBHOOK_HOST_WHITELIST:-host.docker.internal}

0 comments on commit de0f0dd

Please sign in to comment.