pipeline {
  agent none
  options {
    disableConcurrentBuilds()
    buildDiscarder(logRotator(numToKeepStr: '8', daysToKeepStr: '20'))
    timeout(time: 1, unit: 'HOURS')
  }
  stages {
    stage('main') {
      agent {
        dockerfile {
        dir 'ci'
        args '--gpus 1'
        }
      }
      environment {
        HOME = "$WORKSPACE/build"
      }
      steps {
        sh 'EXOPLANET_CORE_CUDA=yes python3 -m pip install --user .'
        sh 'python3 -m pytest -v tests/jax_test.py'
      }
    }
  }
  post {
    failure {
      emailext subject: '$PROJECT_NAME - Build #$BUILD_NUMBER - $BUILD_STATUS',
	       body: '''$PROJECT_NAME - Build #$BUILD_NUMBER - $BUILD_STATUS

Check console output at $BUILD_URL to view full results.

Building $BRANCH_NAME for $CAUSE
$JOB_DESCRIPTION

Chages:
$CHANGES

End of build log:
${BUILD_LOG,maxLines=200}
''',
	       recipientProviders: [
		 [$class: 'DevelopersRecipientProvider'],
	       ],
	       replyTo: '$DEFAULT_REPLYTO',
	       to: 'dforeman-mackey@flatironinstitute.org'
    }
  }
}
