-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathJenkinsfile
More file actions
138 lines (115 loc) · 4.74 KB
/
Jenkinsfile
File metadata and controls
138 lines (115 loc) · 4.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/env groovy
import hudson.model.Result
import hudson.model.Run
import jenkins.model.CauseOfInterruption.UserInterruption
pipeline {
agent { label "linux&&master&&!aarch64" }
environment {
GO_TARBALL_URL = "https://golang.org/dl/go1.24.11.linux-amd64.tar.gz"
GOROOT = "${WORKSPACE}/go"
GOBIN = "${GOROOT}/bin"
PATH="${PATH}:${GOBIN}:${WORKSPACE}/bin"
GOLANGCI_LINT_VERSION = "v2.11.4"
PROJECT = "${WORKSPACE}/tools-common"
}
stages {
stage("Setup") {
steps {
script {
// Configure Gerrit Trigger
properties([pipelineTriggers([
gerrit(
serverName: "review.couchbase.org",
gerritProjects: [
[
compareType: "PLAIN", disableStrictForbiddenFileVerification: false,
pattern: "tools-common", branches: [[ compareType: "PLAIN", pattern: "master" ]]
],
],
triggerOnEvents: [
commentAddedContains(commentAddedCommentContains: "reverify"),
draftPublished(),
patchsetCreated(excludeNoCodeChange: true)
]
)
])])
}
timeout(time: 5, unit: "MINUTES") {
// Install Golang locally
sh "wget -q -O- ${GO_TARBALL_URL} | tar xz"
// get golangci-lint binary
sh "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/${GOLANGCI_LINT_VERSION}/install.sh | sh -s -- -b ${GOBIN} ${GOLANGCI_LINT_VERSION}"
sh "golangci-lint --version"
// A clone of 'jq' written in Go (required for merging coverage files)
sh "go install github.com/itchyny/gojq/cmd/gojq@latest"
// Unit test reporting
sh "go install github.com/jstemmer/go-junit-report@latest"
// Coverage reporting
sh "go install github.com/axw/gocov/gocov@latest"
sh "go install github.com/AlekSi/gocov-xml@latest"
// clone project
sh "git clone git@github.com:couchbase/tools-common.git"
// Fetch the commit we are testing
dir("${PROJECT}") {
sh "git fetch ssh://buildbot@review.couchbase.org:29418/tools-common ${GERRIT_REFSPEC}"
sh "git checkout FETCH_HEAD"
}
}
}
}
stage("Lint") {
steps {
timeout(time: 10, unit: "MINUTES") {
dir("${PROJECT}") {
sh "golangci-lint cache clean"
sh "./scripts/cv/lint.sh"
}
}
}
}
stage("Test") {
steps {
// Create somewhere to store our coverage/test reports
sh "mkdir -p reports"
timeout(time: 15, unit: "MINUTES") {
dir("${PROJECT}") {
// Run unit testing with coverage and place output in 'reports'.
//
// - 'reports/tests.xml'
// - 'reports/coverage.xml'
sh "./scripts/cv/test.sh ${WORKSPACE}/reports"
}
}
}
}
stage("Benchmark") {
steps {
timeout(time: 15, unit: "MINUTES") {
dir("${PROJECT}") {
// Run the benchmarks without running any tests
sh "./scripts/cv/benchmark.sh"
}
}
}
}
}
post {
always {
// Post the test results
junit allowEmptyResults: true, testResults: "reports/tests.xml"
// Post the test coverage
recordCoverage(
tools: [[parser: 'COBERTURA', pattern: 'reports/coverage.xml']],
qualityGates: [[threshold: 30.0, metric: 'LINE', baseline: 'PROJECT']],
sourceDirectories: [[path: "tools-common/"]],
sourceCodeRetention: "LAST_BUILD",
)
}
cleanup {
// We don't need the build cache interfering with any subsequent builds
sh "go clean --cache --testcache"
// Remove the workspace
deleteDir()
}
}
}