Tutorial 3: Wire CI/CD quality gates
Tutorial 3 — Wire Stratix evaluations into GitHub Actions to gate AI changes.
Last updated
Was this helpful?
Was this helpful?
import os
import sys
from layerlens import Stratix
client = Stratix(api_key=os.environ["LAYERLENS_STRATIX_API_KEY"])
# Re-run the gating space
space_id = "your-space-id"
run = client.spaces.run(space_id=space_id)
result = client.spaces.wait_for_completion(run.id, timeout=600)
# Fetch baseline (most recent main-branch run)
baseline = client.spaces.latest_run(space_id=space_id, branch="main")
# Compare
delta = result.score - baseline.score
tolerance = 0.01
print(f"Score: {result.score}")
print(f"Baseline: {baseline.score}")
print(f"Delta: {delta:.4f}")
if delta < -tolerance:
print("REGRESSION beyond tolerance — failing the build.")
sys.exit(1)
else:
print("OK")name: AI Eval Gate
on:
pull_request:
paths:
- 'src/prompts/**'
- 'src/agents/**'
jobs:
eval:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install
run: |
pip install layerlens --extra-index-url https://sdk.layerlens.ai/package
- name: Run eval
run: python scripts/ci-eval.py
env:
LAYERLENS_STRATIX_API_KEY: ${{ secrets.LAYERLENS_STRATIX_API_KEY }}