diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 07eb2635d..c6adff3ee 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/Dockerfile b/Dockerfile index f7480a7b3..edd38e42d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/Makefile b/Makefile index 9efe939c1..b7f913301 100755 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index a8a3cbb8b..a5d984f7d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,6 @@ -version: "3" - services: httpbin: - image: kennethreitz/httpbin + image: kong/httpbin # https://github.com/Kong/httpbin ports: - "8000:80" @@ -18,7 +16,7 @@ services: POSTGRES_DB: postgres broker_app: - image: pactfoundation/pact-broker:latest-multi + image: pactfoundation/pact-broker:latest links: - postgres ports: