55 lines
2.6 KiB
Markdown
55 lines
2.6 KiB
Markdown
# contract-test (Dagger module)
|
|
|
|
> **Verified 2026-07-16**: dagger v0.21.7 `develop` + `go build` + `dagger
|
|
> functions` pass. Generated code (`dagger.gen.go`, `internal/`) is
|
|
> gitignored; run `dagger develop` to regenerate.
|
|
|
|
IntegraCI contract testing module. Runs [Pact](https://pact.io) consumer
|
|
contract tests, publishes the generated pacts to a Pact Broker, runs a
|
|
`can-i-deploy` gate (pact-cli), and optionally POSTs the result to the
|
|
IntegraCI API.
|
|
|
|
## Functions
|
|
|
|
### `verify`
|
|
|
|
Runs consumer contract tests, publishes pacts, runs the can-i-deploy gate,
|
|
and posts results.
|
|
|
|
| Parameter | Required | Default | Description |
|
|
| -------------- | -------- | ---------------------- | -------------------------------------------------------- |
|
|
| `source` | yes | — | Source directory containing the consumer project + pacts |
|
|
| `broker-url` | no | — | Pact Broker URL to publish/query against |
|
|
| `broker-token` | no | — | Pact Broker authentication token |
|
|
| `consumer` | no | `integraci-consumer` | Consumer application name as registered in the broker |
|
|
| `version` | no | `dev` | Version tag applied to published pacts (e.g. git SHA) |
|
|
| `tool` | no | `pact` | Pact tooling CLI command family |
|
|
| `api-url` | no | — | IntegraCI API URL for posting results |
|
|
| `token` | no | — | JWT token for API authentication |
|
|
| `service-id` | no | — | Service ID to link contract results |
|
|
|
|
Returns a `ContractResult` with consumer-test status, publish status,
|
|
can-i-deploy verdict, post status, and overall success.
|
|
|
|
## Usage
|
|
|
|
```sh
|
|
dagger call verify \
|
|
--source . \
|
|
--broker-url https://broker.example.com \
|
|
--broker-token "$PACT_BROKER_TOKEN" \
|
|
--consumer integraci-consumer \
|
|
--version "$GIT_SHA" \
|
|
--api-url http://localhost:8000 \
|
|
--token "$TOKEN" \
|
|
--service-id "$SVC_ID"
|
|
```
|
|
|
|
## Pre-use checklist
|
|
|
|
1. `dagger develop` — generate the SDK bindings (`dag`, `*Directory`, etc.).
|
|
2. `dagger functions` — confirm `verify` is discovered with the expected args.
|
|
3. Run `verify` against a real consumer project + Pact Broker and confirm the
|
|
consumer tests, publish step, and can-i-deploy gate behave as intended.
|
|
4. Confirm the pact-cli image tag and CLI flags match your broker version.
|