github.com/unidoc/unidoc@v2.2.0+incompatible/Jenkinsfile (about)

     1  node {
     2      // Install the desired Go version
     3      def root = tool name: 'go 1.10.3', type: 'go'
     4  
     5      env.GOROOT="${root}"
     6      env.GOPATH="${WORKSPACE}/gopath"
     7      env.PATH="${root}/bin:${env.GOPATH}/bin:${env.PATH}"
     8  
     9      dir("${GOPATH}/src/github.com/unidoc/unidoc") {
    10          sh 'go version'
    11  
    12          stage('Checkout') {
    13              echo "Pulling unidoc on branch ${env.BRANCH_NAME}"
    14              checkout scm
    15          }
    16  
    17          stage('Prepare') {
    18              // Get linter and other build tools.
    19              sh 'go get -u golang.org/x/lint/golint'
    20              sh 'go get github.com/tebeka/go2xunit'
    21              sh 'go get github.com/t-yuki/gocover-cobertura'
    22  
    23              // Get dependencies
    24              sh 'go get golang.org/x/image/tiff/lzw'
    25              sh 'go get github.com/boombuler/barcode'
    26          }
    27  
    28          stage('Linting') {
    29              // Go vet - List issues
    30              sh '(go vet ./... >govet.txt 2>&1) || true'
    31  
    32              // Go lint - List issues
    33              sh '(golint ./... >golint.txt 2>&1) || true'
    34          }
    35  
    36  
    37          stage('Testing') {
    38              // Go test - No tolerance.
    39              //sh 'go test -v ./... >gotest.txt 2>&1'
    40              sh '2>&1 go test -v ./... | tee gotest.txt'
    41          }
    42  
    43          stage('Test coverage') {
    44              sh 'go test -coverprofile=coverage.out ./...'
    45              sh 'gocover-cobertura < coverage.out > coverage.xml'
    46              step([$class: 'CoberturaPublisher', coberturaReportFile: 'coverage.xml'])
    47          }
    48  
    49  
    50          stage('Post') {
    51              // Assemble vet and lint info.
    52              warnings parserConfigurations: [
    53                  [pattern: 'govet.txt', parserName: 'Go Vet'],
    54                  [pattern: 'golint.txt', parserName: 'Go Lint']
    55              ]
    56  
    57              sh 'go2xunit -fail -input gotest.txt -output gotest.xml'
    58              junit "gotest.xml"
    59          }
    60      }
    61  
    62      dir("${GOPATH}/src/github.com/unidoc/unidoc-examples") {
    63          stage('Build examples') {
    64              // Pull unidoc-examples from connected branch, or master otherwise.
    65              def examplesBranch = "master"
    66              switch("${env.BRANCH_NAME}") {
    67                  case "v3":
    68                      examplesBranch = "v3"
    69                      break
    70              }
    71              echo "Pulling unidoc-examples on branch ${examplesBranch}"
    72              git url: 'https://github.com/unidoc/unidoc-examples.git', branch: examplesBranch
    73              
    74              // Dependencies for examples.
    75              sh 'go get github.com/wcharczuk/go-chart'
    76  
    77              // Build all examples.
    78              sh 'find . -name "*.go" -print0 | xargs -0 -n1 go build'
    79          }
    80  
    81          stage('Passthrough benchmark pdfdb_small') {
    82              sh './pdf_passthrough_bench /home/jenkins/corpus/pdfdb_small/* | grep -v "Testing " | grep -v "copy of" | grep -v "To get " | grep -v " - pass"'
    83          }
    84      }
    85  }