pipeline {
    agent { label 'rust_no_docker' }

    options {
        disableConcurrentBuilds()
        skipDefaultCheckout(true)
    }

    stages {
        stage('Checkout') {
            steps { checkout scm }
        }

        stage('Test') {
            steps { sh './tests/test.sh' }
        }
    }

    post {
        success {
            publishChecks(
                conclusion: 'SUCCESS',
                name: 'Win Diagnostics CI',
                summary: 'All diagnostic checks passed.',
                text: 'Contracts, evidence integrity, fixtures, rules, watchlists, and the shell/Typst runtime passed.',
                title: 'Win Diagnostics CI passed'
            )
            echo '✅ Win Diagnostics CI passed.'
        }
        failure {
            publishChecks(
                conclusion: 'FAILURE',
                name: 'Win Diagnostics CI',
                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: 'The diagnostic build is unstable.',
                text: 'Review the Jenkins log for unstable checks.',
                title: 'Win Diagnostics CI unstable'
            )
            echo '⚠️ Win Diagnostics CI is unstable.'
        }
    }
}
