forked from pyca/cryptography
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
448 lines (432 loc) · 15.2 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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
if (env.BRANCH_NAME == "master") {
properties([pipelineTriggers([cron('@daily')])])
}
def configs = [
[
label: 'windows',
toxenvs: ['py27', 'py34', 'py35', 'py36'],
],
[
label: 'windows64',
toxenvs: ['py27', 'py34', 'py35', 'py36'],
],
[
label: 'freebsd11',
toxenvs: ['py27'],
],
[
label: 'sierra',
toxenvs: ['py27', 'py36'],
],
[
label: 'yosemite',
toxenvs: ['py27'],
],
[
label: 'docker',
imageName: 'pyca/cryptography-runner-centos7',
toxenvs: ['py27'],
],
[
label: 'docker',
imageName: 'pyca/cryptography-runner-wheezy',
toxenvs: ['py27'],
],
[
label: 'docker',
imageName: 'pyca/cryptography-runner-jessie',
toxenvs: ['py27', 'py34'],
],
[
label: 'docker',
imageName: 'pyca/cryptography-runner-stretch',
toxenvs: ['py27', 'py35'],
],
[
label: 'docker',
imageName: 'pyca/cryptography-runner-buster',
toxenvs: ['py27', 'py36'],
],
[
label: 'docker',
imageName: 'pyca/cryptography-runner-sid',
toxenvs: ['py27', 'py36'],
],
[
label: 'docker',
imageName: 'pyca/cryptography-runner-jessie-libressl:2.4.5',
toxenvs: ['py27'],
],
[
label: 'docker',
imageName: 'pyca/cryptography-runner-jessie-libressl:2.6.4',
toxenvs: ['py27'],
],
[
label: 'docker',
imageName: 'pyca/cryptography-runner-ubuntu-xenial',
toxenvs: ['py27', 'py35'],
],
[
label: 'docker',
imageName: 'pyca/cryptography-runner-ubuntu-rolling',
toxenvs: ['py27', 'py36', 'randomorder'],
],
[
label: 'docker',
imageName: 'pyca/cryptography-runner-sid',
toxenvs: ['docs'],
artifacts: 'cryptography/docs/_build/html/**',
artifactExcludes: '**/*.doctree',
],
[
label: 'docker',
imageName: 'pyca/cryptography-runner-fedora',
toxenvs: ['py27', 'py36'],
],
[
label: 'docker',
imageName: 'pyca/cryptography-runner-alpine:latest',
toxenvs: ['py36'],
],
]
/* Add the linkcheck job to our config list if we're on master */
if (env.BRANCH_NAME == "master") {
configs.add(
[
label: 'docker',
imageName: 'pyca/cryptography-runner-sid',
toxenvs: ['docs-linkcheck'],
]
)
}
def downstreams = [
[
downstreamName: 'pyOpenSSL',
label: 'docker',
imageName: 'pyca/cryptography-runner-ubuntu-rolling',
script: """#!/bin/bash -xe
git clone --depth=1 https://github.com/pyca/pyopenssl
cd pyopenssl
virtualenv .venv
source .venv/bin/activate
pip install ../cryptography
pip install -e .[test]
pytest tests
"""
],
[
downstreamName: 'Twisted',
label: 'docker',
imageName: 'pyca/cryptography-runner-ubuntu-rolling',
script: """#!/bin/bash -xe
git clone --depth=1 https://github.com/twisted/twisted
cd twisted
virtualenv .venv
source .venv/bin/activate
pip install ../cryptography
pip install pyopenssl service_identity pycrypto
pip install -e .
python -m twisted.trial src/twisted
"""
],
[
downstreamName: 'paramiko',
label: 'docker',
imageName: 'pyca/cryptography-runner-ubuntu-rolling',
script: """#!/bin/bash -xe
git clone --depth=1 https://github.com/paramiko/paramiko
cd paramiko
virtualenv .venv
source .venv/bin/activate
pip install ../cryptography
pip install -e .
pip install -r dev-requirements.txt
inv test
"""
],
[
downstreamName: 'aws-encryption-sdk',
label: 'docker',
imageName: 'pyca/cryptography-runner-ubuntu-rolling',
script: """#!/bin/bash -xe
git clone --depth=1 https://github.com/awslabs/aws-encryption-sdk-python
cd aws-encryption-sdk-python
virtualenv .venv
source .venv/bin/activate
pip install ../cryptography
pip install pytest pytest-mock mock
pip install -e .
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID="arn:aws:kms:us-west-2:nonsense" pytest -m local -l
"""
],
[
downstreamName: 'certbot',
label: 'docker',
imageName: 'pyca/cryptography-runner-ubuntu-rolling',
script: """#!/bin/bash -xe
git clone --depth=1 https://github.com/certbot/certbot
cd certbot
virtualenv .venv
source .venv/bin/activate
pip install ../cryptography
pip install pytest pytest-mock mock
pip install -e acme
pip install -e .
pytest certbot/tests
pytest acme
"""
],
[
downstreamName: 'certbot-josepy',
label: 'docker',
imageName: 'pyca/cryptography-runner-ubuntu-rolling',
script: """#!/bin/bash -xe
git clone --depth=1 https://github.com/certbot/josepy
cd josepy
virtualenv .venv
source .venv/bin/activate
pip install ../cryptography
pip install -e .[tests]
pytest src
"""
],
[
downstreamName: 'urllib3',
label: 'docker',
imageName: 'pyca/cryptography-runner-ubuntu-rolling',
script: """#!/bin/bash -xe
git clone --depth 1 https://github.com/shazow/urllib3
cd urllib3
virtualenv .venv
source .venv/bin/activate
pip install ../cryptography
pip install -r ./dev-requirements.txt
pip install -e .[socks]
pytest test
"""
],
]
def checkout_git(label) {
retry(3) {
def script = ""
if (env.BRANCH_NAME.startsWith('PR-')) {
script = """
git clone --depth=1 https://github.com/pyca/cryptography
cd cryptography
git fetch origin +refs/pull/${env.CHANGE_ID}/merge:
git checkout -qf FETCH_HEAD
"""
if (label.contains("windows")) {
bat script
} else {
sh """#!/bin/sh
set -xe
${script}
"""
}
} else {
checkout([
$class: 'GitSCM',
branches: [[name: "*/${env.BRANCH_NAME}"]],
doGenerateSubmoduleConfigurations: false,
extensions: [[
$class: 'RelativeTargetDirectory',
relativeTargetDir: 'cryptography'
]],
submoduleCfg: [],
userRemoteConfigs: [[
'url': 'https://github.com/pyca/cryptography'
]]
])
}
}
if (label.contains("windows")) {
bat """
cd cryptography
git rev-parse HEAD
"""
} else {
sh """
cd cryptography
git rev-parse HEAD
"""
}
}
def build(toxenv, label, imageName, artifacts, artifactExcludes) {
try {
timeout(time: 30, unit: 'MINUTES') {
checkout_git(label)
withCredentials([string(credentialsId: 'cryptography-codecov-token', variable: 'CODECOV_TOKEN')]) {
withEnv(["LABEL=$label", "TOXENV=$toxenv", "IMAGE_NAME=$imageName"]) {
if (label.contains("windows")) {
def pythonPath = [
py27: "C:\\Python27\\python.exe",
py34: "C:\\Python34\\python.exe",
py35: "C:\\Python35\\python.exe",
py36: "C:\\Python36\\python.exe"
]
if (toxenv == "py35" || toxenv == "py36") {
opensslPaths = [
"windows": [
"include": "C:\\OpenSSL-Win32-2015\\include",
"lib": "C:\\OpenSSL-Win32-2015\\lib"
],
"windows64": [
"include": "C:\\OpenSSL-Win64-2015\\include",
"lib": "C:\\OpenSSL-Win64-2015\\lib"
]
]
} else {
opensslPaths = [
"windows": [
"include": "C:\\OpenSSL-Win32-2010\\include",
"lib": "C:\\OpenSSL-Win32-2010\\lib"
],
"windows64": [
"include": "C:\\OpenSSL-Win64-2010\\include",
"lib": "C:\\OpenSSL-Win64-2010\\lib"
]
]
}
bat """
cd cryptography
@set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH%
@set PYTHON="${pythonPath[toxenv]}"
@set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE%
@set LIB="${opensslPaths[label]['lib']}";%LIB%
tox -r
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
virtualenv .codecov
call .codecov/Scripts/activate
REM this pin must be kept in sync with tox.ini
pip install coverage==4.3.4
pip install codecov
codecov -e JOB_BASE_NAME,LABEL,TOXENV
"""
} else if (label.contains("sierra") || label.contains("yosemite")) {
ansiColor {
sh """#!/usr/bin/env bash
set -xe
# Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH
export PATH="/usr/local/bin:\${PATH}"
export PATH="/Users/jenkins/.pyenv/shims:\${PATH}"
cd cryptography
CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 \
LDFLAGS="/usr/local/opt/openssl\\@1.1/lib/libcrypto.a /usr/local/opt/openssl\\@1.1/lib/libssl.a" \
CFLAGS="-I/usr/local/opt/openssl\\@1.1/include -Werror -Wno-error=deprecated-declarations -Wno-error=incompatible-pointer-types -Wno-error=unused-function -Wno-error=unused-command-line-argument -mmacosx-version-min=10.9" \
tox -r -- --color=yes
virtualenv .venv
source .venv/bin/activate
# This pin must be kept in sync with tox.ini
pip install coverage==4.3.4
bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV
"""
}
} else {
ansiColor {
sh """#!/usr/bin/env bash
set -xe
cd cryptography
if [[ "\${IMAGE_NAME}" == *"libressl"* ]]; then
LD_LIBRARY_PATH="/usr/local/libressl/lib:\$LD_LIBRARY_PATH" \
LDFLAGS="-L/usr/local/libressl/lib" \
CFLAGS="-I/usr/local/libressl/include" \
tox -r -- --color=yes
else
tox -r -- --color=yes
fi
virtualenv .venv
source .venv/bin/activate
# This pin must be kept in sync with tox.ini
pip install coverage==4.3.4
bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV,IMAGE_NAME
"""
}
if (artifacts) {
archiveArtifacts artifacts: artifacts, excludes: artifactExcludes
}
}
}
}
}
} finally {
deleteDir()
}
}
def builders = [:]
for (config in configs) {
def label = config["label"]
def toxenvs = config["toxenvs"]
def artifacts = config["artifacts"]
def artifactExcludes = config["artifactExcludes"]
for (_toxenv in toxenvs) {
def toxenv = _toxenv
if (label.contains("docker")) {
def imageName = config["imageName"]
def combinedName = "${imageName}-${toxenv}"
builders[combinedName] = {
node(label) {
stage(combinedName) {
def buildImage = docker.image(imageName)
buildImage.pull()
buildImage.inside {
build(toxenv, label, imageName, artifacts, artifactExcludes)
}
}
}
}
} else {
def combinedName = "${label}-${toxenv}"
builders[combinedName] = {
node(label) {
stage(combinedName) {
build(toxenv, label, '', null, null)
}
}
}
}
}
}
/* Add the python setup.py test builder */
builders["setup.py-test"] = {
node("docker") {
stage("python setup.py test") {
docker.image("pyca/cryptography-runner-ubuntu-rolling").inside {
try {
checkout_git("docker")
sh """#!/usr/bin/env bash
set -xe
cd cryptography
virtualenv .venv
source .venv/bin/activate
python setup.py test
"""
} finally {
deleteDir()
}
}
}
}
}
for (downstream in downstreams) {
def downstreamName = downstream["downstreamName"]
def imageName = downstream["imageName"]
def label = downstream["label"]
def script = downstream["script"]
builders[downstreamName] = {
node(label) {
docker.image(imageName).inside {
try {
timeout(time: 30, unit: 'MINUTES') {
checkout_git(label)
sh script
}
} finally {
deleteDir()
}
}
}
}
}
parallel builders