From 5b9bf9c627ebb2e682a128359d9db42da4452467 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Thu, 5 Sep 2024 22:28:31 +0100 Subject: [PATCH 01/13] feat: support linux musl --- .github/workflows/test.yml | 6 +++++- Dockerfile.alpine | 10 ++++++++++ Dockerfile => Dockerfile.debian | 0 Makefile | 11 +++++++---- installer/installer.go | 27 ++++++++++++++------------- installer/installer_test.go | 29 +++++++++++++++++++++++++---- 6 files changed, 61 insertions(+), 22 deletions(-) create mode 100644 Dockerfile.alpine rename Dockerfile => Dockerfile.debian (100%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 15b71523b..0cbaf7acd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -76,11 +76,14 @@ jobs: test-containers: runs-on: ubuntu-latest - name: ${{ matrix.go-version }}-test-container + name: ${{ matrix.variant }}-${{ matrix.go-version }}-test-container strategy: fail-fast: false matrix: go-version: ["1.22", "1.23"] + variant: + - debian + - alpine steps: - uses: actions/checkout@v4 @@ -88,6 +91,7 @@ jobs: run: make docker_test_all env: GO_VERSION: ${{ matrix.go-version }} + IMAGE_VARIANT: ${{ matrix.variant }} finish: needs: [test,test-containers] diff --git a/Dockerfile.alpine b/Dockerfile.alpine new file mode 100644 index 000000000..6723ba712 --- /dev/null +++ b/Dockerfile.alpine @@ -0,0 +1,10 @@ +ARG VERSION=1.22 +FROM golang:${VERSION}-alpine + +RUN apk add --no-cache curl gcc musl-dev gzip openjdk17-jre bash protoc protobuf-dev make file + +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/Dockerfile b/Dockerfile.debian similarity index 100% rename from Dockerfile rename to Dockerfile.debian diff --git a/Makefile b/Makefile index 7f90ddbb2..cf6b63386 100755 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ PLUGIN_PACT_MATT_VERSION=0.1.1 PLUGIN_PACT_AVRO_VERSION=0.0.6 GO_VERSION?=1.22 +IMAGE_VARIANT?=debian ci:: docker deps clean bin test pact PACT_DOWNLOAD_DIR=/tmp ifeq ($(OS),Windows_NT) @@ -37,24 +38,26 @@ docker: docker compose up -d docker_build: - docker build -f Dockerfile --build-arg GO_VERSION=${GO_VERSION} -t pactfoundation/pact-go-test . + docker build -f Dockerfile.$(IMAGE_VARIANT) --build-arg GO_VERSION=${GO_VERSION} -t pactfoundation/pact-go-test-$(IMAGE_VARIANT) . + docker_test: docker_build docker run \ -e LOG_LEVEL=INFO \ --rm \ - pactfoundation/pact-go-test \ + -it \ + pactfoundation/pact-go-test-$(IMAGE_VARIANT) \ /bin/sh -c "make test" docker_pact: docker_build docker run \ -e LOG_LEVEL=INFO \ --rm \ - pactfoundation/pact-go-test \ + pactfoundation/pact-go-test-$(IMAGE_VARIANT) \ /bin/sh -c "make pact_local" docker_test_all: docker_build docker run \ -e LOG_LEVEL=INFO \ --rm \ - pactfoundation/pact-go-test \ + pactfoundation/pact-go-test-$(IMAGE_VARIANT) \ /bin/sh -c "make test && make pact_local" bin: diff --git a/installer/installer.go b/installer/installer.go index dbc092d48..95c00c611 100644 --- a/installer/installer.go +++ b/installer/installer.go @@ -80,14 +80,6 @@ func NewInstaller(opts ...installerConfig) (*Installer, error) { log.Println("[WARN] amd64 architecture not detected, defaulting to x86_64. Behaviour may be undefined") } - // Only perform a check if current OS is linux - if runtime.GOOS == "linux" { - err := i.checkMusl() - if err != nil { - log.Println("[DEBUG] unable to check for presence musl library due to error:", err) - } - } - return i, nil } @@ -260,7 +252,13 @@ func (i *Installer) getDownloadURLForPackage(pkg string) (string, error) { return "", fmt.Errorf("unable to find package details for package: %s", pkg) } - return fmt.Sprintf(downloadTemplate, pkg, pkgInfo.version, osToLibName[i.os], i.os, i.arch, osToExtension[i.os]), nil + if checkMusl() && i.os == linux { + return fmt.Sprintf(downloadTemplate, pkg, pkgInfo.version, osToLibName[i.os], i.os, i.arch+"-musl", osToExtension[i.os]), nil + } else { + return fmt.Sprintf(downloadTemplate, pkg, pkgInfo.version, osToLibName[i.os], i.os, i.arch, osToExtension[i.os]), nil + + } + } func (i *Installer) getLibDstForPackage(pkg string) (string, error) { @@ -331,20 +329,23 @@ func checkVersion(lib, version, versionRange string) error { } // checkMusl checks if the OS uses musl library instead of glibc -func (i *Installer) checkMusl() error { +func checkMusl() bool { lddPath, err := exec.LookPath("ldd") if err != nil { - return fmt.Errorf("could not find ldd in environment path") + return false } cmd := exec.Command(lddPath, "/bin/echo") out, err := cmd.CombinedOutput() + if err != nil { + return false + } if strings.Contains(string(out), "musl") { - log.Println("[WARN] Usage of musl library is known to cause problems, prefer using glibc instead.") + return true } - return err + return false } // download template structure: "https://github.com/pact-foundation/pact-reference/releases/download/PACKAGE-vVERSION/LIBNAME-OS-ARCH.EXTENSION.gz" diff --git a/installer/installer_test.go b/installer/installer_test.go index b492af492..dd6c85492 100644 --- a/installer/installer_test.go +++ b/installer/installer_test.go @@ -35,16 +35,37 @@ func TestInstallerDownloader(t *testing.T) { test Installer }{ { - name: "ffi lib - linux x86", + name: "ffi lib - linux x86_64", pkg: FFIPackage, - want: fmt.Sprintf("https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v%s/libpact_ffi-linux-x86_64.so.gz", packages[FFIPackage].version), + want: func() string { + if checkMusl() { + return fmt.Sprintf("https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v%s/libpact_ffi-linux-x86_64-musl.so.gz", packages[FFIPackage].version) + } else { + return fmt.Sprintf("https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v%s/libpact_ffi-linux-x86_64.so.gz", packages[FFIPackage].version) + } + }(), test: Installer{ os: linux, arch: x86_64, }, }, { - name: "ffi lib - macos x86", + name: "ffi lib - linux aarch64", + pkg: FFIPackage, + want: func() string { + if checkMusl() { + return fmt.Sprintf("https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v%s/libpact_ffi-linux-aarch64-musl.so.gz", packages[FFIPackage].version) + } else { + return fmt.Sprintf("https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v%s/libpact_ffi-linux-aarch64.so.gz", packages[FFIPackage].version) + } + }(), + test: Installer{ + os: linux, + arch: aarch64, + }, + }, + { + name: "ffi lib - macos x86_64", pkg: FFIPackage, want: fmt.Sprintf("https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v%s/libpact_ffi-macos-x86_64.dylib.gz", packages[FFIPackage].version), test: Installer{ @@ -62,7 +83,7 @@ func TestInstallerDownloader(t *testing.T) { }, }, { - name: "ffi lib - windows x86", + name: "ffi lib - windows x86_64", pkg: FFIPackage, want: fmt.Sprintf("https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v%s/pact_ffi-windows-x86_64.dll.gz", packages[FFIPackage].version), test: Installer{ From b3d03a030e6b7c50e01fe856ac6169d011983f37 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Wed, 22 Jan 2025 16:41:03 +0000 Subject: [PATCH 02/13] chore(deps): update pact-protobuf-plugin to 0.5.4 --- Makefile | 2 +- consumer/http_v4_test.go | 2 +- examples/grpc/grpc_consumer_test.go | 6 +++--- examples/protobuf-message/protobuf_consumer_test.go | 2 +- examples/protobuf-message/protobuf_provider_test.go | 2 +- internal/native/message_server_test.go | 10 +++++----- internal/native/mock_server_test.go | 2 +- message/v4/synchronous_message_test.go | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index cf6b63386..5ceeefdba 100755 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ TEST?=./... .DEFAULT_GOAL := ci DOCKER_HOST_HTTP?="http://host.docker.internal" PACT_CLI="docker run --rm -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL=$(DOCKER_HOST_HTTP) -e PACT_BROKER_USERNAME -e PACT_BROKER_PASSWORD pactfoundation/pact-cli" -PLUGIN_PACT_PROTOBUF_VERSION=0.3.15 +PLUGIN_PACT_PROTOBUF_VERSION=0.5.4 PLUGIN_PACT_CSV_VERSION=0.0.6 PLUGIN_PACT_MATT_VERSION=0.1.1 PLUGIN_PACT_AVRO_VERSION=0.0.6 diff --git a/consumer/http_v4_test.go b/consumer/http_v4_test.go index 6232bd794..33165496b 100644 --- a/consumer/http_v4_test.go +++ b/consumer/http_v4_test.go @@ -59,7 +59,7 @@ func TestHttpV4TypeSystem(t *testing.T) { UponReceiving("some scenario"). UsingPlugin(PluginConfig{ Plugin: "protobuf", - Version: "0.3.15", + Version: "0.5.4", }). WithRequest("GET", "/"). // WithRequest("GET", "/", func(b *V4InteractionWithPluginRequestBuilder) { diff --git a/examples/grpc/grpc_consumer_test.go b/examples/grpc/grpc_consumer_test.go index 06d0394f7..ba23e062c 100644 --- a/examples/grpc/grpc_consumer_test.go +++ b/examples/grpc/grpc_consumer_test.go @@ -53,7 +53,7 @@ func TestGetFeatureSuccess(t *testing.T) { Given("feature 'Big Tree' exists"). UsingPlugin(message.PluginConfig{ Plugin: "protobuf", - Version: "0.3.15", + Version: "0.5.4", }). WithContents(grpcInteraction, "application/protobuf"). StartTransport("grpc", "127.0.0.1", nil). // For plugin tests, we can't assume if a transport is needed, so this is optional @@ -123,7 +123,7 @@ func TestGetFeatureError(t *testing.T) { Given("feature does not exist at -1, -1"). UsingPlugin(message.PluginConfig{ Plugin: "protobuf", - Version: "0.3.15", + Version: "0.5.4", }). WithContents(grpcInteraction, "application/protobuf"). StartTransport("grpc", "127.0.0.1", nil). // For plugin tests, we can't assume if a transport is needed, so this is optional @@ -194,7 +194,7 @@ func TestSaveFeature(t *testing.T) { Given("feature does not exist at -1, -1"). UsingPlugin(message.PluginConfig{ Plugin: "protobuf", - Version: "0.3.15", + Version: "0.5.4", }). WithContents(grpcInteraction, "application/protobuf"). StartTransport("grpc", "127.0.0.1", nil). // For plugin tests, we can't assume if a transport is needed, so this is optional diff --git a/examples/protobuf-message/protobuf_consumer_test.go b/examples/protobuf-message/protobuf_consumer_test.go index ca097fd6c..9fa0a61eb 100644 --- a/examples/protobuf-message/protobuf_consumer_test.go +++ b/examples/protobuf-message/protobuf_consumer_test.go @@ -43,7 +43,7 @@ func TestPluginMessageConsumer(t *testing.T) { ExpectsToReceive("feature message"). UsingPlugin(message.PluginConfig{ Plugin: "protobuf", - Version: "0.3.15", + Version: "0.5.4", }). WithContents(protoMessage, "application/protobuf"). ExecuteTest(t, func(m message.AsynchronousMessage) error { diff --git a/examples/protobuf-message/protobuf_provider_test.go b/examples/protobuf-message/protobuf_provider_test.go index bec3eb217..eb7d5ecb0 100644 --- a/examples/protobuf-message/protobuf_provider_test.go +++ b/examples/protobuf-message/protobuf_provider_test.go @@ -41,7 +41,7 @@ func TestPluginMessageProvider(t *testing.T) { }, }) return feature, message.Metadata{ - "contentType": "application/protobuf;message=Feature", // <- This is required to ensure the correct type is matched + "contentType": "application/protobuf;message=.routeguide.Feature", // <- This is required to ensure the correct type is matched }, nil }, } diff --git a/internal/native/message_server_test.go b/internal/native/message_server_test.go index c24df1edc..0431b8e05 100644 --- a/internal/native/message_server_test.go +++ b/internal/native/message_server_test.go @@ -213,7 +213,7 @@ func TestGetPluginSyncMessageContentsAsBytes(t *testing.T) { // Protobuf plugin test defer m.CleanupPlugins() - err := m.UsingPlugin("protobuf", "0.3.15") + err := m.UsingPlugin("protobuf", "0.5.4") assert.NoError(t, err) i := m.NewSyncMessageInteraction("grpc interaction") @@ -271,7 +271,7 @@ func TestGetPluginSyncMessageContentsAsBytes_EmptyResponse(t *testing.T) { // Protobuf plugin test defer m.CleanupPlugins() - err := m.UsingPlugin("protobuf", "0.3.15") + err := m.UsingPlugin("protobuf", "0.5.4") assert.NoError(t, err) i := m.NewSyncMessageInteraction("grpc interaction") @@ -318,7 +318,7 @@ func TestGetPluginAsyncMessageContentsAsBytes(t *testing.T) { // Protobuf plugin test defer m.CleanupPlugins() - _ = m.UsingPlugin("protobuf", "0.3.15") + _ = m.UsingPlugin("protobuf", "0.5.4") i := m.NewAsyncMessageInteraction("grpc interaction") @@ -359,7 +359,7 @@ func TestGrpcPluginInteraction(t *testing.T) { // Protobuf plugin test defer m.CleanupPlugins() - _ = m.UsingPlugin("protobuf", "0.3.15") + _ = m.UsingPlugin("protobuf", "0.5.4") i := m.NewSyncMessageInteraction("grpc interaction") @@ -437,7 +437,7 @@ func TestGrpcPluginInteraction_ErrorResponse(t *testing.T) { // Protobuf plugin test defer m.CleanupPlugins() - _ = m.UsingPlugin("protobuf", "0.3.15") + _ = m.UsingPlugin("protobuf", "0.5.4") i := m.NewSyncMessageInteraction("grpc interaction") diff --git a/internal/native/mock_server_test.go b/internal/native/mock_server_test.go index 2e991aa6c..aa79a6373 100644 --- a/internal/native/mock_server_test.go +++ b/internal/native/mock_server_test.go @@ -174,7 +174,7 @@ func TestPluginInteraction(t *testing.T) { // Protobuf plugin test defer m.CleanupPlugins() - _ = m.UsingPlugin("protobuf", "0.3.15") + _ = m.UsingPlugin("protobuf", "0.5.4") m.WithSpecificationVersion(SPECIFICATION_VERSION_V4) i := m.NewInteraction("some plugin interaction") diff --git a/message/v4/synchronous_message_test.go b/message/v4/synchronous_message_test.go index 0c5dd147f..3b1d4ac24 100644 --- a/message/v4/synchronous_message_test.go +++ b/message/v4/synchronous_message_test.go @@ -111,7 +111,7 @@ func TestSyncTypeSystem_ProtobufPlugin_Matcher_Transport(t *testing.T) { Given("some state"). UsingPlugin(PluginConfig{ Plugin: "protobuf", - Version: "0.3.15", + Version: "0.5.4", }). WithContents(grpcInteraction, "application/protobuf"). StartTransport("grpc", "127.0.0.1", nil). // For plugin tests, we can't assume if a transport is needed, so this is optional @@ -168,7 +168,7 @@ func TestSyncTypeSystem_ProtobufPlugin_Matcher_Transport_Fail(t *testing.T) { Given("some state"). UsingPlugin(PluginConfig{ Plugin: "protobuf", - Version: "0.3.15", + Version: "0.5.4", }). WithContents(grpcInteraction, "application/protobuf"). StartTransport("grpc", "127.0.0.1", nil). // For plugin tests, we can't assume if a transport is needed, so this is optional From 719e4cf0b56afe8f076dd4a3ea74a05c91aa1241 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Wed, 22 Jan 2025 16:41:25 +0000 Subject: [PATCH 03/13] chore(deps): update pact-plugin-cli to 0.1.3 --- scripts/install-cli.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install-cli.sh b/scripts/install-cli.sh index b4151f940..66817bd0c 100755 --- a/scripts/install-cli.sh +++ b/scripts/install-cli.sh @@ -38,7 +38,7 @@ function detect_osarch() { } -VERSION="0.1.2" +VERSION="0.1.3" detect_osarch if [ ! -f ~/.pact/bin/pact-plugin-cli ]; then From 31f0569f5deb4820aef4cce1a698a05624d90779 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Wed, 22 Jan 2025 16:41:38 +0000 Subject: [PATCH 04/13] chore: ignore pact files from git --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index dddbec92a..c98284310 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ _* *.log pact-go pacts +examples/pacts/*.json logs tmp coverage.txt From 52bba194d6f2d4c6e6e0a8db540ff9ec335f1c02 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Wed, 22 Jan 2025 16:41:53 +0000 Subject: [PATCH 05/13] ci: allow alpine as experimental --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0cbaf7acd..cb05f9a2c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -83,7 +83,9 @@ jobs: go-version: ["1.22", "1.23"] variant: - debian - - alpine + include: + - variant: alpine + experimental: true steps: - uses: actions/checkout@v4 From 1eee0e5c10b0070c4a0b08463a4b5f1844e6825b Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Wed, 22 Jan 2025 16:50:38 +0000 Subject: [PATCH 06/13] chore: ability ability to skip setting of -race causes issues in musl --- Makefile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 5ceeefdba..182c4b9dc 100755 --- a/Makefile +++ b/Makefile @@ -16,7 +16,11 @@ PACT_DOWNLOAD_DIR=/tmp ifeq ($(OS),Windows_NT) PACT_DOWNLOAD_DIR=$$TMP endif - +SKIP_RACE?=false +RACE?=-race +ifeq ($(SKIP_RACE),true) + RACE= +endif # Run the ci target from a developer machine with the environment variables # set as if it was on Travis CI. # Use this for quick feedback when playing around with your workflows. @@ -43,6 +47,7 @@ docker_build: docker_test: docker_build docker run \ -e LOG_LEVEL=INFO \ + -e SKIP_RACE=$(SKIP_RACE) \ --rm \ -it \ pactfoundation/pact-go-test-$(IMAGE_VARIANT) \ @@ -50,12 +55,14 @@ docker_test: docker_build docker_pact: docker_build docker run \ -e LOG_LEVEL=INFO \ + -e SKIP_RACE=$(SKIP_RACE) \ --rm \ pactfoundation/pact-go-test-$(IMAGE_VARIANT) \ /bin/sh -c "make pact_local" docker_test_all: docker_build docker run \ -e LOG_LEVEL=INFO \ + -e SKIP_RACE=$(SKIP_RACE) \ --rm \ pactfoundation/pact-go-test-$(IMAGE_VARIANT) \ /bin/sh -c "make test && make pact_local" @@ -133,7 +140,7 @@ test: deps install @echo "mode: count" > coverage.txt @for d in $$(go list ./... | grep -v vendor | grep -v examples); \ do \ - go test -v -race -coverprofile=profile.out -covermode=atomic $$d; \ + go test -v $(RACE) -coverprofile=profile.out -covermode=atomic $$d; \ if [ $$? != 0 ]; then \ exit 1; \ fi; \ @@ -146,7 +153,7 @@ test: deps install testrace: - go test -race $(TEST) $(TESTARGS) + go test $(RACE) $(TEST) $(TESTARGS) updatedeps: go get -d -v -p 2 ./... From db22d37161cf4c1ffec532bcd40b4c3d67010431 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Wed, 22 Jan 2025 17:00:55 +0000 Subject: [PATCH 07/13] ci: multi-platform test containers --- .github/workflows/test.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cb05f9a2c..974a28538 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -75,16 +75,23 @@ jobs: if: ${{ always() }} test-containers: - runs-on: ubuntu-latest - name: ${{ matrix.variant }}-${{ matrix.go-version }}-test-container + continue-on-error: ${{ matrix.experimental }} + runs-on: ${{ matrix.os }} + name: ${{ matrix.os }}-${{ matrix.variant }}-${{ matrix.go-version }}-test-container strategy: fail-fast: false matrix: + os: [ubuntu-24.04, ubuntu-24.04-arm] go-version: ["1.22", "1.23"] variant: - debian + experimental: [false] include: - variant: alpine + go-version: 1.22 + experimental: true + - variant: alpine + go-version: 1.23 experimental: true steps: - uses: actions/checkout@v4 From d08f78a0648ba660dc31acf12b27fd6890191d52 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Wed, 22 Jan 2025 17:13:26 +0000 Subject: [PATCH 08/13] ci: test --- .github/workflows/test.yml | 114 ++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 974a28538..0a6e6cb6f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,59 +20,59 @@ env: COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: - test: - strategy: - fail-fast: false - matrix: - go-version: [ # https://endoflife.date/go - # 1.17.x, # Ended 02 Aug 2022 - # 1.18.x, # Ended 01 Feb 2023 - # 1.19.x, # Ended 06 Sep 2023 - # 1.20.x, # Ended 06 Feb 2024 - # 1.21.x, # Ended 13 Aug 2024 - 1.22.x, - 1.23.x, - ] - os: [ubuntu-latest, macos-13, macos-14, windows-latest] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - uses: actions/setup-java@v4 # Needed for the Avro example - with: - distribution: 'zulu' - java-version: '17' - - if: matrix.os == 'macos-14' - run: brew install protobuf - - name: Test - if: matrix.os == 'ubuntu-latest' - run: APP_BRANCH=${APP_REF:11} DOCKER_GATEWAY_HOST=172.17.0.1 DOCKER_HOST_HTTP="http://172.17.0.1" make - - name: Set CGO_LDFLAGS / pact_ffi lib on PATH - if: matrix.os == 'windows-latest' - run: | - "CGO_LDFLAGS=-L$env:TMP" >> $env:GITHUB_ENV - "$env:TMP" >> $env:GITHUB_PATH - - name: Test (unit) - if: matrix.os != 'ubuntu-latest' - run: make test - - name: Test (pact) - if: matrix.os != 'ubuntu-latest' - run: make pact_local - - name: Install goveralls - if: matrix.os != 'windows-latest' - run: go install github.com/mattn/goveralls@latest - - name: Send coverage - if: matrix.os != 'windows-latest' - run: goveralls -coverprofile=coverage.txt -service=github -parallel - - uses: actions/upload-artifact@v4 - with: - name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.go-version }}-${{ matrix.os }}.zip - path: ~/.pact/plugins/**/plugin.log - if: ${{ always() }} + # test: + # strategy: + # fail-fast: false + # matrix: + # go-version: [ # https://endoflife.date/go + # # 1.17.x, # Ended 02 Aug 2022 + # # 1.18.x, # Ended 01 Feb 2023 + # # 1.19.x, # Ended 06 Sep 2023 + # # 1.20.x, # Ended 06 Feb 2024 + # # 1.21.x, # Ended 13 Aug 2024 + # 1.22.x, + # 1.23.x, + # ] + # os: [ubuntu-latest, macos-13, macos-14, windows-latest] + # runs-on: ${{ matrix.os }} + # steps: + # - name: Checkout code + # uses: actions/checkout@v4 + # - name: Install Go + # uses: actions/setup-go@v5 + # with: + # go-version: ${{ matrix.go-version }} + # - uses: actions/setup-java@v4 # Needed for the Avro example + # with: + # distribution: 'zulu' + # java-version: '17' + # - if: matrix.os == 'macos-14' + # run: brew install protobuf + # - name: Test + # if: matrix.os == 'ubuntu-latest' + # run: APP_BRANCH=${APP_REF:11} DOCKER_GATEWAY_HOST=172.17.0.1 DOCKER_HOST_HTTP="http://172.17.0.1" make + # - name: Set CGO_LDFLAGS / pact_ffi lib on PATH + # if: matrix.os == 'windows-latest' + # run: | + # "CGO_LDFLAGS=-L$env:TMP" >> $env:GITHUB_ENV + # "$env:TMP" >> $env:GITHUB_PATH + # - name: Test (unit) + # if: matrix.os != 'ubuntu-latest' + # run: make test + # - name: Test (pact) + # if: matrix.os != 'ubuntu-latest' + # run: make pact_local + # - name: Install goveralls + # if: matrix.os != 'windows-latest' + # run: go install github.com/mattn/goveralls@latest + # - name: Send coverage + # if: matrix.os != 'windows-latest' + # run: goveralls -coverprofile=coverage.txt -service=github -parallel + # - uses: actions/upload-artifact@v4 + # with: + # name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.go-version }}-${{ matrix.os }}.zip + # path: ~/.pact/plugins/**/plugin.log + # if: ${{ always() }} test-containers: continue-on-error: ${{ matrix.experimental }} @@ -81,10 +81,9 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-24.04, ubuntu-24.04-arm] + os: [ubuntu-latest, ubuntu-24.04-arm] go-version: ["1.22", "1.23"] - variant: - - debian + variant: [debian] experimental: [false] include: - variant: alpine @@ -103,7 +102,8 @@ jobs: IMAGE_VARIANT: ${{ matrix.variant }} finish: - needs: [test,test-containers] + needs: [test-containers] + # needs: [test,test-containers] runs-on: ubuntu-latest steps: - name: Coveralls Finished From dd20918b55bcc62adb18dca2c9f45157c93acc7c Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Wed, 22 Jan 2025 17:14:53 +0000 Subject: [PATCH 09/13] ci: test --- .github/workflows/test.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0a6e6cb6f..0d13c0fef 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -89,9 +89,19 @@ jobs: - variant: alpine go-version: 1.22 experimental: true + os: ubuntu-latest - variant: alpine go-version: 1.23 experimental: true + os: ubuntu-latest + - variant: alpine + go-version: 1.22 + experimental: true + os: ubuntu-24.04-arm + - variant: alpine + go-version: 1.23 + experimental: true + os: ubuntu-24.04-arm steps: - uses: actions/checkout@v4 From d354654def2e519f984c7ccf46f058a6980a5e93 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Wed, 22 Jan 2025 17:20:14 +0000 Subject: [PATCH 10/13] ci: skip race on arm --- .github/workflows/test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0d13c0fef..b32e3a2e2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -106,7 +106,11 @@ jobs: - uses: actions/checkout@v4 - name: Test dockerfile - run: make docker_test_all + run: | + if [[ "${{ matrix.os }}" == *"arm"* ]]; then + export SKIP_RACE=true + fi + make docker_test_all env: GO_VERSION: ${{ matrix.go-version }} IMAGE_VARIANT: ${{ matrix.variant }} From 93aa88d0ddecc5f71f502314421498ee78551b29 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Wed, 22 Jan 2025 17:54:01 +0000 Subject: [PATCH 11/13] ci: allow skipping of provider tests musl no likey --- .github/workflows/test.yml | 4 ++-- Makefile | 15 +++++++++++++-- internal/native/verifier_test.go | 3 +++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b32e3a2e2..948620670 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -107,8 +107,8 @@ jobs: - name: Test dockerfile run: | - if [[ "${{ matrix.os }}" == *"arm"* ]]; then - export SKIP_RACE=true + if [[ "${{ matrix.variant }}" == "alpine" ]]; then + export SKIP_PROVIDER_TESTS=true fi make docker_test_all env: diff --git a/Makefile b/Makefile index 182c4b9dc..9cc6ec751 100755 --- a/Makefile +++ b/Makefile @@ -47,6 +47,7 @@ docker_build: docker_test: docker_build docker run \ -e LOG_LEVEL=INFO \ + -e SKIP_PROVIDER_TESTS=$(SKIP_PROVIDER_TESTS) \ -e SKIP_RACE=$(SKIP_RACE) \ --rm \ -it \ @@ -55,6 +56,7 @@ docker_test: docker_build docker_pact: docker_build docker run \ -e LOG_LEVEL=INFO \ + -e SKIP_PROVIDER_TESTS=$(SKIP_PROVIDER_TESTS) \ -e SKIP_RACE=$(SKIP_RACE) \ --rm \ pactfoundation/pact-go-test-$(IMAGE_VARIANT) \ @@ -62,6 +64,7 @@ docker_pact: docker_build docker_test_all: docker_build docker run \ -e LOG_LEVEL=INFO \ + -e SKIP_PROVIDER_TESTS=$(SKIP_PROVIDER_TESTS) \ -e SKIP_RACE=$(SKIP_RACE) \ --rm \ pactfoundation/pact-go-test-$(IMAGE_VARIANT) \ @@ -124,7 +127,9 @@ pact: clean install docker pact_local: clean download_plugins install @echo "--- 🔨 Running Pact examples" go test -v -tags=consumer -count=1 github.com/pact-foundation/pact-go/v2/examples/... - SKIP_PUBLISH=true go test -v -timeout=30s -tags=provider -count=1 github.com/pact-foundation/pact-go/v2/examples/... + if [ -z "$(SKIP_PROVIDER_TESTS)" ]; then \ + SKIP_PUBLISH=true go test -v -timeout=30s -tags=provider -count=1 github.com/pact-foundation/pact-go/v2/examples/...; \ + fi publish: @echo "-- 📃 Publishing pacts" @@ -134,13 +139,19 @@ release: echo "--- 🚀 Releasing it" "$(CURDIR)/scripts/release.sh" +ifeq ($(SKIP_PROVIDER_TESTS),true) + PROVIDER_TEST_TAGS= +else + PROVIDER_TEST_TAGS=-tags=provider +endif + test: deps install @echo "--- ✅ Running tests" @if [ -f coverage.txt ]; then rm coverage.txt; fi; @echo "mode: count" > coverage.txt @for d in $$(go list ./... | grep -v vendor | grep -v examples); \ do \ - go test -v $(RACE) -coverprofile=profile.out -covermode=atomic $$d; \ + go test -v $(RACE) -coverprofile=profile.out $(PROVIDER_TEST_TAGS) -covermode=atomic $$d; \ if [ $$? != 0 ]; then \ exit 1; \ fi; \ diff --git a/internal/native/verifier_test.go b/internal/native/verifier_test.go index 6105bc93a..714d65551 100644 --- a/internal/native/verifier_test.go +++ b/internal/native/verifier_test.go @@ -1,3 +1,6 @@ +//go:build provider +// +build provider + package native import ( From 70290573d28d17786261d5b20e9e1d2490f14675 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Wed, 22 Jan 2025 18:26:12 +0000 Subject: [PATCH 12/13] ci: add support to skip provider tests on alpine add workflow input to allow for conditional testing with tests enabled This will allow end users to at least utilise pact-go with alpine in some capacity and may lead to an inquisitive user working out why we are getting segfaults in the verifier execution --- .github/workflows/test.yml | 9 +++++++++ Makefile | 2 +- README.md | 9 +++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 948620670..316a24dd0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,6 +7,12 @@ on: pull_request: branches: - master + workflow_dispatch: + inputs: + SKIP_ALPINE_PROVIDER_TESTS: + description: 'Skip alpine provider tests' + required: false + default: 'false' env: PACT_BROKER_BASE_URL: https://testdemo.pactflow.io @@ -109,6 +115,9 @@ jobs: run: | if [[ "${{ matrix.variant }}" == "alpine" ]]; then export SKIP_PROVIDER_TESTS=true + if [[ "${{ github.event.inputs.SKIP_ALPINE_PROVIDER_TESTS }}" == "false" ]]; then + export SKIP_PROVIDER_TESTS=false + fi fi make docker_test_all env: diff --git a/Makefile b/Makefile index 9cc6ec751..b50ec44af 100755 --- a/Makefile +++ b/Makefile @@ -127,7 +127,7 @@ pact: clean install docker pact_local: clean download_plugins install @echo "--- 🔨 Running Pact examples" go test -v -tags=consumer -count=1 github.com/pact-foundation/pact-go/v2/examples/... - if [ -z "$(SKIP_PROVIDER_TESTS)" ]; then \ + if [ "$(SKIP_PROVIDER_TESTS)" != "true" ]; then \ SKIP_PUBLISH=true go test -v -timeout=30s -tags=provider -count=1 github.com/pact-foundation/pact-go/v2/examples/...; \ fi diff --git a/README.md b/README.md index 8cb16e7e0..3ab2ab1c3 100644 --- a/README.md +++ b/README.md @@ -285,12 +285,17 @@ _\*_ v3 support is limited to the subset of functionality required to enable lan | MacOS | arm64 | ✅ | All | | Linux (libc) | x86_64 | ✅ | All | | Linux (libc) | arm64 | ✅ | All | -| Linux (musl) | x86_64 | ❌ | - | -| Linux (musl) | arm64 | ❌ | - | +| Linux (musl) | x86_64 | ✅ | v2.2.0 | +| Linux (musl) | arm64 | ✅ | v2.2.0 | | Windows | x86_64 | ✅ | All | | Windows | x86 | ❌ | - | | Windows | arm64 | ❌ | - | +⚠️ - Known issues + +> - Linux (musl) provider verification is known to experience segmentation faults, reproducible in our CI system. +> - Assistance is greatly appreciated if musl support is important to you. + ## Roadmap From 3d48a9d62bde028d08559e2db15e19d8cdb2c4d5 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Wed, 22 Jan 2025 18:29:25 +0000 Subject: [PATCH 13/13] chore: re-enable ci jobs removed for testing --- .github/workflows/test.yml | 109 ++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 55 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 316a24dd0..e1417532f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,59 +26,59 @@ env: COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: - # test: - # strategy: - # fail-fast: false - # matrix: - # go-version: [ # https://endoflife.date/go - # # 1.17.x, # Ended 02 Aug 2022 - # # 1.18.x, # Ended 01 Feb 2023 - # # 1.19.x, # Ended 06 Sep 2023 - # # 1.20.x, # Ended 06 Feb 2024 - # # 1.21.x, # Ended 13 Aug 2024 - # 1.22.x, - # 1.23.x, - # ] - # os: [ubuntu-latest, macos-13, macos-14, windows-latest] - # runs-on: ${{ matrix.os }} - # steps: - # - name: Checkout code - # uses: actions/checkout@v4 - # - name: Install Go - # uses: actions/setup-go@v5 - # with: - # go-version: ${{ matrix.go-version }} - # - uses: actions/setup-java@v4 # Needed for the Avro example - # with: - # distribution: 'zulu' - # java-version: '17' - # - if: matrix.os == 'macos-14' - # run: brew install protobuf - # - name: Test - # if: matrix.os == 'ubuntu-latest' - # run: APP_BRANCH=${APP_REF:11} DOCKER_GATEWAY_HOST=172.17.0.1 DOCKER_HOST_HTTP="http://172.17.0.1" make - # - name: Set CGO_LDFLAGS / pact_ffi lib on PATH - # if: matrix.os == 'windows-latest' - # run: | - # "CGO_LDFLAGS=-L$env:TMP" >> $env:GITHUB_ENV - # "$env:TMP" >> $env:GITHUB_PATH - # - name: Test (unit) - # if: matrix.os != 'ubuntu-latest' - # run: make test - # - name: Test (pact) - # if: matrix.os != 'ubuntu-latest' - # run: make pact_local - # - name: Install goveralls - # if: matrix.os != 'windows-latest' - # run: go install github.com/mattn/goveralls@latest - # - name: Send coverage - # if: matrix.os != 'windows-latest' - # run: goveralls -coverprofile=coverage.txt -service=github -parallel - # - uses: actions/upload-artifact@v4 - # with: - # name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.go-version }}-${{ matrix.os }}.zip - # path: ~/.pact/plugins/**/plugin.log - # if: ${{ always() }} + test: + strategy: + fail-fast: false + matrix: + go-version: [ # https://endoflife.date/go + # 1.17.x, # Ended 02 Aug 2022 + # 1.18.x, # Ended 01 Feb 2023 + # 1.19.x, # Ended 06 Sep 2023 + # 1.20.x, # Ended 06 Feb 2024 + # 1.21.x, # Ended 13 Aug 2024 + 1.22.x, + 1.23.x, + ] + os: [ubuntu-latest, macos-13, macos-14, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go-version }} + - uses: actions/setup-java@v4 # Needed for the Avro example + with: + distribution: 'zulu' + java-version: '17' + - if: matrix.os == 'macos-14' + run: brew install protobuf + - name: Test + if: matrix.os == 'ubuntu-latest' + run: APP_BRANCH=${APP_REF:11} DOCKER_GATEWAY_HOST=172.17.0.1 DOCKER_HOST_HTTP="http://172.17.0.1" make + - name: Set CGO_LDFLAGS / pact_ffi lib on PATH + if: matrix.os == 'windows-latest' + run: | + "CGO_LDFLAGS=-L$env:TMP" >> $env:GITHUB_ENV + "$env:TMP" >> $env:GITHUB_PATH + - name: Test (unit) + if: matrix.os != 'ubuntu-latest' + run: make test + - name: Test (pact) + if: matrix.os != 'ubuntu-latest' + run: make pact_local + - name: Install goveralls + if: matrix.os != 'windows-latest' + run: go install github.com/mattn/goveralls@latest + - name: Send coverage + if: matrix.os != 'windows-latest' + run: goveralls -coverprofile=coverage.txt -service=github -parallel + - uses: actions/upload-artifact@v4 + with: + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.go-version }}-${{ matrix.os }}.zip + path: ~/.pact/plugins/**/plugin.log + if: ${{ always() }} test-containers: continue-on-error: ${{ matrix.experimental }} @@ -125,8 +125,7 @@ jobs: IMAGE_VARIANT: ${{ matrix.variant }} finish: - needs: [test-containers] - # needs: [test,test-containers] + needs: [test,test-containers] runs-on: ubuntu-latest steps: - name: Coveralls Finished