-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile.public
124 lines (113 loc) · 3.85 KB
/
Jenkinsfile.public
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
def repositories = [
'https://review.dev.storj.io/storj/common',
'https://review.dev.storj.io/storj/uplink',
'https://review.dev.storj.io/storj/uplink-c',
'https://review.dev.storj.io/storj/gateway',
'https://review.dev.storj.io/storj/edge',
'https://review.dev.storj.io/storj/storj',
'https://review.dev.storj.io/storj/drpc'
]
def repositoryCheckStages = repositories.collectEntries {
[ "${basename(it)}" : checkRepository(basename(it), it) ]
}
def checkRepository(name, repo) {
return {
stage("${name}") {
sh "git clone --depth 2 ${repo} ${name}"
dir(name){
sh 'check-mod-tidy'
sh 'check-copyright'
sh 'check-large-files'
sh 'check-imports ./...'
sh 'check-peer-constraints'
// Currently protobuf uses different structure in storj/storj repostitory,
// making these fail.
// sh 'storj-protobuf --protoc=$HOME/protoc/bin/protoc lint'
// sh 'storj-protobuf --protoc=$HOME/protoc/bin/protoc check-lock'
sh 'check-atomic-align ./...'
sh 'check-errs ./...'
sh 'check-monkit ./...'
sh 'check-deferloop ./...'
sh 'staticcheck ./...'
// sh 'check-downgrades'
sh 'golangci-lint run --allow-parallel-runners --config /go/ci/.golangci.yml'
}
}
}
}
def basename(path) {
lastPath = path.lastIndexOf('/');
if (lastPath!=-1){
path = path.substring(lastPath+1);
}
return path
}
pipeline {
agent {
dockerfile {
filename 'images/Dockerfile'
args '-u root:root --cap-add SYS_PTRACE -v "/tmp/gomod":/go/pkg/mod'
label 'main'
}
}
options {
timeout(time: 26, unit: 'MINUTES')
}
environment {
NPM_CONFIG_CACHE = '/tmp/npm/cache'
}
stages {
stage('Build') {
steps {
checkout scm
// ensure that services can start
sh 'service postgresql start'
sh 'cockroach start --insecure --store=\'/tmp/crdb\' --listen-addr=localhost:26257 --http-addr=localhost:8080 --join=localhost:26257 --background'
sh 'cockroach init --insecure --host=localhost:26257'
}
}
stage('Lint') {
steps {
sh 'check-copyright'
sh 'check-large-files'
sh 'check-imports ./...'
sh 'check-peer-constraints'
sh 'storj-protobuf --protoc=$HOME/protoc/bin/protoc lint'
sh 'storj-protobuf --protoc=$HOME/protoc/bin/protoc check-lock'
sh 'check-atomic-align ./...'
sh 'check-errs ./...'
sh 'staticcheck ./...'
sh 'golangci-lint --config /go/ci/.golangci.yml -j=2 run'
sh 'check-downgrades'
}
}
stage('Lint Gerrit Hook') {
steps {
dir("gerrit-hook"){
sh 'check-copyright'
sh 'check-large-files'
sh 'check-imports ./...'
sh 'check-peer-constraints'
sh 'check-atomic-align ./...'
sh 'check-errs ./...'
sh 'staticcheck ./...'
sh 'golangci-lint --config /go/ci/.golangci.yml -j=2 run'
sh 'check-downgrades'
}
}
}
stage('Repos') {
steps {
script {
parallel(repositoryCheckStages)
}
}
}
}
post {
always {
sh "chmod -R 777 ." // ensure Jenkins agent can delete the working directory
deleteDir()
}
}
}