pipeline {
    agent { label 'um-trace' }

    options {
        buildDiscarder(logRotator(numToKeepStr: '20'))
        disableConcurrentBuilds()
        timeout(time: 45, unit: 'MINUTES')
    }

    environment {
        DEVELOPER_DIR = '/Applications/Xcode.app/Contents/Developer'
        DOTNET_ROOT = '/Users/brent/.dotnet'
        DOTNET_CLI_TELEMETRY_OPTOUT = '1'
        DOTNET_NOLOGO = '1'
        NUGET_XMLDOC_MODE = 'skip'
        PATH = "/Users/brent/.dotnet:/opt/homebrew/bin:${env.PATH}"
    }

    stages {
        stage('Toolchain') {
            steps {
                sh './scripts/ci/verify-macos-agent.sh'
            }
        }

        stage('Tests') {
            steps {
                sh './scripts/ci/test.sh'
            }
        }

        stage('iOS Build (Unsigned)') {
            steps {
                sh './scripts/ci/build-ios-unsigned.sh'
            }
        }
    }

    post {
        always {
            archiveArtifacts(
                artifacts: 'artifacts/**/*',
                allowEmptyArchive: true,
                fingerprint: true
            )
        }
    }
}
