pipeline {
  agent any

  stages {
    stage('ci') {
      parallel {

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

            discoverGitReferenceBuild referenceJob: 'climada_branches/develop'
            recordIssues tools: [pyLint(pattern: 'pylint.log')]
          }
        }

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

      }
    }
  }

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