2019-04-22 14:45:53 +01:00
pipeline {
agent {
dockerfile {
filename 'Dockerfile.jenkins'
2019-06-27 17:09:37 +01:00
args '-u root:root --cap-add SYS_PTRACE -v "/tmp/gomod":/go/pkg/mod'
2019-06-19 20:56:52 +01:00
label 'main'
2019-04-22 14:45:53 +01:00
}
}
2019-05-02 16:48:04 +01:00
options {
2019-07-03 13:25:10 +01:00
timeout(time: 14, unit: 'MINUTES')
2019-05-02 16:48:04 +01:00
}
2019-04-22 14:45:53 +01:00
stages {
stage('Build') {
steps {
checkout scm
2019-04-24 16:33:01 +01:00
2019-06-27 17:09:37 +01:00
sh 'mkdir -p .build'
2019-04-24 16:33:01 +01:00
// make a backup of the mod file in case, for later linting
sh 'cp go.mod .build/go.mod.orig'
// download dependencies
2019-04-22 14:45:53 +01:00
sh 'go mod download'
2019-06-27 19:52:50 +01:00
sh 'make -j2 build-packages'
2019-04-22 14:45:53 +01:00
sh 'make install-sim'
sh 'service postgresql start'
}
}
stage('Verification') {
parallel {
stage('Lint') {
steps {
sh 'go run ./scripts/check-copyright.go'
2019-06-26 07:44:52 +01:00
sh 'go run ./scripts/check-large-files.go'
2019-05-01 16:44:12 +01:00
sh 'go run ./scripts/check-imports.go -race ./...'
2019-05-10 13:13:09 +01:00
sh 'go run ./scripts/check-peer-constraints.go -race -fail=false'
2019-04-22 14:45:53 +01:00
sh 'go run ./scripts/protobuf.go --protoc=$HOME/protoc/bin/protoc lint'
2019-06-04 18:12:27 +01:00
sh 'go run ./scripts/protobuf.go --protoc=$HOME/protoc/bin/protoc check-lock'
2019-07-17 14:26:04 +01:00
sh 'go run ./scripts/atomicalign.go ./...'
2019-04-22 14:45:53 +01:00
sh 'bash ./scripts/check-dbx-version.sh'
2019-07-03 13:25:10 +01:00
sh 'golangci-lint -j=2 run'
2019-04-24 16:33:01 +01:00
sh 'go run scripts/check-mod-tidy.go -mod .build/go.mod.orig'
2019-06-04 18:12:27 +01:00
sh 'make check-satellite-config-lock'
2019-04-22 14:45:53 +01:00
}
}
stage('Tests') {
environment {
STORJ_POSTGRES_TEST = 'postgres://postgres@localhost/teststorj?sslmode=disable'
2019-04-26 14:39:11 +01:00
COVERFLAGS = "${ env.BRANCH_NAME != 'master' ? '' : '-coverprofile=.build/coverprofile -coverpkg=-coverpkg=storj.io/storj/bootstrap/...,storj.io/storj/internal/...,storj.io/storj/lib/...,storj.io/storj/pkg/...,storj.io/storj/satellite/...,storj.io/storj/storage/...,storj.io/storj/storagenode/...,storj.io/storj/uplink/...,storj.io/storj/versioncontrol/...'}"
2019-04-22 14:45:53 +01:00
}
steps {
sh 'psql -U postgres -c \'create database teststorj;\''
sh 'go run scripts/use-ports.go -from 1024 -to 10000 &'
2019-07-03 13:25:10 +01:00
sh 'go test -parallel 4 -p 6 -vet=off $COVERFLAGS -timeout 12m -json -race ./... 2>&1 | tee .build/tests.json | go run ./scripts/xunit.go -out .build/tests.xml'
2019-04-24 16:33:01 +01:00
sh 'go run scripts/check-clean-directory.go'
2019-04-22 14:45:53 +01:00
}
post {
always {
2019-04-24 16:33:01 +01:00
sh script: 'cat .build/tests.json | tparse -all -top -slow 100', returnStatus: true
archiveArtifacts artifacts: '.build/tests.json'
junit '.build/tests.xml'
2019-04-26 14:39:11 +01:00
script {
if(fileExists(".build/coverprofile")){
sh script: 'go run ./scripts/cover-remove-generated.go < .build/coverprofile > .build/clean.coverprofile', returnStatus: true
sh script: 'gocov convert .build/clean.coverprofile > .build/cover.json', returnStatus: true
sh script: 'gocov-xml < .build/cover.json > .build/cobertura.xml', returnStatus: true
cobertura coberturaReportFile: '.build/cobertura.xml'
}
}
2019-04-22 14:45:53 +01:00
}
}
}
stage('Integration') {
environment {
// use different hostname to avoid port conflicts
STORJ_NETWORK_HOST4 = '127.0.0.2'
STORJ_NETWORK_HOST6 = '127.0.0.2'
2019-05-14 16:13:18 +01:00
STORJ_SIM_POSTGRES = 'postgres://postgres@localhost/teststorj2?sslmode=disable'
2019-04-22 14:45:53 +01:00
}
steps {
2019-05-14 16:13:18 +01:00
sh 'psql -U postgres -c \'create database teststorj2;\''
2019-04-22 14:45:53 +01:00
sh 'make test-sim'
}
}
}
}
}
post {
always {
2019-04-24 16:33:01 +01:00
sh "chmod -R 777 ." // ensure Jenkins agent can delete the working directory
deleteDir()
2019-04-22 14:45:53 +01:00
}
}
2019-05-09 06:40:00 +01:00
}