Skip to content

Commit

Permalink
Merge pull request #12 from pactflow/deps/pact_go_v2
Browse files Browse the repository at this point in the history
Deps/pact go v2
  • Loading branch information
YOU54F authored Sep 27, 2024
2 parents b0639e7 + ca2cbff commit f41d994
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 147 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '^1.14.1'
- name: install ruby standalone
run: make install_ruby_standalone
- name: install pact-go shared libraries
run: make install
- name: Test
run: GIT_BRANCH=${GITHUB_REF:11} make test

Expand All @@ -31,7 +31,7 @@ jobs:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: docker pull pactfoundation/pact-cli:latest
- name: Can I deploy?
run: GIT_BRANCH=${GITHUB_REF:11} make can_i_deploy
Expand All @@ -41,7 +41,7 @@ jobs:
runs-on: ubuntu-latest
needs: can-i-deploy
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: docker pull pactfoundation/pact-cli:latest
- name: Deploy
run: GIT_BRANCH=${GITHUB_REF:11} make deploy
Expand Down
20 changes: 11 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
PACTICIPANT := "pactflow-example-provider-golang"
WEBHOOK_UUID := "c76b601e-d66a-4eb1-88a4-6ebc50c0df8b"
PACT_CLI="docker run --rm -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL -e PACT_BROKER_TOKEN pactfoundation/pact-cli:latest"
PACT_GO_VERSION=2.0.8
PACT_DOWNLOAD_DIR=/tmp
ifeq ($(OS),Windows_NT)
PACT_DOWNLOAD_DIR=$$TMP
endif

# Only deploy from master
ifeq ($(GIT_BRANCH),master)
Expand Down Expand Up @@ -48,7 +53,7 @@ test: .env
## Deploy tasks
## =====================

deploy: deploy_app tag record_deployment
deploy: deploy_app record_deployment

no_deploy:
@echo "Not deploying as not on master branch"
Expand All @@ -65,13 +70,6 @@ can_i_deploy: .env
deploy_app:
@echo "Deploying to prod"

tag: .env
@"${PACT_CLI}" broker create-version-tag \
--pacticipant ${PACTICIPANT} \
--version ${GIT_COMMIT} \
--auto-create-version \
--tag ${GIT_BRANCH}

record_deployment: .env
@"${PACT_CLI}" broker record-deployment --pacticipant ${PACTICIPANT} --version ${GIT_COMMIT} --environment production

Expand Down Expand Up @@ -111,7 +109,11 @@ test_pact_changed_webhook:
.env:
touch .env

install_ruby_standalone:
install:
go install github.com/pact-foundation/pact-go/v2@v$(PACT_GO_VERSION)
pact-go -l DEBUG install --libDir $(PACT_DOWNLOAD_DIR);

install_cli:
@if [ ! -d pact/bin ]; then\
echo "--- 🐿 Installing Pact CLI dependencies"; \
cd /tmp; \
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ It is using a public tenant on PactFlow, which you can access [here](https://tes

## Pre-Requisites

Ruby standalone binaries must be installed, the following script will download them and add them to your system PATH
In order to use pact-go v2, you must install pact ffi system libraries to your machine.

```
make install_ruby_standalone
make install
```

In order to use the pact cli tools, which interact with a pact broker, the Ruby standalone binaries must be installed, the following script will download them and add them to your system PATH

```
make install_cli
```

## Usage
Expand Down
34 changes: 32 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,38 @@
module github.com/pactflow/example-provider-golang

go 1.15
go 1.21

require (
github.com/gin-gonic/gin v1.7.2
github.com/pact-foundation/pact-go v1.6.9
github.com/pact-foundation/pact-go/v2 v2.0.8
)

require (
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.13.0 // indirect
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/go-playground/validator/v10 v10.4.1 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/leodido/go-urn v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/ugorji/go/codec v1.1.7 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect
google.golang.org/grpc v1.66.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Loading

0 comments on commit f41d994

Please sign in to comment.