@Library('flexo-libs') _

currentBuild.displayName = "#${BUILD_ID}: Zone Delegator"

pipeline {
  agent { docker { image 'docker.pkgs.xarth.tv/devtools/bionic/go1.15.6:latest' }}

  stages {
    stage('test') {
      steps {
        sh """
          go env
          curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b \$(go env GOPATH)/bin latest
          golangci-lint run --enable-all -D exhaustivestruct,nlreturn,cyclop,wrapcheck ./pkg/...
          golangci-lint run --enable-all ./cmd/...
          go test -covermode=atomic -coverprofile=coverage.txt ./...
        """

        // To create this credential, go to https://codecov.xarth.tv/ghe/awsi/twitch-a2z-com/settings and save the token as a plaintext Jenkins secret.
        withCredentials([[ $class: 'StringBinding', credentialsId: 'awsi_twitch_a2z_com_codecov_token', variable: 'CODECOV_TOKEN' ]]) {
          sh 'curl -s https://codecov.xarth.tv/bash | bash -s -- -f coverage.txt'
        }
      }
    }
  }
}
