ci: support FreeBSD diagnostic workers
Win Diagnostics CI All diagnostic checks passed.
Beffroi/win-diagnostics/pipeline/head This commit looks good Details

This commit is contained in:
Dandaedre 2026-09-16 00:52:47 +02:00
parent 3b139c15db
commit c361ac62ff
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
3 changed files with 28 additions and 82 deletions

99
Jenkinsfile vendored
View File

@ -1,86 +1,38 @@
// Add this webhook in Gitea:
// http://192.168.1.37:8080/gitea-webhook/post
pipeline {
agent { label 'rust_no_docker' }
options { disableConcurrentBuilds() }
environment {
CARGO_TERM_COLOR = 'always'
CI_ARTIFACT_DIR = '.ci-artifacts'
options {
disableConcurrentBuilds()
skipDefaultCheckout(true)
}
stages {
stage('Checkout') {
steps {
checkout scm
}
steps { checkout scm }
}
stage('Validate Repository') {
steps {
sh '''
set -eu
echo "Validating Win Diagnostics repository..."
test -f README.md
test -f LICENSE
test -f AGENT.md
echo "Repository structure OK."
test -f Makefile
test -f schemas/diagnostic.schema.json
test -x tools/analyse.sh
test -x tools/validate.sh
command -v make >/dev/null 2>&1
command -v jq >/dev/null 2>&1
command -v uv >/dev/null 2>&1
jq --version
uv --version
'''
}
}
/*
* Windows collection is intentionally NOT run here.
*
* This Jenkins agent is not the target Windows machine.
*
* Collection scripts should eventually receive separate
* Windows-specific validation if a suitable CI worker becomes
* available.
*/
stage('Validate Contract') {
steps {
sh '''
set -eu
command -v uv >/dev/null 2>&1 || { echo "uv is required for the isolated validation environment" >&2; exit 1; }
command -v jq >/dev/null 2>&1 || { echo "jq is required" >&2; exit 1; }
make test
'''
}
stage('Test') {
steps { sh 'make test' }
}
/*
* TODO: Analysis Tests
*
* Once sanitized diagnostic fixtures exist:
*
* fixtures/
*
* run the analysis engine against them.
*
* This should be platform-independent wherever practical.
*/
/*
* TODO: Regression Tests
*
* Known diagnostic inputs should produce expected findings,
* severity and evidence relationships.
*/
/*
* No rendering or publishing stages belong here.
*
* Win Diagnostics produces structured diagnostic information.
* It does not own reports or PDFs.
*/
}
post {
@ -88,40 +40,31 @@ pipeline {
publishChecks(
conclusion: 'SUCCESS',
name: 'Win Diagnostics CI',
summary: 'Win Diagnostics passed all currently implemented CI checks.',
text: 'Repository, diagnostic contract, and first offline-analysis fixture tests passed. Native collection and remaining rules remain pending.',
summary: 'All diagnostic checks passed.',
text: 'Contracts, evidence integrity, fixtures, rules, watchlists, and the shell/jq runtime passed.',
title: 'Win Diagnostics CI passed'
)
echo '✅ Win Diagnostics CI passed.'
}
failure {
publishChecks(
conclusion: 'FAILURE',
name: 'Win Diagnostics CI',
summary: 'Win Diagnostics failed CI.',
text: 'A repository or validation check failed. Check the Jenkins log.',
summary: 'A diagnostic check failed.',
text: 'Review the Jenkins log for the failing contract, fixture, rule, or runtime check.',
title: 'Win Diagnostics CI failed'
)
echo '❌ Win Diagnostics CI failed.'
}
unstable {
publishChecks(
conclusion: 'ACTION_REQUIRED',
name: 'Win Diagnostics CI',
summary: 'Win Diagnostics CI is unstable.',
text: 'The Jenkins build completed with an unstable status.',
summary: 'The diagnostic build is unstable.',
text: 'Review the Jenkins log for unstable checks.',
title: 'Win Diagnostics CI unstable'
)
echo '⚠️ Win Diagnostics CI is unstable.'
}
always {
echo 'CI finished.'
}
}
}

View File

@ -2,17 +2,19 @@
set -euo pipefail
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
fail(){ echo "error: $*" >&2; exit 1; }; usage(){ echo "Usage: $0 INPUT --evidence-root DIR --output FILE --reference-time TIME --producer-version VERSION [--force]" >&2; exit 2; }
sha256_file(){ if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1"|awk '{print $1}'; elif command -v sha256 >/dev/null 2>&1; then sha256 -q "$1"; else openssl dgst -sha256 "$1"|awk '{print $NF}'; fi; }
input=${1:-}; [[ -n "$input" ]] || usage; shift
evidence_root= output= reference_time= producer_version= force=false
while (($#)); do case $1 in --evidence-root) evidence_root=$2;shift 2;;--output) output=$2;shift 2;;--reference-time) reference_time=$2;shift 2;;--producer-version) producer_version=$2;shift 2;;--force) force=true;shift;;*) usage;;esac;done
for value in "$evidence_root" "$output" "$reference_time" "$producer_version"; do [[ -n "$value" ]]||usage; done
[[ ! -L "$input" ]] || fail "input symlinks are not supported"
input=$(realpath "$input"); evidence_root=$(realpath "$evidence_root"); output=$(realpath -m "$output")
input=$(realpath "$input"); evidence_root=$(realpath "$evidence_root")
output_parent=$(dirname "$output"); mkdir -p "$output_parent"; output=$(cd "$output_parent" && pwd -P)/$(basename "$output")
[[ "$input" == "$evidence_root"/* ]] || fail "input must be inside --evidence-root"
[[ "$input" != "$output" ]] || fail "input and output paths must differ"
[[ ! -e "$output" || "$force" == true ]] || fail "$output: output exists; use --force to replace it"
artifact=${input#"$evidence_root/"}; hash=$(sha256sum "$input"|awk '{print $1}')
mkdir -p "$(dirname "$output")"; temporary=$(mktemp "$(dirname "$output")/.${output##*/}.XXXXXXXX"); trap 'rm -f "$temporary"' EXIT
artifact=${input#"$evidence_root/"}; hash=$(sha256_file "$input")
temporary=$(mktemp "$(dirname "$output")/.${output##*/}.XXXXXXXX"); trap 'rm -f "$temporary"' EXIT
jq --arg artifact "$artifact" --arg artifact_hash "$hash" --arg reference_time "$reference_time" --arg producer_version "$producer_version" \
--slurpfile rules "$root/rules/event-rules.json" --slurpfile watchlist "$root/rules/watchlist.json" \
-f "$root/tools/analyse.jq" "$input" >"$temporary" || fail "analysis failed"

View File

@ -1,6 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
usage(){ echo "Usage: $0 INPUT [--evidence-root DIR]" >&2; exit 2; }; fail(){ echo "error: $*" >&2; exit 1; }
sha256_file(){ if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1"|awk '{print $1}'; elif command -v sha256 >/dev/null 2>&1; then sha256 -q "$1"; else openssl dgst -sha256 "$1"|awk '{print $NF}'; fi; }
input=${1:-}; [[ -n "$input" ]]||usage; shift; evidence_root=
while (($#)); do case $1 in --evidence-root) evidence_root=$2;shift 2;;*) usage;;esac; done
jq -e '
@ -19,7 +20,7 @@ if [[ -n "$evidence_root" ]]; then
[[ "$artifact" != /* && "$artifact" != *..* && "$artifact" != *\\* ]] || fail "source artifact escapes evidence root"
source=$(realpath "$evidence_root/$artifact"); root=$(realpath "$evidence_root")
[[ "$source" == "$root"/* && -f "$source" ]] || fail "source artifact escapes evidence root"
expected=$(jq -r '.metadata.source.sha256' "$input"); actual=$(sha256sum "$source"|awk '{print $1}')
expected=$(jq -r '.metadata.source.sha256' "$input"); actual=$(sha256_file "$source")
[[ "$actual" == "$expected" ]] || fail "evidence checksum differs"
jq -e --slurpfile raw "$source" '
$raw[0] as $raw | all(.observations[]; . as $observation |