unipdf/Jenkinsfile

108 lines
3.8 KiB
Plaintext
Raw Normal View History

2018-07-26 01:46:18 +00:00
node {
// Install the desired Go version
def root = tool name: 'go 1.10.3', type: 'go'
env.GOROOT="${root}"
env.GOPATH="${WORKSPACE}/gopath"
env.PATH="${root}/bin:${env.GOPATH}/bin:${env.PATH}"
env.GOCACHE="off"
env.UNIDOC_EXTRACT_FORCETEST="1"
env.UNIDOC_EXTRACT_TESTDATA="/home/jenkins/corpus/unidoc-extractor-testdata"
2018-07-26 01:46:18 +00:00
env.TMPDIR="${WORKSPACE}/temp"
sh "mkdir -p ${env.TMPDIR}"
2018-07-26 01:46:18 +00:00
dir("${GOPATH}/src/github.com/unidoc/unidoc") {
sh 'go version'
stage('Checkout') {
echo "Pulling unidoc on branch ${env.BRANCH_NAME}"
2018-07-26 01:56:41 +00:00
checkout scm
2018-07-26 01:46:18 +00:00
}
stage('Prepare') {
// Get linter and other build tools.
2018-10-13 11:34:26 +00:00
sh 'go get -u golang.org/x/lint/golint'
2018-07-26 01:46:18 +00:00
sh 'go get github.com/tebeka/go2xunit'
sh 'go get github.com/t-yuki/gocover-cobertura'
// Get all dependencies (for tests also).
sh 'go get -t ./...'
2018-07-26 01:46:18 +00:00
}
stage('Linting') {
// Go vet - List issues
sh '(go vet ./... >govet.txt 2>&1) || true'
// Go lint - List issues
sh '(golint ./... >golint.txt 2>&1) || true'
}
stage('Testing') {
// Go test - No tolerance.
sh "rm -f ${env.TMPDIR}/*.pdf"
2018-07-26 01:46:18 +00:00
sh '2>&1 go test -v ./... | tee gotest.txt'
}
stage('Check generated PDFs') {
// Check the created output pdf files.
sh "find ${env.TMPDIR} -maxdepth 1 -name \"*.pdf\" -print0 | xargs -t -n 1 -0 gs -dNOPAUSE -dBATCH -sDEVICE=nullpage -sPDFPassword=password -dPDFSTOPONERROR -dPDFSTOPONWARNING"
}
2018-07-26 01:46:18 +00:00
stage('Test coverage') {
sh 'go test -coverprofile=coverage.out -covermode=atomic -coverpkg=./... ./...'
sh '/home/jenkins/codecov.sh'
2018-07-26 01:46:18 +00:00
sh 'gocover-cobertura < coverage.out > coverage.xml'
step([$class: 'CoberturaPublisher', coberturaReportFile: 'coverage.xml'])
}
stage('Post') {
// Assemble vet and lint info.
warnings parserConfigurations: [
[pattern: 'govet.txt', parserName: 'Go Vet'],
[pattern: 'golint.txt', parserName: 'Go Lint']
]
sh 'go2xunit -fail -input gotest.txt -output gotest.xml'
junit "gotest.xml"
}
}
dir("${GOPATH}/src/github.com/unidoc/unidoc-examples") {
stage('Build examples') {
2018-11-06 10:38:18 +00:00
// Output environment variables (useful for debugging).
2018-11-06 10:29:34 +00:00
sh("printenv")
// Pull unidoc-examples from connected branch, or master otherwise.
def examplesBranch = "master"
2018-11-06 10:38:18 +00:00
if (env.BRANCH_NAME.take(3) == "PR-") {
// Pull requests (PR) require separate handling.
if (env.CHANGE_TARGET.take(2) == "v3") {
examplesBranch = "v3"
}
} else {
if (env.BRANCH_NAME.take(2) == "v3") {
examplesBranch = "v3"
}
// Special cases.
switch("${env.BRANCH_NAME}") {
case "v3-enhance-forms":
examplesBranch = "v3-enhance-forms"
break
}
}
echo "Pulling unidoc-examples on branch ${examplesBranch}"
git url: 'https://github.com/unidoc/unidoc-examples.git', branch: examplesBranch
// Dependencies for examples.
sh 'go get github.com/wcharczuk/go-chart'
2018-07-26 01:46:18 +00:00
// Build all examples.
sh 'find . -name "*.go" -print0 | xargs -0 -n1 go build'
}
stage('Passthrough benchmark pdfdb_small') {
sh './pdf_passthrough_bench /home/jenkins/corpus/pdfdb_small/* | grep -v "Testing " | grep -v "copy of" | grep -v "To get " | grep -v " - pass"'
}
2018-07-26 01:46:18 +00:00
}
}