pipeline {
    agent any

    options {
        ansiColor('xterm')
        disableConcurrentBuilds()
        timestamps()
    }

    parameters {
        string(name: 'SHARED_LIBRARIES_VERSION', defaultValue: 'master', description: 'The version of the Jenkins shared libraries to use. Can be a branch, tag or Git revision.')
    }

    triggers {
        issueCommentTrigger('.*retest this please.*')
    }

    stages {
        stage('Load Shared Libraries') {
            steps {
                library "jenkins-global-libraries@${params.SHARED_LIBRARIES_VERSION}"
            }
        }
        stage('Checks and Static Tests') {
            parallel {
                stage('Unit tests and Style Checks') {
                    steps {
                        withEcr {
                            sh '''
                            docker compose up --build \
                                --exit-code-from lint \
                                --abort-on-container-exit \
                                --remove-orphans \
                                lint
                            '''
                        }
                    }
                }
            }
        }
    }
}
