Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 39 additions & 34 deletions .github/workflows/build-ffi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,58 @@ on:
branches:
- master

env:
# Generic
FORCE_COLOR: '1'
CLICOLOR: '1'
# Rust
CARGO_TERM_COLOR: always
RUST_BACKTRACE: '1'

jobs:
build:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ ubuntu-latest, windows-latest, macos-15, macos-15-intel ]
rust: [ stable ]
rust: [ nightly ]
Comment thread
YOU54F marked this conversation as resolved.
env:
pact_do_not_track: true
steps:
- uses: actions/checkout@v3
- run: rustc --version || true
shell: bash
- uses: dtolnay/rust-toolchain@stable
- name: Checkout code
uses: actions/checkout@v5

- name: Install Conan
uses: conan-io/setup-conan@09566912d661de90608308897a4d513e850c04e8 # v1.2.0
with:
toolchain: stable
- name: Install shared mime info DB
if: runner.os == 'macOS'
run: brew install shared-mime-info
- uses: dtolnay/rust-toolchain@nightly
cache_packages: true

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}

- name: Install cbindgen and just
uses: taiki-e/install-action@main
with:
toolchain: nightly
components: rustfmt
- name: Install doxygen
if: runner.os == 'Linux'
run: sudo apt-get install -y doxygen
- name: Build pact_ffi with CMake
run: ./ci-build.sh
working-directory: rust/pact_ffi
shell: bash
- name: Run the C FFI tests
if: runner.os == 'Linux'
working-directory: c/consumer-verification
tool: cbindgen,just

- name: Install macOS dependencies
if: runner.os == 'macOS'
run: |
sudo apt update
sudo apt install libcurl4-openssl-dev
/usr/bin/aclocal
autoconf
automake --add-missing
./configure
make
src/consumer-verification basic ../../rust/target/debug/libpact_ffi.so
src/consumer-verification error ../../rust/target/debug/libpact_ffi.so
brew install \
shared-mime-info \
gettext

- name: Run C consumer examples
working-directory: c/consumer
run: just run

- name: Run C provider verification
working-directory: c/provider
run: just run

- name: Run mock_server_logs test
run: cargo test -p pact_ffi returns_mock_server_logs -- --nocapture --include-ignored
working-directory: rust
env:
RUST_LOG: debug
RUST_BACKTRACE: 1
38 changes: 17 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,26 @@

> Reference implementations for the Pact Specification written in Rust

This project contains a reference implementation of the [Pact specification](https://github.com/pact-foundation/pact-specification)
written in Rust, often referred to as the Pact Core.
This project contains a reference implementation of the [Pact specification](https://github.com/pact-foundation/pact-specification) written in Rust, often referred to as the Pact Core.

It exposes the core functionality through various crates, as part of the Pact Rust SDK, as well as through FFI (Foreign Function Interface) and CLI (Command Line Interface) for use in other programming languages.

## Usage

### Rust

For Rust projects, you can use the Rust crates from this library in your project directly. Refer to the [Rust project
readme](rust/README.md). Requires minimum Rust 1.71.0.

### Other languages
For Rust projects, you can use the Rust crates from this library in your project directly. Refer to the [Rust project readme](rust/README.md).

#### FFI
### FFI

This project contains dynamic libraries that expose the core functionality through FFI (Foreign Function Interface).
This project contains dynamic libraries that expose the core functionality through a C-compatible FFI (Foreign Function Interface).

For examples:
This project contains a couple of examples which demonstrate how to use the FFI library in a C project, with a focus on showcasing how to call the FFI functions from C:

* [C - Consumer](c/consumer-verification)
* [C - Provider](c/provider-verification)
* [Various Languages](https://github.com/YOU54F/hello_ffi)
* [C - Consumer](c/consumer)
* [C - Provider](c/provider)

For implementations:

[Ecosystem graph](https://docs.pact.io/diagrams/ecosystem#rust-ffi-consumers-goldberg-machine)
Most of the Pact SDKs in other languages make use of this FFI library to provide Pact functionality. You can see this in the [Ecosystem graph](https://docs.pact.io/diagrams/ecosystem#rust-ffi-consumers-goldberg-machine), and the following examples:

* [Javascript via pact-js-core](https://github.com/pact-foundation/pact-js-core)
* [Ruby via pact-ruby-ffi](https://github.com/YOU54F/pact-ruby-ffi)
Expand All @@ -43,7 +38,9 @@ For implementations:
* [C++ via pact-cplusplus](https://github.com/pact-foundation/pact-cplusplus)
* [Python via pact-python](https://github.com/pact-foundation/pact-python)

#### CLI
Lastly, you can also refer to [Hello Pact FFI](https://github.com/YOU54F/hello_ffi) for collection of examples in various languages.

### CLI

This project contains code to support exposing the core functionality through CLI (Command Line Interface).

Expand All @@ -55,8 +52,7 @@ They are distributed in binary & Docker formats.

## Building

To build the libraries in this project, you need a working Rust environment. Requires minimum Rust 1.59.0.
Refer to the [Rust Guide](https://www.rust-lang.org/learn/get-started).
To build the libraries in this project, you need a working Rust environment. Requires minimum Rust 1.59.0. Refer to the [Rust Guide](https://www.rust-lang.org/learn/get-started).

The build tool used is `cargo`.

Expand All @@ -73,7 +69,7 @@ See [CONTRIBUTING](CONTRIBUTING.md) (PRs are always welcome!).

## Documentation

Rust library documentation is published to the Rust documentation site. Refer to the [Rust project README](rust/README.md).
Rust library documentation is published to the Rust documentation site [`docs.rs`](https://docs.rs). Refer to the [Rust project README](rust/README.md).

Additional documentation can be found at the main [Pact website](https://pact.io).

Expand All @@ -83,8 +79,8 @@ Join us in slack: [![slack](https://slack.pact.io/badge.svg)](https://slack.pact

or

- Twitter: [@pact_up](https://twitter.com/pact_up)
- Stack Overflow: [stackoverflow.com/questions/tagged/pact](https://stackoverflow.com/questions/tagged/pact)
* Twitter: [@pact_up](https://twitter.com/pact_up)
* Stack Overflow: [stackoverflow.com/questions/tagged/pact](https://stackoverflow.com/questions/tagged/pact)

## Licensing

Expand Down
2 changes: 2 additions & 0 deletions c/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/
CMakeUserPresets.json
Loading
Loading