#!/usr/bin/env groovy

AWS_REGION = "us-west-2"
DEV_CREDENTIALS_ID = "twitch-gds-dev"

pipeline {
    agent any
    options {
        ansiColor('xterm')
    }

    stages {
        stage("Sanity Check") {
            steps {
                validateDeclarativePipeline 'Jenkinsfile'
                sh 'printenv'
            }
        }

        stage("Run Integration Tests") {
            steps {
                checkout scm
                withAWS(credentials: DEV_CREDENTIALS_ID, region: AWS_REGION) {
                    sh 'bin/run_tests'
                }
            }
        }
    }

    post {
        always {
            publishHTML(target: [
                allowMissing: false,
                alwaysLinkToLastBuild: true,
                keepAll: true,
                reportDir: 'testoutput',
                reportFiles: 'report.html',
                reportName: 'Test Report'
            ])
        }
    }
}
