// CI pipeline for Scrap-Web (SSW 590, Continuous Integration with Jenkins).
// Runs for every pull request through the Multibranch Pipeline job and reports
// its result to Gitea as a commit status. Uses only the Python 3 standard
// library, so no packages are downloaded during the build.
pipeline {
    // Builds run on the Jenkins controller executor (see the IT manual for the
    // documented risk). python3 must be installed in the Jenkins container.
    agent any

    options {
        skipDefaultCheckout()
        timeout(time: 10, unit: 'MINUTES')
    }

    stages {
        stage('Checkout') {
            steps {
                checkout scm
                // Record exactly which commit is being tested, for traceability.
                sh 'git rev-parse HEAD'
                sh 'python3 --version'
            }
        }
        stage('Syntax check') {
            steps {
                sh 'python3 -m py_compile pricing.py tests/test_pricing.py'
            }
        }
        stage('Test') {
            steps {
                sh 'python3 -m unittest discover -s tests -v'
            }
        }
    }

    post {
        success { echo 'All checks passed.' }
        failure { echo 'A stage failed: see the stage view for which one.' }
    }
}
