pipeline {
  agent any

  stages {
    stage('lint') {
      steps {
        sh '''#!/bin/bash
        export PATH=$PATH:$CONDAPATH
        source activate climada_env
        rm -f pylint.log
        pylint -ry climada | tee pylint.log'''

        recordIssues tools: [pyLint(pattern: 'pylint.log')]
      }
    }

    stage('integ_test') {
      steps {
        sh '''#!/bin/bash
        export PATH=$PATH:$CONDAPATH
        source activate climada_env
        rm -rf tests_xml/
        rm -rf coverage/
        make test'''
      }
    }
  }

  post {
    always {
      junit 'tests_xml/*.xml'
      recordCoverage(
        qualityGates: [[
          baseline: 'PROJECT',
          metric: 'LINE',
          threshold: 80.0
        ]],
        tools: [[
          parser: 'COBERTURA',
          pattern: 'coverage.xml'
        ]]
      )
    }
  }
}
