Skip to content

Depend on another part of the repo

Goal: in a monorepo, rerun the frontend tests when the backend's inputs change, without copying the backend's globs.

flowchart LR
  f[frontend/aval.yaml] -- scope.contracts --> b[backend/aval.yaml]
  b --> bs(["backend scope: api/**"])
  bs -. change .-> miss([frontend misses and runs]):::err

The example

The frontend names the backend's contract:

frontend/aval.yaml
apiVersion: aval.trianalab.io/v1
kind: Test
metadata:
  name: frontend
runner:
  command: ["sh", "test.sh"]
scope:
  source: ["src/**", "test.sh"]
  contracts: ["../backend/aval.yaml"]
cacheability: hermetic
backend/aval.yaml
apiVersion: aval.trianalab.io/v1
kind: Test
metadata:
  name: backend
runner:
  command: ["go", "test", "./..."]
scope:
  source: ["api/**"]
cacheability: hermetic

The frontend's fingerprint now includes the backend's:

  • a change in the backend's scope: the frontend misses and runs;
  • a change outside it (a backend README): still reused;
  • contracts the backend names count too.

aval explain shows the link:

contract ../backend/aval.yaml backend sha256:<backend fingerprint>
depends on ../backend/aval.yaml (backend) sha256:<backend fingerprint>
  • Paths are relative and stay inside the git working tree. No other repositories.
  • If Aval cannot read the other contract, the test runs.
  • A mutable reference in the backend blocks the frontend too; only the backend's scope.allowMutable accepts it.

Using only the backend's interface (a generated client)? List the API file (OpenAPI, .proto) in scope.dependencies instead.

Workspaces

uv, pnpm and cargo keep one lockfile at the root, and globs cannot use ... Two layouts work. Either one contract per member at the root:

aval.api.yaml
apiVersion: aval.trianalab.io/v1
kind: Test
metadata:
  name: api-unit
runner:
  command: ["uv", "run", "--package", "api", "pytest", "packages/api/tests"]
scope:
  source: ["packages/api/**"]
  dependencies: ["pyproject.toml", "uv.lock"]
cacheability: hermetic

Or a root contract owns the lockfile, and members name it (scope.contracts may use ..):

aval.lock.yaml
apiVersion: aval.trianalab.io/v1
kind: Test
metadata:
  name: workspace-lock
runner:
  command: ["uv", "lock", "--check"]
scope:
  source: ["pyproject.toml"]
  dependencies: ["uv.lock"]
cacheability: hermetic
packages/api/aval.yaml
apiVersion: aval.trianalab.io/v1
kind: Test
metadata:
  name: api-unit
runner:
  command: ["uv", "run", "pytest", "tests"]
scope:
  source: ["src/**", "tests/**", "pyproject.toml"]
  contracts: ["../../aval.lock.yaml"]
cacheability: hermetic

Any lockfile change reruns every member.

Tool Root files to hash Lockfile check
uv pyproject.toml, uv.lock uv lock --check
pnpm package.json, pnpm-workspace.yaml, pnpm-lock.yaml pnpm install --frozen-lockfile
cargo Cargo.toml, Cargo.lock cargo metadata --locked

A member that imports another member lists that member's sources too, or names its contract.

Also check root config (tsconfig.base.json, .npmrc, conftest.py, pytest.ini, .cargo/config.toml, rust-toolchain.toml, .python-version, .nvmrc), patches, build scripts, shared fixtures and environment variables (environment.env): find undeclared inputs.