Skip to content

Commit 79d3763

Browse files
committed
chore: Add Claude.md
1 parent a57ae0e commit 79d3763

1 file changed

Lines changed: 112 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Overview
6+
7+
This is the reference implementation of [Pact](https://pact.io) contract testing written in Rust. It provides shared libraries for consumer and provider testing, with FFI bindings for use in other languages. The project supports Pact specification V1–V4.
8+
9+
> Note: The mock server crates (`pact_mock_server`, `pact_mock_server_cli`) have moved to https://github.com/pact-foundation/pact-core-mock-server and are excluded from this workspace.
10+
11+
## Build & Test Commands
12+
13+
All Cargo commands must be run from the `rust/` subdirectory (the workspace root):
14+
15+
```bash
16+
cd rust
17+
18+
# Build all crates
19+
cargo build
20+
21+
# Run all tests
22+
cargo test
23+
24+
# Run tests for a specific crate
25+
cargo test --package pact_models
26+
27+
# Run a single test by name (exact match)
28+
cargo test --package pact_models -- my_test_name --exact
29+
30+
# Run tests in a specific module
31+
cargo test --package pact_matching headers::tests
32+
33+
# Run tests with log output
34+
RUST_LOG=debug cargo test -- --nocapture
35+
36+
# Lint
37+
cargo clippy
38+
39+
# Check without building (faster)
40+
cargo check
41+
42+
# Release build (strip=true, opt-level="z")
43+
cargo build --release
44+
```
45+
46+
### WASM targets (pact_models and pact_matching only)
47+
48+
```bash
49+
cargo build --target wasm32-wasip2
50+
```
51+
52+
### Cross-compilation / MUSL static builds
53+
54+
```bash
55+
docker run --rm --user "$(id -u)":"$(id -g)" \
56+
-v $(pwd):/workspace -w /workspace/rust \
57+
-t -e TZ=UTC pactfoundation/rust-musl-build \
58+
./scripts/ci-musl-build.sh
59+
```
60+
61+
## Crate Architecture
62+
63+
The dependency graph flows upward — each layer depends on those below it:
64+
65+
```
66+
pact_models ← Pact data structures, reading/writing pact files
67+
68+
pact_matching ← Request/response matching logic
69+
↑ ↖
70+
pact_verifier pact_consumer ← Verification library / Consumer DSL
71+
↑ ↑
72+
pact_verifier_cli pact_ffi ← Standalone CLI / C FFI bindings
73+
```
74+
75+
### Crates
76+
77+
- **pact_models**: Core data structures for Pact contracts. Handles JSON serialization of pact files. WASM-compatible (no `tokio`/`reqwest` on WASM). Features: `datetime`, `xml`, `form_urlencoded`.
78+
79+
- **pact_matching**: Implements all matching rules and interaction matching. Supports plugin-based extensibility via `pact-plugin-driver`. Features: `datetime`, `xml`, `plugins`, `multipart`, `form_urlencoded`.
80+
81+
- **pact_consumer**: DSL for writing consumer tests in Rust. Integrates with `pact_mock_server` (external repo). Features: `datetime`, `xml`, `plugins`, `multipart`, `tls`, `colour`.
82+
83+
- **pact_verifier**: Core provider verification logic (library). Compiled as `cdylib` + `rlib`. Features: `datetime`, `xml`, `plugins`, `multipart`.
84+
85+
- **pact_ffi**: C-compatible FFI layer exposing consumer and verifier APIs. Compiled as `cdylib`, `staticlib`, and `rlib`. Uses Rust edition 2021 (differs from other crates, which use 2024).
86+
87+
- **pact_verifier_cli**: Command-line tool wrapping `pact_verifier`. Features include `junit` output format.
88+
89+
## Key Conventions
90+
91+
- **Rust edition**: 2024 for all crates except `pact_ffi` (2021).
92+
- **Minimum Rust version**: 1.88.0 (required for edition 2024).
93+
- **Async runtime**: `tokio` throughout (except WASM builds).
94+
- **Logging**: `tracing` / `tracing-subscriber` (not `log`).
95+
- **Test helpers**: `rstest`, `hamcrest2`, `expectest`, `pretty_assertions` are common dev-dependencies.
96+
- **Workspace patch**: `pact_models` is patched in `rust/Cargo.toml` to always use the local path (`./pact_models`), so changes propagate across all crates without a publish.
97+
98+
## Commit Messages
99+
100+
Follow [Conventional Changelog](https://github.com/bcoe/conventional-changelog-standard/blob/master/convention.md) format:
101+
- `feat: ...` for new features
102+
- `fix: ...` for bug fixes
103+
- `chore: ...` for maintenance
104+
- `refactor: ...` for refactoring
105+
106+
## Compatibility Suite
107+
108+
BDD-style integration tests covering V1–V4 spec compliance live in `/compatibility-suite/`. These use the `cucumber` framework and run separately from the main workspace tests.
109+
110+
## Releasing
111+
112+
Each crate has a `release.groovy` script that guides the release process and updates changelogs. Releases are published to [crates.io](https://crates.io) and tagged on GitHub. CI builds attach platform binaries to each GH release.

0 commit comments

Comments
 (0)