Skip to content

feat: adopt pact_ffi 0.5.4 based PactSwiftMockServer - #134

Merged
surpher merged 4 commits into
surpher:feat/v2.0.0from
pepejeria:feat/adopt-pactswiftmockserver-0.5.4
Jul 27, 2026
Merged

feat: adopt pact_ffi 0.5.4 based PactSwiftMockServer#134
surpher merged 4 commits into
surpher:feat/v2.0.0from
pepejeria:feat/adopt-pactswiftmockserver-0.5.4

Conversation

@pepejeria

@pepejeria pepejeria commented Jul 21, 2026

Copy link
Copy Markdown

Updates PactSwift to use the new pact_ffi 0.5.4 based PactSwiftMockServer.

📝 Summary of Changes

  • Map the provider verifier options to the new typed VerificationOptions API.
  • Small fixes for consumer side API changes in the new mock server.
  • Update tests.

⚠️ Items of Note

Note: This PR does not change Package.swift. It still points at the ittybittyapps fork, so this branch will not build until the dependency is repointed. That repoint needs a 0.5.4 XCFramework release to exist first.

@surpher, could you release a 0.5.4 release of PactSwiftMockServer (the merged chore/update-libpact_ffi-0.5.x)? That creates the 0.5.4 xcframework binary. Once it's published I'll update Package.swift to point to it.

Known mapping gaps (the new FFI is a bit less flexible than the old CLI string, all noted in code):

  • Multiple filter states or descriptions now use only the first one.
  • logLevel is not applied (the new verifier API has no per run log level).
  • WIP provider version is not sent unless publishing.

🧐🗒 Reviewer Notes

💁 Example

The public ProviderVerifier.Options API is unchanged, so existing usage stays the same. The change is internal, the options are now mapped to the mock server's typed VerificationOptions instead of a CLI args string.

🔨 How To Test

Not testable in CI until Package.swift is repointed. Verified locally by building a macOS xcframework from the 0.5.4 branch and pointing this branch at it: 201/203 pass. The 2 failures are pact_ffi 0.5.4 behaviour changes, not this PR.

Prepares PactSwift for the pact_ffi 0.5.4 based PactSwiftMockServer. Source
changes only; the Package.swift repoint waits on a 0.5.4 XCFramework release,
so the branch does not build until that dependency is updated.

Provider verifier:
- Replace the newline-delimited `args` string with a typed mapping from
  ProviderVerifier.Options to PactSwiftMockServer.VerificationOptions.
- Update the ProviderVerifier call site and the MockVerifier test double for
  the new verifyProvider(options: VerificationOptions) signature.
- Known gaps (documented in code): multiple filter states/descriptions collapse
  to the first (FFI takes one each), and logLevel is not mapped (no per-verifier
  FFI setter). WIP provider version is not forwarded outside publishing.

Consumer-side API drift (fork -> surpher):
- BodyBuilder.body contentType is now non-optional.
- Drop the redundant HeaderBuilder.header(_:value:) extension; surpher provides it.
- Pact.version is now the instance property ffi_version.

Rewrite ProviderVerifier+OptionsTests to assert the mapped VerificationOptions.

Verified locally against a macOS xcframework built from real pact_ffi 0.5.4:
201/203 tests pass. The 2 failures are pact_ffi 0.5.4 engine behaviour changes,
not this change: multi-value request headers, and an empty response body no
longer emitting a Content-Type header.

@surpher surpher left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love your work! Thank you.
I'll get the new version of PactSwiftMockServer and XCFramework out in the next couple of days. And we go from there. 🫡

@surpher

surpher commented Jul 25, 2026

Copy link
Copy Markdown
Owner

José Jeria added 2 commits July 27, 2026 10:18
Repoint the mock server dependency off the ittybittyapps fork onto the
published surpher/PactSwiftMockServerXCFramework v1.2.0 (pact_ffi 0.5.4),
in both Package.swift and PactSwift.xcodeproj.

- Drop tvOS: the v1.2.0 xcframework has no tvOS slice.
- Note: v1.2.0 is arm64 only (no x86_64), so Intel Macs and Intel iOS
  simulators are not supported.

Verified against the released v1.2.0 on macOS and iOS Simulator: 201/203
tests pass. The 2 failures are pact_ffi 0.5.4 behaviour changes, not this
change (multi value request headers, and an empty response body no longer
setting a Content-Type header).
PactSwiftMockServer v1.2.0 is arm64 only, so the x86_64 CI destination and
the Intel macos-13 runner can no longer build it. Run CI on macos-14
(Apple Silicon) with a native macOS destination.
@pepejeria
pepejeria force-pushed the feat/adopt-pactswiftmockserver-0.5.4 branch from 238aa71 to facdc9e Compare July 27, 2026 10:08
- testGetEvents: an empty response body no longer sends a Content-Type header.
- testRequestHeaderWithMultipleValues: a comma-joined multi-value request
  header no longer matches a pact defined with an array of values.

Skipped (not deleted) with XCTSkipIf and documented, pending confirmation with
PactSwiftMockServer on whether these are intended or regressions.
@pepejeria
pepejeria force-pushed the feat/adopt-pactswiftmockserver-0.5.4 branch from facdc9e to 99bf252 Compare July 27, 2026 11:38
@pepejeria

Copy link
Copy Markdown
Author

Thanks @surpher! I repointed PactSwiftMockServer to use the new version.

Note though, that there were 3 issues:

  • There is no x86_64 slice in the new release (good call if u ask me), so I dropped it here as well
  • There is also no tvOS slice, that was dropped as well
  • 2 tests are disabled, they break on pact_ffi 0.5.4 behavior changes:
    • an empty response body no longer sends a Content-Type header
    • a multi-value request header (value1,value2) no longer matches ["value1", "value2"]

@surpher
surpher merged commit 50540e0 into surpher:feat/v2.0.0 Jul 27, 2026
3 checks passed
@surpher

surpher commented Jul 27, 2026

Copy link
Copy Markdown
Owner

@pepejeria love it, thank you!

Supporting x86_64 was just in the way of setting up the libpact_ffi and tools were complaining something in the chain broke. It's been officially dropped by Apple so, time to move on.
Dropping tvOS slice is a bit of an oversight but it's a task for another day and PR. If anyone would've needed it they can raise an issue or even contribute.
Noticed tests failing in PactSwiftMockServer. It's okay, they can get fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants