pact-foundation / pact-go

Golang version of Pact. Pact is a contract testing framework for HTTP APIs and non-HTTP asynchronous messaging systems.
http://pact.io
MIT License
862 stars 110 forks source link

RFC: Support Alpine Linux #453

Open YOU54F opened 2 months ago

YOU54F commented 2 months ago

Rationale

We have warnings in the code, if on Alpine - See https://github.com/pact-foundation/pact-go/pull/246

but we now have native musl based shared libraries for the pact_ffi

https://github.com/pact-foundation/pact-reference/releases/tag/libpact_ffi-v0.4.23

It would be nice to add proper support for these variants in pact-go

Approach

  1. When detecting musl, instead of warning user, provide download for *.so musl variant in https://github.com/pact-foundation/pact-go/blob/master/installer/installer.go
  2. Update tests to reflect https://github.com/pact-foundation/pact-go/blob/master/installer/installer_test.go
  3. Create Dockerfile for golang alpine https://github.com/pact-foundation/pact-go/blob/master/Dockerfile
  4. Update Makefile to run either debian or alpine based image https://github.com/pact-foundation/pact-go/blob/a1e63fc66c7dda9a79966fb5fcc47614738bef2c/Makefile#L39-L58
  5. Update CI to test amd64 alpine variant https://github.com/pact-foundation/pact-go/blob/a1e63fc66c7dda9a79966fb5fcc47614738bef2c/.github/workflows/test.yml#L69-L82
YOU54F commented 2 months ago

Tried this out

https://github.com/YOU54F/pact-go/actions/runs/10728828875/job/29754218172

works fine on the consumer side, but getting segfaults in the provider side. I have a hunch its relating to the proxy code

SIGSEGV: segmentation violation
PC=0x7f09e5a12ca3 m=6 sigcode=2 addr=0x7f099ebf7a00
signal arrived during cgo execution

goroutine 5 gp=0xc000103dc0 m=6 mp=0xc000096008 [syscall]:
runtime.cgocall(0x9df100, 0xc000047338)
    /usr/local/go/src/runtime/cgocall.go:157 +0x4b fp=0xc000047310 sp=0xc0000472d8 pc=0x40bd2b
github.com/pact-foundation/pact-go/v2/internal/native._Cfunc_pactffi_verifier_execute(0x7f099ea0aa60)
    _cgo_gotypes.go:727 +0x47 fp=0xc000047338 sp=0xc000047310 pc=0x94c187
github.com/pact-foundation/pact-go/v2/internal/native.(*Verifier).Execute.func1(0xc000849340?)
    /go/src/github.com/pact-foundation/pact-go/internal/native/verifier.go:198 +0x3e fp=0xc000047378 sp=0xc000047338 pc=0x9576be
github.com/pact-foundation/pact-go/v2/internal/native.(*Verifier).Execute(0xc000582b88?)
    /go/src/github.com/pact-foundation/pact-go/internal/native/verifier.go:198 +0x17 fp=0xc0000473c0 sp=0xc000047378 pc=0x9575d7
github.com/pact-foundation/pact-go/v2/provider.(*VerifyRequest).Verify(0xc000047720, 0xc000582b88, {0x2?, 0xc0000476a8?})
    /go/src/github.com/pact-foundation/pact-go/provider/verify_request.go:304 +0x21a fp=0xc0000474c8 sp=0xc0000473c0 pc=0x9db71a
github.com/pact-foundation/pact-go/v2/provider.(*Verifier).verifyProviderRaw(_, {{0xc000146768, 0x16}, {0x0, 0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0, ...}, ...}, ...)
    /go/src/github.com/pact-foundation/pact-go/provider/verifier.go:169 +0xc8f fp=0xc000047720 sp=0xc0000474c8 pc=0x9d7b4f
github.com/pact-foundation/pact-go/v2/provider.(*Verifier).VerifyProvider(_, _, {{0xb3452d, 0x15}, {0x0, 0x0, 0x0}, {0x0, 0x0}, {0x0, ...}, ...})
    /go/src/github.com/pact-foundation/pact-go/provider/verifier.go:176 +0x65 fp=0xc000047938 sp=0xc000047720 pc=0x9d9445
github.com/pact-foundation/pact-go/v2/examples.TestV3HTTPProvider(0xc0000c6000)
    /go/src/github.com/pact-foundation/pact-go/examples/provider_test.go:99 +0x548 fp=0xc000047f70 sp=0xc000047938 pc=0x9dca08

<snip>