pipeline {
    agent any

    environment {
        TAGS = "@accounting-run"
        SLACK_CHANNEL = '#accounting-tech'
    }

    options {
        ansiColor('xterm')
        disableConcurrentBuilds()
        timestamps()
        timeout(time: 1, unit: 'HOURS')
        buildDiscarder(logRotator(numToKeepStr: '60'))
    }

    triggers {
        cron('0 5 * * 0') // Every Sunday at 5 AM
    }

    stages {
        stage('Load Shared Libraries') {
            steps {
                library "jenkins-global-libraries@master"
            }
        }

        stage('Run ABACUS Accounting Run E2E Tests') {
            steps {
                script {
                    playwrightTests(
                        tags: env.TAGS,
                        runtimeEnvironment: 'ecs',
                        reportSuffix: 'abacus-accounting-run',
                        slackNotificationChannels: [env.SLACK_CHANNEL]
                    )
                }
            }
        }
    }
}