@Library('flexo-libs') _

currentBuild.displayName = "#${BUILD_ID}: Cloudwatch Datasource"

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

  stages {
    stage('test') {
      steps {
        sh """
          go env
          golangci-lint run --enable-all -D exhaustivestruct,nlreturn,cyclop,wrapcheck,tagliatelle,maligned,scopelint,golint,interfacer,forbidigo ./pkg/...
          golangci-lint run --enable-all -D maligned,scopelint,golint,interfacer ./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'
        }
      }
    }
  }
}
