// This configures your Jenkins pipeline. You can read more about it here:
// https://wiki.twitch.com/display/DTA/Jenkins+Pipelines
// You can also see your Jenkins pipeline here:
// https://jenkins.internal.justin.tv/job/web/job/core-ui/
// You should note that Jenkins pipelines are defined per-branch. This means
// that if you change this file it will impact your branch and no other. Each
// branch has its own view in there and you can see how the pipeline played
// out for each build that happened for each branch.
pipeline {
  agent {
      docker {
          // Change this if you want a different version of node to be run for
          // tests. Here are some options: https://hub.docker.com/_/node/
          image "node:carbon"
          args '-u root'
      }
  }
  stages {
    // Setup steps modify the instance and should not run in parallel.
    stage("setup") {
      steps {
        sh "yarn"
      }
    }
    stage("spawn quality checks") {
      // Everything in this section should be side-effect free. Since these
      // all run in parallel side-effects could cause random failures or
      // unintended successes.
      parallel {
        stage("test") {
          steps {
            sh "yarn test:ci"
          }
        }
        stage("lint") {
          steps {
            sh "yarn lint:ci"
          }
        }
        stage("build") {
          steps {
            sh "yarn build:ci"
          }
        }
      }
    }
  }
  // Post defines post-build steps.
  post {
    // Always look for all the junit files that jest created to let Jenkins
    // be able to better understand the results of the test run.
    always {
      junit 'build/reports/**/*.xml'
    }
  }
}

