Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pact FFI Tracking Issue #317

Open
YOU54F opened this issue Aug 12, 2024 · 2 comments
Open

Pact FFI Tracking Issue #317

YOU54F opened this issue Aug 12, 2024 · 2 comments

Comments

@YOU54F
Copy link
Member

YOU54F commented Aug 12, 2024

Meta issue for all things Pact FFI interop with Pact-Ruby

📝 Background

One of the strengths of Pact is its specification, allowing anybody to create a new language binding in an interoperable way.

Pact-ruby support up to v2.0 of the pact-specification, and was distributed and used in other languages via travelling ruby.

For a fuller background, please see

For a view of the pact-ruby ecosystem, please see

The main functionality of the Pact-ruby project has been replaced by a core library written in Rust (pact-foundation/pact-reference). This library exposes both command line applications & a foreign function interface which other languages can leverage without the need to re-implement a lot of the logic. The core library helps to maintain parity across the different clients and helps with the adoption of new features.

It has the benefit of supports up to the current Pact V4 specification, which allows end-users to leverage the pact-plugin ecosystem, along with several other quality of life benefits.

For a view of the rust ecosystem, please see

🔍 Overview of the pact-ruby ecosystem

Project Purpose Status
pact-ruby core dsl for pact ruby rspec consumers / rack providers v2 spec + v3 spec message consumers (partial)
pact-mock_service HTTP mock and stub service used in pact-ruby and standalone replaced by https://github.com/pact-foundation/pact-core-mock-server
pact-provider-verifier pact provider verification for running apps (non rack ruby or standalone) replaced by pact-verifier
pact message ruby provides a consumer message dsl for partial v3 message support replaced by https://github.com/pact-foundation/pact-core-mock-server
pact_broker-client cli to interact with pact broker API in use with no current replacement
pact-ruby-cli docker collection of ruby gems in use mainly for pact_broker-client
pact-ruby-standalone standalone collection of ruby gems in use mainly for pact_broker-client
pact-support shared code for pact gems in use
pact-message-demo TODO needs archiving
pact-xml TODO TODO
pact-ruby-e2e-example TODO TODO
rspec-pact-matchers TODO TODO
pact-mock-service-docker TODO archived
pact-provider-proxy TODO archived
zoo-app TODO TODO
pact-ruby-standalone-windows-test TODO TODO
pact-consumer-minitest TODO TODO

🤔 Challenges

  1. pact-mock_service currently starts a mock server first, and is then loaded up with interactions. When a test is complete, an after hook fires to verify matches were present. Pact FFI uses an approach whereby the an interaction is created by prior starting a mock server. When the consumer has issued a request, mismatches must be checked to ensure the consumer made the correct request. The developer can then perform their unit tests as normal.
  2. pact-ruby leverages rspec hooks on both the consumer and provider side. on the provider side, it runs through each interaction in the pact, and generates a dynamic rspec test suite on the fly. the pact_ffi verifier is loaded up with sources, and then fired. the user does not have the ability to gain granular access to individual tests
  3. Pact-ruby uses rack-test to verify Rack based applications, without creating a running endpoint that can be hit externally. pact_ffi requires a running host url, therefore we may need to ask users to start and stop their tests manually. Wonder if we can use lessons from pact-provider-verifier which uses a rack-reverse-proxy (could we start up a proxy app for a url to pass to pact_ffi and pass requests from the proxy to the users rack app

Issues resolved by leveraging the rust core

The rust core may exhibit different behaviour than the current ruby core. In some cases, leveraging the rust core may fix existing defects raised against the pact-ruby projects. Below are a list of some to consider

Validation

@YOU54F
Copy link
Member Author

YOU54F commented Aug 23, 2024

Experiment of pact-ruby exposing both it's existing interface, and allowing for access to the pact_ffi interface too, so we can allow for backwards compat with the existing implementation but to allow people to try out new features.

https://github.com/safdotdev/pact-ruby-e2e-example/tree/feat/ffi

@YOU54F YOU54F pinned this issue Aug 30, 2024
@YOU54F
Copy link
Member Author

YOU54F commented Oct 16, 2024

See the latest pact blog post for an announcement about sbmt-pact which leverages the pact-ruby-ffi project and implements support for v3/v4 and plugins via the rust core

https://docs.pact.io/blog/2024/09/30/pact-open-source-update-sept-2024#sbmt-pact---pact-v3v4--plugin-support

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

No branches or pull requests

1 participant