Skip to content

Integrate Aval in 5 files

Goal: put a monorepo's CI on Aval by adding 2 files and editing at most 3, without touching the Makefile or the scripts.

flowchart LR
  a[aval.yaml<br>added] --> j[suite jobs:<br>aval run action]
  p[.github/aval/policy.yaml<br>added] -- from the default branch --> j
  w[ci.yml<br>edited] --> j
  j -- "push to main" --> pub[publish job:<br>aval publish action] --> reg([registry]):::muted
  g[.gitignore<br>edited]:::muted

The example is examples/github-monorepo: a Go module (cmd/, internal/, pkg/), a Node UI, a Dockerfile, a data directory, an end-to-end suite in 3 shards and one suite that calls an outside service. Aval's tests check that its integration is exactly these files, and run every test through the CLI.

1. Add aval.yaml

One TestSet: defaults for every test, a fragment per part of the repo, and a matrix for the shards. Each test reads only its fragments, so a change to ui/ reruns ui and nothing else:

# Every test CI runs through Aval, and the files each one reads.
# test-external calls a service this repository does not control, so it is
# not here: CI runs it as a plain make job.
apiVersion: aval.trianalab.io/v1
kind: TestSet
defaults:
  scope:
    dependencies: [Makefile]
  cacheability: hermetic
fragments:
  go:
    scope:
      source: ["cmd/**", "internal/**", "pkg/**"]
      dependencies: [go.mod]
    environment:
      toolchain: {go: "1.25"}
      env: [GOFLAGS, CGO_ENABLED]
  ui:
    scope:
      source: ["ui/src/**", "ui/test/**"]
      dependencies: [ui/package.json, ui/package-lock.json]
    environment:
      toolchain: {node: "24"}
  image:
    scope:
      source: [Dockerfile, "data/**"]
      allowMutable:
        - files: ["data/fixtures/*.yaml"]
          ref: ghcr.io/stefanprodan/podinfo:6.5.0
          reason: public demo workload; the e2e suite only starts it
tests:
  - metadata: {name: unit}
    use: [go]
    runner: {command: [make, test]}
    outputs: [coverage.out]
  - metadata: {name: ui}
    use: [ui]
    runner: {command: [make, ui]}
  - metadata: {name: "e2e-{shard}"}
    use: [go, image]
    runner: {command: [make, e2e, "SHARD={shard}"]}
    scope: {source: ["e2e/**"]}
    matrix: {shard: ["1", "2", "3"]}
    cacheability: controlled-environment
  • allowMutable[].files accepts the one tag the data fixtures share, in those files only. The same tag anywhere else blocks reuse.
  • outputs restores coverage.out when unit is reused.
  • Check every test without running anything: aval explain --all.

Leave out what must always run: a non-deterministic test is never reused, and an external-dependencies test only when the policy lists it in allowedCacheability (Trust model). Here test-external stays a plain make job.

2. Add the trust policy

One runner identity, this workflow on main, and the registry results go to:

# The trust policy. The run and publish actions read it from the default
# branch only, so a pull request that edits it changes nothing.
apiVersion: aval.trianalab.io/v1
kind: Policy
registry: ghcr.io/acme/monorepo-aval
minTrustLevel: runner
identities:
  - issuer: https://token.actions.githubusercontent.com
    subjectRegexp: https://github\.com/acme/monorepo/\.github/workflows/ci\.yml@refs/heads/main
    trustLevel: runner

3. Edit the workflow

In each suite job, the make step becomes the run action:

      - uses: TrianaLab/aval/integrations/github/run@f5bc5993f33d45596105408e026a732d5933dbdb # v0.12.1
        with:
          test: unit

A matrix job names its shard, so each shard is its own test and artifact:

      - uses: TrianaLab/aval/integrations/github/run@f5bc5993f33d45596105408e026a732d5933dbdb # v0.12.1
        with:
          test: e2e-${{ matrix.shard }}

Add one publish job:

  publish:
    needs: [unit, ui, e2e]
    if: ${{ !cancelled() && github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
      id-token: write
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: TrianaLab/aval/integrations/github/publish@f5bc5993f33d45596105408e026a732d5933dbdb # v0.12.1

4. Ignore .aval/

Add .aval/ to .gitignore: each test writes its result there. Optionally, say in CONTRIBUTING.md that CI reuses results.

Each action installs the aval release its commit pins. The example pins the commit that pins the latest release.

The run action's artifact carries coverage.out, the output of unit, and the publish job pushes it from there, not from its own checkout (the artifact).

Before you start

Pinning is project work, not part of these files: base images by digest, lockfiles in scope.dependencies, tools at fixed versions. Until then Aval reports each mutable reference and reuses nothing for that test (Pin your dependencies).

Security

  • Require code-owner review of .github/workflows/ and .github/aval/: a pull request controls its own workflow file.
  • Trust refs/heads/main only. A runner-level identity for refs/pull/ lets any pull request sign results that are reused.
  • Publish only on a push to the default branch, from a job that runs no tests.
  • The publish action is a composite action, not a reusable workflow, so the certificate names your workflow (Why a composite action).

Other CI systems

A wrapper for another CI system has the same duties as the two actions:

  • Install a pinned aval release and verify it (sha256, signature).
  • Read the policy from the protected branch, never from the checkout.
  • Give suite jobs no signing credentials; sign in a separate job.
  • Never swallow exit 5: fail the job and show the security event.
  • Keep one artifact per test (.aval/<test>/), named after the test.
  • Publish only on protected refs, with that job's own identity.