-
Notifications
You must be signed in to change notification settings - Fork 18
/
Jenkinsfile
235 lines (212 loc) · 9.7 KB
/
Jenkinsfile
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
pipeline {
agent none
options {
timeout(time: 26, unit: 'MINUTES')
skipDefaultCheckout(true)
}
environment {
GOTRACEBACK = 'all'
// COCKROACH_MEMPROF_INTERVAL = 0
// ^ doesn't work: https://github.com/cockroachdb/cockroach/issues/54793
}
stages {
stage('Build') {
agent {
docker {
label 'main'
image 'storjlabs/ci:latest'
alwaysPull true
args '-u root:root --cap-add SYS_PTRACE -v "/tmp/gomod":/go/pkg/mod'
}
}
stages {
stage('Preparation') {
parallel {
stage('Checkout') {
steps {
// delete any content leftover from a previous run:
sh 'chmod -R 777 .'
// bash requires the extglob option to support !(.git)
// syntax, and we don't want to delete .git to have
// faster clones.
sh 'bash -O extglob -O dotglob -c "rm -rf !(.git|.|..)"'
checkout scm
sh 'git restore-mtime'
// download dependencies
sh 'go mod download'
dir('testsuite') {
sh 'go mod download'
}
sh 'mkdir -p .build'
}
}
stage('Start databases') {
steps {
sh 'service postgresql start'
dir('.build') {
sh 'cockroach start-single-node --insecure --store=\'/tmp/crdb\' --listen-addr=localhost:26257 --http-addr=localhost:8080 --cache 512MiB --max-sql-memory 512MiB --background'
}
}
}
}
}
stage('Verification') {
parallel {
stage('Lint') {
environment {
GOLANGCI_LINT_CONFIG = '/go/ci/.golangci.yml'
GOLANGCI_LINT_CONFIG_TESTSUITE = '/go/ci/.golangci.yml'
}
steps {
sh 'make lint'
}
}
stage('Cross-Vet') {
steps {
sh 'make cross-vet'
}
}
stage('Test') {
environment {
JSON = true
SHORT = true
SKIP_TESTSUITE = true
STORJ_TEST_COCKROACH = 'cockroach://root@localhost:26257/postgres?sslmode=disable'
STORJ_TEST_POSTGRES = 'postgres://postgres@localhost/postgres?sslmode=disable'
STORJ_TEST_LOG_LEVEL = 'info'
}
steps {
sh 'make test 2>&1 | grep "^{.*" | tee .build/tests.json | xunit -out .build/tests.xml'
}
post {
always {
sh script: 'cat .build/tests.json| tparse -all -slow 100', returnStatus: true
archiveArtifacts artifacts: '.build/tests.json'
junit '.build/tests.xml'
}
}
}
stage('Testsuite') {
environment {
JSON = true
SHORT = false
STORJ_TEST_COCKROACH = 'cockroach://root@localhost:26257/postgres?sslmode=disable'
STORJ_TEST_POSTGRES = 'postgres://postgres@localhost/postgres?sslmode=disable'
STORJ_TEST_LOG_LEVEL = 'info'
STORJ_TEST_GCSTEST_BUCKET = 'gcstest-ci'
STORJ_TEST_GCSTEST_PATH_TO_JSON_KEY = credentials('gcstest-ci')
}
steps {
// exhaust ports from 1024 to 10000 to ensure we don't
// use hardcoded ports
sh 'use-ports -from 1024 -to 10000 &'
sh 'make test-testsuite 2>&1 | grep "^{.*" | tee .build/testsuite.json | xunit -out .build/testsuite.xml'
}
post {
always {
sh script: 'cat .build/testsuite.json| tparse -all -slow 100', returnStatus: true
archiveArtifacts artifacts: '.build/testsuite.json'
junit '.build/testsuite.xml'
}
}
}
}
}
stage('Post-lint') {
steps {
sh 'check-clean-directory'
}
}
}
post {
always {
sh 'bash -O extglob -O dotglob -c "rm -rf !(.git|.|..)"'
}
}
}
stage('Integration') {
agent {
node {
label 'ondemand'
}
}
stages {
stage('Checkout') {
steps {
// delete any content leftover from a previous run.
// bash requires the extglob option to support !(.git)
// syntax, and we don't want to delete .git to have
// faster clones.
sh 'bash -O extglob -O dotglob -c "rm -rf !(.git|.|..)"'
checkout scm
// install storj-up dependency
sh 'go install storj.io/storj-up@main'
}
}
stage('Start environment') {
steps {
sh 'make integration-env-start'
}
}
stage('Test') {
steps {
script {
def tests = [:]
tests['splunk-tests'] = {
stage('splunk-tests') {
sh 'make integration-splunk-tests'
}
}
['awscli', 'awscli_multipart', 'duplicity', 'duplicati', 'https', 'rclone', 's3fs'].each { test ->
tests["gateway-st-test ${test}"] = {
stage("gateway-st-test ${test}") {
sh "TEST=${test} make integration-gateway-st-tests"
}
}
}
['aws-sdk-go', 'aws-sdk-java', 'awscli', 'minio-go', 's3cmd', 's3select'].each { test ->
tests["mint-test ${test}"] = {
stage("mint-test ${test}") {
sh "TEST=${test} make integration-mint-tests"
}
}
}
parallel tests
}
}
}
// We run aws-sdk-php and aws-sdk-ruby tests sequentially because
// each of them contains a test that lists buckets and interferes
// with other tests that run in parallel.
//
// TODO: run each Mint test with different credentials.
stage('mint-test aws-sdk-php') {
steps {
sh 'TEST=aws-sdk-php make integration-mint-tests'
}
}
stage('mint-test aws-sdk-ruby') {
steps {
sh 'TEST=aws-sdk-ruby make integration-mint-tests'
}
}
}
post {
always {
catchError {
script {
if(fileExists('gateway-st/.build/rclone-integration-tests')) {
zip zipFile: 'rclone-integration-tests.zip', archive: true, dir: 'gateway-st/.build/rclone-integration-tests'
archiveArtifacts artifacts: 'rclone-integration-tests.zip'
}
}
}
catchError {
sh 'make integration-env-purge'
}
sh 'bash -O extglob -O dotglob -c "rm -rf !(.git|.|..)"'
}
}
}
}
}