Skip to content

Commit

Permalink
chore(docker): Update Dockerfile to support pact-go v2 and test in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Jul 4, 2024
1 parent f3b61a7 commit 19ca6ef
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 14 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,21 @@ jobs:
path: ~/.pact/plugins/**/plugin.log
if: ${{ always() }}

test-containers:
runs-on: ubuntu-latest
name: ${{ matrix.go-version }}-test-container
strategy:
fail-fast: false
matrix:
go-version: ["1.20", "1.21", "1.22"]
steps:
- uses: actions/checkout@v4

- name: Test dockerfile
run: make docker_test_all

finish:
needs: test
needs: [test,test-containers]
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
Expand Down
13 changes: 5 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
FROM golang:1.22.5

# Install pact ruby standalone binaries
RUN curl -LO https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v2.0.3/pact-2.0.3-linux-x86_64.tar.gz; \
tar -C /usr/local -xzf pact-2.0.3-linux-x86_64.tar.gz; \
rm pact-2.0.3-linux-x86_64.tar.gz

ENV PATH /usr/local/pact/bin:$PATH
ARG VERSION=latest
FROM golang:${VERSION}

RUN apt-get update && apt-get install -y openjdk-17-jre file protobuf-compiler
COPY . /go/src/github.com/pact-foundation/pact-go

WORKDIR /go/src/github.com/pact-foundation/pact-go

CMD ["make", "test"]
25 changes: 24 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PLUGIN_PACT_PROTOBUF_VERSION=0.3.15
PLUGIN_PACT_CSV_VERSION=0.0.6
PLUGIN_PACT_MATT_VERSION=0.1.1
PLUGIN_PACT_AVRO_VERSION=0.0.5

GO_VERSION?=1.22
ci:: docker deps clean bin test pact

# Run the ci target from a developer machine with the environment variables
Expand All @@ -31,6 +31,29 @@ docker:
@echo "--- 🛠 Starting docker"
docker-compose up -d

docker_build:
docker build -f Dockerfile --build-arg GO_VERSION=${GO_VERSION} -t pactfoundation/pact-go-test .


docker_test: docker_build
docker run \
-e LOG_LEVEL=INFO \
--rm \
pactfoundation/pact-go-test \
/bin/sh -c "make test"
docker_pact: docker_build
docker run \
-e LOG_LEVEL=INFO \
--rm \
pactfoundation/pact-go-test \
/bin/sh -c "make pact_local"
docker_test_all: docker_build
docker run \
-e LOG_LEVEL=INFO \
--rm \
pactfoundation/pact-go-test \
/bin/sh -c "make test && make pact_local"

bin:
go build -o build/pact-go

Expand Down
6 changes: 2 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
version: "3"

services:
httpbin:
image: kennethreitz/httpbin
image: kong/httpbin # https://github.com/Kong/httpbin
ports:
- "8000:80"

Expand All @@ -18,7 +16,7 @@ services:
POSTGRES_DB: postgres

broker_app:
image: pactfoundation/pact-broker:latest-multi
image: pactfoundation/pact-broker:latest
links:
- postgres
ports:
Expand Down

0 comments on commit 19ca6ef

Please sign in to comment.