2018-07-26 01:46:18 +00:00
|
|
|
node {
|
|
|
|
// Install the desired Go version
|
2020-06-16 21:19:10 +00:00
|
|
|
def root = tool name: 'go 1.14.3', type: 'go'
|
2018-07-26 01:46:18 +00:00
|
|
|
|
|
|
|
env.GOROOT="${root}"
|
2020-06-16 21:19:10 +00:00
|
|
|
env.GOBIN="${WORKSPACE}/bin"
|
|
|
|
env.PATH="${root}/bin:${env.GOBIN}:${env.PATH}"
|
2018-12-27 22:47:39 +00:00
|
|
|
env.UNIDOC_EXTRACT_FORCETEST="1"
|
2019-01-22 13:53:11 +00:00
|
|
|
env.UNIDOC_E2E_FORCE_TESTS="1"
|
2018-12-27 22:47:39 +00:00
|
|
|
env.UNIDOC_EXTRACT_TESTDATA="/home/jenkins/corpus/unidoc-extractor-testdata"
|
2019-04-14 19:03:05 +00:00
|
|
|
env.UNIDOC_RENDERTEST_BASELINE_PATH="/home/jenkins/corpus/unidoc-creator-render-testdata-upd2"
|
2019-01-22 13:53:11 +00:00
|
|
|
env.UNIDOC_PASSTHROUGH_TESTDATA="/home/jenkins/corpus/unidoc-e2e-testdata"
|
|
|
|
env.UNIDOC_ALLOBJECTS_TESTDATA="/home/jenkins/corpus/unidoc-e2e-testdata"
|
2019-04-13 21:47:54 +00:00
|
|
|
env.UNIDOC_SPLIT_TESTDATA="/home/jenkins/corpus/unidoc-e2e-split-testdata"
|
2019-08-20 01:37:16 +03:00
|
|
|
env.UNIDOC_EXTRACT_IMAGES_TESTDATA="/home/jenkins/corpus/unidoc-e2e-extract-images-testdata"
|
2019-07-14 20:18:57 +00:00
|
|
|
env.UNIDOC_JBIG2_TESTDATA="/home/jenkins/corpus/jbig2-testdata"
|
2019-06-25 08:08:51 +00:00
|
|
|
env.UNIDOC_FDFMERGE_TESTDATA="/home/jenkins/corpus/fdfmerge-testdata"
|
2019-01-28 12:48:30 +00:00
|
|
|
env.UNIDOC_GS_BIN_PATH="/usr/bin/gs"
|
2019-03-14 19:37:50 +00:00
|
|
|
env.CGO_ENABLED="0"
|
2018-07-26 01:46:18 +00:00
|
|
|
|
2018-12-07 12:08:17 +00:00
|
|
|
env.TMPDIR="${WORKSPACE}/temp"
|
2020-06-16 21:19:10 +00:00
|
|
|
sh "mkdir -p ${env.GOBIN}"
|
2018-12-07 12:39:40 +00:00
|
|
|
sh "mkdir -p ${env.TMPDIR}"
|
2018-12-07 12:08:17 +00:00
|
|
|
|
2020-06-16 21:19:10 +00:00
|
|
|
dir("${WORKSPACE}/unipdf") {
|
2018-07-26 01:46:18 +00:00
|
|
|
sh 'go version'
|
|
|
|
|
|
|
|
stage('Checkout') {
|
2019-05-19 12:41:13 +00:00
|
|
|
echo "Pulling unipdf 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.
|
2020-06-16 21:19:10 +00:00
|
|
|
sh 'go get 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'
|
|
|
|
}
|
|
|
|
|
|
|
|
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.
|
2018-12-07 12:08:17 +00:00
|
|
|
sh "rm -f ${env.TMPDIR}/*.pdf"
|
2020-06-16 21:19:10 +00:00
|
|
|
sh '2>&1 go test -count=1 -v ./... | tee gotest.txt'
|
2018-07-26 01:46:18 +00:00
|
|
|
}
|
|
|
|
|
2018-09-03 10:59:32 +00:00
|
|
|
stage('Check generated PDFs') {
|
|
|
|
// Check the created output pdf files.
|
2018-12-07 12:08:17 +00:00
|
|
|
sh "find ${env.TMPDIR} -maxdepth 1 -name \"*.pdf\" -print0 | xargs -t -n 1 -0 gs -dNOPAUSE -dBATCH -sDEVICE=nullpage -sPDFPassword=password -dPDFSTOPONERROR -dPDFSTOPONWARNING"
|
2018-09-03 10:59:32 +00:00
|
|
|
}
|
|
|
|
|
2018-07-26 01:46:18 +00:00
|
|
|
stage('Test coverage') {
|
2020-06-16 21:19:10 +00:00
|
|
|
sh 'go test -count=1 -coverprofile=coverage.out -covermode=atomic -coverpkg=./... ./...'
|
2019-01-02 14:30:09 +00:00
|
|
|
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"
|
|
|
|
}
|
2018-08-01 21:38:23 +00:00
|
|
|
}
|
|
|
|
|
2020-06-16 21:19:10 +00:00
|
|
|
dir("${WORKSPACE}/unipdf-examples") {
|
2018-08-01 21:38:23 +00:00
|
|
|
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")
|
|
|
|
|
2019-05-19 12:41:13 +00:00
|
|
|
// Pull unipdf-examples from connected branch, or master otherwise.
|
2019-09-07 17:28:53 +03:00
|
|
|
def examplesBranch = "development"
|
2019-03-09 20:45:19 +00:00
|
|
|
|
|
|
|
// Check if connected branch is defined explicitly.
|
|
|
|
def safeName = env.BRANCH_NAME.replaceAll(/[\/\.]/, '')
|
|
|
|
def fpath = "/home/jenkins/exbranch/" + safeName
|
|
|
|
if (fileExists(fpath)) {
|
|
|
|
examplesBranch = readFile(fpath).trim()
|
|
|
|
}
|
|
|
|
|
2019-05-19 12:41:13 +00:00
|
|
|
echo "Pulling unipdf-examples on branch ${examplesBranch}"
|
2018-08-01 21:38:23 +00:00
|
|
|
git url: 'https://github.com/unidoc/unidoc-examples.git', branch: examplesBranch
|
2020-06-16 21:19:10 +00:00
|
|
|
|
|
|
|
// Use replace directive to use disk version of unipdf.
|
|
|
|
sh 'echo "replace github.com/unidoc/unipdf/v3 => ../unipdf" >>go.mod'
|
2018-08-01 21:38:23 +00:00
|
|
|
|
|
|
|
// Dependencies for examples.
|
2019-05-19 12:41:13 +00:00
|
|
|
sh './build_examples.sh'
|
2018-08-01 21:38:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stage('Passthrough benchmark pdfdb_small') {
|
2019-05-19 12:41:13 +00:00
|
|
|
sh './bin/pdf_passthrough_bench /home/jenkins/corpus/pdfdb_small/* | grep -v "Testing " | grep -v "copy of" | grep -v "To get " | grep -v " - pass"'
|
2018-08-01 21:38:23 +00:00
|
|
|
}
|
2018-07-26 01:46:18 +00:00
|
|
|
}
|
2019-03-14 17:56:35 +00:00
|
|
|
}
|