From 070604cd8be1157cc3427d2f0881b530355330ce Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Wed, 3 Jul 2024 01:38:42 +0100 Subject: [PATCH] chore(ci): test Dockerfile in CI --- .github/workflows/test.yml | 15 ++++++++++++++- Makefile | 25 ++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 79e3129aa..f347f2844 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -59,8 +59,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/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