Files
pruefwerk/.gitea/workflows/nightly.yml
T
sharang b247c5b359
CI / Check (push) Skipped
CI / Detect Changes (push) Successful in 4s
CI / Deploy Docs (push) Successful in 1m25s
CI / Deploy MCP (push) Successful in 5m21s
CI / Deploy Agent (push) Successful in 10m24s
CI / Deploy Dashboard (push) Successful in 11m57s
fix(llm): nightly uses the gateway's models; no OpenAI defaults (#575)
2026-10-29 07:43:21 +00:00

219 lines
9.1 KiB
YAML

name: Nightly scan regression
# Scans the fixture corpus (fixtures/demo-targets and fixtures/nightly) with
# the agent image built from main and compares the results with the blessed
# baselines in fixtures/nightly/baselines (#188, epic #309). A regression
# anywhere between a tool bump and a parser change turns this red before a
# customer sees it.
#
# Run it by hand with "bless" ticked after an intended change: the job then
# rewrites the baselines instead of comparing, and the new files are in the
# `nightly-report` artifact to commit.
on:
schedule:
- cron: '0 3 * * *' # 3 AM UTC daily
workflow_dispatch:
inputs:
bless:
description: "Rewrite the baselines from this run (commit them from the artifact)"
type: boolean
default: false
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"
RUSTC_WRAPPER: /usr/local/bin/sccache
SCCACHE_BUCKET: bp-sccache
SCCACHE_ENDPOINT: https://nbg1.your-objectstorage.com
SCCACHE_REGION: auto
SCCACHE_S3_USE_SSL: "true"
SCCACHE_S3_KEY_PREFIX: compliance-scanner
AWS_ACCESS_KEY_ID: ${{ secrets.HETZNER_S3_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.HETZNER_S3_SECRET_KEY }}
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
CARGO_NET_RETRY: "10"
CARGO_HTTP_MULTIPLEXING: "false"
concurrency:
group: nightly-scans
cancel-in-progress: true
jobs:
scans:
name: Scan regression
runs-on: docker
container:
image: rust:1.94-bookworm
services:
mongo:
image: mongo:7
env:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
# The image main deployed. Dev mode (no Keycloak): the harness talks to
# the unauthenticated dev tenant; source_only matches staging.
agent:
image: repo.breakpilot.com/pruefwerk/compliance-agent:latest
credentials:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
env:
APP_ENV: dev
MONGODB_URI: mongodb://root:example@mongo:27017/?authSource=admin
MONGODB_DATABASE: nightly
PW_FEATURES: source_only
# Optional. Without an LLM the control judge stamps no control refs,
# which the report lists as advisory; it never fails the run.
LITELLM_URL: ${{ secrets.NIGHTLY_LITELLM_URL }}
LITELLM_API_KEY: ${{ secrets.NIGHTLY_LITELLM_API_KEY }}
# The models stage and prod run. Without them the agent asked for
# gpt-4o / text-embedding-3-small, which the gateway refuses (425
# failed requests a night until 2026-10-28).
LITELLM_MODEL: Qwen3.8-27B
LITELLM_EMBED_MODEL: bge-multilingual-gemma2
# Optional. The CODESYS CVE match queries NVD, which rate-limits
# unauthenticated clients; a key keeps those CVEs from going missing.
NVD_API_KEY: ${{ secrets.NIGHTLY_NVD_API_KEY }}
steps:
- name: Checkout
run: |
git init
git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
git fetch --depth=1 origin "${GITHUB_SHA:-refs/heads/main}"
git checkout FETCH_HEAD
- name: Use Kellnr crates.io mirror
run: |
: "${CARGO_HOME:=/usr/local/cargo}"
mkdir -p "$CARGO_HOME"
{
echo '[source.crates-io]'
echo 'replace-with = "kellnr"'
echo '[registries.kellnr]'
echo 'index = "sparse+https://crates.breakpilot.com/api/v1/cratesio/"'
} >> "$CARGO_HOME/config.toml"
env:
RUSTC_WRAPPER: ""
- name: Install sccache
run: |
curl -fsSL https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-x86_64-unknown-linux-musl.tar.gz \
| tar xz --strip-components=1 -C /usr/local/bin/ sccache-v0.10.0-x86_64-unknown-linux-musl/sccache
chmod +x /usr/local/bin/sccache
env:
RUSTC_WRAPPER: ""
# The harness links compliance-agent, which depends on the private
# firmwerk repo; same PAT rewrite as in ci.yml.
- name: Configure git auth for the private firmwerk dependency
run: |
git config --global \
url."https://platform-ci:${{ secrets.PLATFORM_CI_TOKEN }}@git.breakpilot.com/".insteadOf \
"ssh://git@git.breakpilot.com:22222/"
env:
RUSTC_WRAPPER: ""
# The real CODESYS sample is ~10 MB, so it is fetched at a pinned commit
# and checksum rather than committed. fixtures/nightly/targets.json skips
# its target where NIGHTLY_CODESYS_SAMPLE is unset.
- name: Fetch the CODESYS sample
run: |
curl -fsSL -o /tmp/csv-blackbox.projectarchive \
"https://github.com/Proemion/codesys-examples/raw/164d8eea7b7483f764b4959788fd2a733624e576/CSV-BlackBox-Writter/CSV-BlackBox-Writter.projectarchive"
echo "8e1150728e33fc0f5e2572bc060545497cfa64308c927c0d81ecda71873db265 /tmp/csv-blackbox.projectarchive" \
| sha256sum -c -
env:
RUSTC_WRAPPER: ""
# The upstream Zephyr example application, at a pinned commit so the
# result does not drift with upstream main. codeload zips are not
# byte-stable, so the commit pin (not a checksum) is the guarantee.
- name: Fetch the Zephyr example application
run: |
curl -fsSL -o /tmp/zephyr-example.zip \
"https://codeload.github.com/zephyrproject-rtos/example-application/zip/38a6d9b276ed434454900130cacc87d058d3ac62"
env:
RUSTC_WRAPPER: ""
# Public mobile apps at pinned commits (MIT, Apache-2.0): a current
# SwiftUI app and a large Android app, so the mobile checks meet real
# projects, not only the hand-written fixtures. Not committed, as with
# the Zephyr example.
- name: Fetch the public mobile samples
run: |
curl -fsSL -o /tmp/ios-sample.zip \
"https://codeload.github.com/nalexn/clean-architecture-swiftui/zip/9eca97b8cfff96a14084b564b1fefd949c93d232"
curl -fsSL -o /tmp/android-sample.zip \
"https://codeload.github.com/android/nowinandroid/zip/a49ed253d75e61a2b6ab80a8da677b57437b08eb"
env:
RUSTC_WRAPPER: ""
- name: Wait for the agent
run: |
for i in $(seq 1 90); do
curl -fsS http://agent:3001/api/v1/health && exit 0
sleep 2
done
echo "agent did not become healthy" >&2
exit 1
env:
RUSTC_WRAPPER: ""
- name: Scan the corpus and compare with the baselines
run: cargo test -p compliance-agent --test nightly -- --nocapture
env:
NIGHTLY_AGENT_URL: http://agent:3001
NIGHTLY_CODESYS_SAMPLE: /tmp/csv-blackbox.projectarchive
NIGHTLY_ZEPHYR_EXAMPLE: /tmp/zephyr-example.zip
NIGHTLY_IOS_SAMPLE: /tmp/ios-sample.zip
NIGHTLY_ANDROID_SAMPLE: /tmp/android-sample.zip
NIGHTLY_BLESS: ${{ inputs.bless && '1' || '0' }}
# upload-artifact is a Node action and the Rust image has no node.
- name: Install node for the artifact upload
if: always()
run: |
apt-get update -qq
apt-get install -y -qq --no-install-recommends nodejs >/dev/null
env:
RUSTC_WRAPPER: ""
- name: Keep the report and this run's snapshots
if: always()
uses: actions/upload-artifact@v3
with:
name: nightly-report
path: |
target/nightly/
fixtures/nightly/baselines/
# One open issue tracks a red nightly: opened on the first failure,
# commented on while it stays red. Needs NIGHTLY_ALERT_TOKEN (issue write
# on this repo); without it the job still fails, just without the issue.
- name: Alert
if: failure() && github.event_name == 'schedule'
env:
RUSTC_WRAPPER: ""
TOKEN: ${{ secrets.NIGHTLY_ALERT_TOKEN }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
if [ -z "$TOKEN" ]; then
echo "::warning::NIGHTLY_ALERT_TOKEN is not set; not opening an issue"
exit 0
fi
api="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
title="Nightly scan regression is red"
body="The nightly scan regression failed: ${RUN_URL} (report in the nightly-report artifact)."
number=$(curl -fsS -H "Authorization: token $TOKEN" \
"$api/issues?state=open&type=issues&q=$(printf %s "$title" | sed 's/ /%20/g')" \
| python3 -c "import json,sys; print(next((i['number'] for i in json.load(sys.stdin) if i['title']==sys.argv[1]), ''))" "$title")
payload=$(python3 -c "import json,sys; print(json.dumps({'title': sys.argv[1], 'body': sys.argv[2]}))" "$title" "$body")
if [ -n "$number" ]; then
curl -fsS -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
"$api/issues/$number/comments" -d "$payload" >/dev/null
else
curl -fsS -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
"$api/issues" -d "$payload" >/dev/null
fi