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: 'Reportist CI',
                summary: 'Both renderer plugin suites passed.',
                text: 'Standalone report and diagnostic rendering, analysis, and validation passed.',
                title: 'Reportist CI passed'
            )
            echo '✅ Reportist CI passed.'
        }
        failure {
            publishChecks(
                conclusion: 'FAILURE',
                name: 'Reportist CI',
                summary: 'A validation or rendering check failed.',
                text: 'Review the Jenkins log for the failing plugin check.',
                title: 'Reportist CI failed'
            )
            echo '❌ Reportist CI failed.'
        }
        unstable {
            publishChecks(
                conclusion: 'ACTION_REQUIRED',
                name: 'Reportist CI',
                summary: 'The Reportist build is unstable.',
                text: 'Review the Jenkins log for unstable checks.',
                title: 'Reportist CI unstable'
            )
            echo '⚠️ Reportist CI is unstable.'
        }
    }
}
