blob: 7f8cf6b7a0290142609561ba9aae5b1350f81add [file] [log] [blame]
Paul Kehrerba58e1f2017-05-22 18:08:29 -07001if (env.BRANCH_NAME == "master") {
2 properties([pipelineTriggers([cron('@daily')])])
3}
4
5def configs = [
6 [
7 label: 'windows',
Paul Kehrer4cf6e782017-10-12 06:06:01 +08008 toxenvs: ['py27', 'py34', 'py35', 'py36'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -07009 ],
10 [
11 label: 'windows64',
Paul Kehrer4cf6e782017-10-12 06:06:01 +080012 toxenvs: ['py27', 'py34', 'py35', 'py36'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070013 ],
14 [
15 label: 'freebsd11',
16 toxenvs: ['py27'],
17 ],
18 [
19 label: 'sierra',
Paul Kehrer90375552017-09-20 20:49:03 +080020 toxenvs: ['py27', 'py36'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070021 ],
22 [
23 label: 'yosemite',
24 toxenvs: ['py27'],
25 ],
26 [
27 label: 'docker',
28 imageName: 'pyca/cryptography-runner-centos7',
29 toxenvs: ['py27'],
30 ],
31 [
32 label: 'docker',
33 imageName: 'pyca/cryptography-runner-wheezy',
34 toxenvs: ['py27'],
35 ],
36 [
37 label: 'docker',
38 imageName: 'pyca/cryptography-runner-jessie',
39 toxenvs: ['py27', 'py34'],
40 ],
41 [
42 label: 'docker',
Alex Gaynor70639ed2017-07-08 11:53:58 -040043 imageName: 'pyca/cryptography-runner-stretch',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070044 toxenvs: ['py27', 'py35'],
45 ],
46 [
47 label: 'docker',
Alex Gaynor70639ed2017-07-08 11:53:58 -040048 imageName: 'pyca/cryptography-runner-buster',
Alex Gaynor20128c72017-10-28 19:16:49 -040049 toxenvs: ['py27', 'py36'],
Alex Gaynor70639ed2017-07-08 11:53:58 -040050 ],
51 [
52 label: 'docker',
53 imageName: 'pyca/cryptography-runner-sid',
Alex Gaynora87daea2017-10-11 21:36:30 -040054 toxenvs: ['py27', 'py36'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070055 ],
56 [
57 label: 'docker',
58 imageName: 'pyca/cryptography-runner-jessie-libressl:2.4.5',
59 toxenvs: ['py27'],
60 ],
61 [
62 label: 'docker',
Alex Gaynor24bb7a02017-12-25 13:49:48 -050063 imageName: 'pyca/cryptography-runner-jessie-libressl:2.6.4',
Alex Gaynor45f2a422017-07-26 09:10:32 -040064 toxenvs: ['py27'],
65 ],
66 [
67 label: 'docker',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070068 imageName: 'pyca/cryptography-runner-ubuntu-xenial',
69 toxenvs: ['py27', 'py35'],
70 ],
71 [
72 label: 'docker',
73 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
Alex Gaynorf2a03332017-10-21 09:13:42 -040074 toxenvs: ['py27', 'py36', 'randomorder'],
Alex Gaynor40226372017-05-23 14:14:18 -070075 ],
76 [
77 label: 'docker',
Paul Kehrer6bdae782017-06-06 08:45:01 -100078 imageName: 'pyca/cryptography-runner-sid',
Alex Gaynor40226372017-05-23 14:14:18 -070079 toxenvs: ['docs'],
80 artifacts: 'cryptography/docs/_build/html/**',
81 artifactExcludes: '**/*.doctree',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070082 ],
83 [
84 label: 'docker',
85 imageName: 'pyca/cryptography-runner-fedora',
Alex Gaynor2e64a3f2017-07-13 08:30:24 -040086 toxenvs: ['py27', 'py36'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070087 ],
Paul Kehrer8c0e7312017-06-25 12:22:07 -100088 [
89 label: 'docker',
90 imageName: 'pyca/cryptography-runner-alpine:latest',
91 toxenvs: ['py36'],
92 ],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070093]
94
95/* Add the linkcheck job to our config list if we're on master */
96if (env.BRANCH_NAME == "master") {
97 configs.add(
98 [
99 label: 'docker',
Paul Kehrer6bdae782017-06-06 08:45:01 -1000100 imageName: 'pyca/cryptography-runner-sid',
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700101 toxenvs: ['docs-linkcheck'],
102 ]
103 )
104}
105
106def downstreams = [
107 [
108 downstreamName: 'pyOpenSSL',
109 label: 'docker',
110 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
111 script: """#!/bin/bash -xe
Alex Gaynora7e9a222017-06-01 11:02:15 -0400112 git clone --depth=1 https://github.com/pyca/pyopenssl
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700113 cd pyopenssl
114 virtualenv .venv
115 source .venv/bin/activate
116 pip install ../cryptography
Paul Kehrerf564b7e2017-07-07 06:30:50 -0500117 pip install -e .[test]
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700118 pytest tests
119 """
120 ],
121 [
122 downstreamName: 'Twisted',
123 label: 'docker',
124 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
125 script: """#!/bin/bash -xe
Alex Gaynora7e9a222017-06-01 11:02:15 -0400126 git clone --depth=1 https://github.com/twisted/twisted
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700127 cd twisted
128 virtualenv .venv
129 source .venv/bin/activate
130 pip install ../cryptography
131 pip install pyopenssl service_identity pycrypto
132 pip install -e .
133 python -m twisted.trial src/twisted
134 """
135 ],
136 [
137 downstreamName: 'paramiko',
138 label: 'docker',
139 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
140 script: """#!/bin/bash -xe
Alex Gaynora7e9a222017-06-01 11:02:15 -0400141 git clone --depth=1 https://github.com/paramiko/paramiko
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700142 cd paramiko
143 virtualenv .venv
144 source .venv/bin/activate
145 pip install ../cryptography
146 pip install -e .
147 pip install -r dev-requirements.txt
148 inv test
149 """
150 ],
Paul Kehrer7254db52018-02-13 20:07:14 +0400151 [
152 downstreamName: 'aws-encryption-sdk',
153 label: 'docker',
154 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
155 script: """#!/bin/bash -xe
156 git clone --depth=1 https://github.com/awslabs/aws-encryption-sdk-python
157 cd aws-encryption-sdk-python
158 virtualenv .venv
159 source .venv/bin/activate
160 pip install ../cryptography
161 pip install pytest pytest-mock mock
162 pip install -e .
163 AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID="arn:aws:kms:us-west-2:nonsense" pytest -m local -l
164 """
165 ],
Jeremy Lainé83742062018-02-25 04:22:37 +0100166 [
167 downstreamName: 'certbot',
168 label: 'docker',
169 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
170 script: """#!/bin/bash -xe
171 git clone --depth=1 https://github.com/certbot/certbot
172 cd certbot
173 virtualenv .venv
174 source .venv/bin/activate
175 pip install ../cryptography
176 pip install pytest pytest-mock mock
177 pip install -e acme
178 pip install -e .
179 pytest certbot/tests
Paul Kehrer96787f92018-02-25 23:18:03 +0800180 pytest acme
181 """
182 ],
183 [
184 downstreamName: 'certbot-josepy',
185 label: 'docker',
186 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
187 script: """#!/bin/bash -xe
188 git clone --depth=1 https://github.com/certbot/josepy
189 cd josepy
190 virtualenv .venv
191 source .venv/bin/activate
192 pip install ../cryptography
193 pip install -e .[tests]
194 pytest src
Jeremy Lainé83742062018-02-25 04:22:37 +0100195 """
196 ],
Paul Kehrerec90afc2018-03-20 23:03:47 -0400197 [
198 downstreamName: 'urllib3',
199 label: 'docker',
200 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
201 script: """#!/bin/bash -xe
202 git clone --depth 1 https://github.com/shazow/urllib3
203 cd urllib3
204 virtualenv .venv
205 source .venv/bin/activate
206 pip install ../cryptography
207 pip install -r ./dev-requirements.txt
208 pip install -e .[socks]
209 pytest test
210 """
211 ],
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700212]
213
214def checkout_git(label) {
Alex Gaynor42b25712017-06-03 12:04:32 -0400215 retry(3) {
216 def script = ""
217 if (env.BRANCH_NAME.startsWith('PR-')) {
218 script = """
219 git clone --depth=1 https://github.com/pyca/cryptography
220 cd cryptography
221 git fetch origin +refs/pull/${env.CHANGE_ID}/merge:
222 git checkout -qf FETCH_HEAD
Paul Kehrera119d2e2017-05-23 22:02:50 -0700223 """
Alex Gaynor42b25712017-06-03 12:04:32 -0400224 if (label.contains("windows")) {
225 bat script
226 } else {
227 sh """#!/bin/sh
228 set -xe
229 ${script}
230 """
231 }
232 } else {
233 checkout([
234 $class: 'GitSCM',
235 branches: [[name: "*/${env.BRANCH_NAME}"]],
236 doGenerateSubmoduleConfigurations: false,
237 extensions: [[
238 $class: 'RelativeTargetDirectory',
239 relativeTargetDir: 'cryptography'
240 ]],
241 submoduleCfg: [],
242 userRemoteConfigs: [[
243 'url': 'https://github.com/pyca/cryptography'
244 ]]
245 ])
Paul Kehrera119d2e2017-05-23 22:02:50 -0700246 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700247 }
248 if (label.contains("windows")) {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700249 bat """
250 cd cryptography
251 git rev-parse HEAD
252 """
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700253 } else {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700254 sh """
255 cd cryptography
256 git rev-parse HEAD
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700257 """
258 }
259}
Alex Gaynor40226372017-05-23 14:14:18 -0700260def build(toxenv, label, imageName, artifacts, artifactExcludes) {
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700261 try {
262 timeout(time: 30, unit: 'MINUTES') {
263
264 checkout_git(label)
265
266 withCredentials([string(credentialsId: 'cryptography-codecov-token', variable: 'CODECOV_TOKEN')]) {
267 withEnv(["LABEL=$label", "TOXENV=$toxenv", "IMAGE_NAME=$imageName"]) {
268 if (label.contains("windows")) {
269 def pythonPath = [
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700270 py27: "C:\\Python27\\python.exe",
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700271 py34: "C:\\Python34\\python.exe",
272 py35: "C:\\Python35\\python.exe",
273 py36: "C:\\Python36\\python.exe"
274 ]
275 if (toxenv == "py35" || toxenv == "py36") {
276 opensslPaths = [
277 "windows": [
278 "include": "C:\\OpenSSL-Win32-2015\\include",
279 "lib": "C:\\OpenSSL-Win32-2015\\lib"
280 ],
281 "windows64": [
282 "include": "C:\\OpenSSL-Win64-2015\\include",
283 "lib": "C:\\OpenSSL-Win64-2015\\lib"
284 ]
285 ]
286 } else {
287 opensslPaths = [
288 "windows": [
289 "include": "C:\\OpenSSL-Win32-2010\\include",
290 "lib": "C:\\OpenSSL-Win32-2010\\lib"
291 ],
292 "windows64": [
293 "include": "C:\\OpenSSL-Win64-2010\\include",
294 "lib": "C:\\OpenSSL-Win64-2010\\lib"
295 ]
296 ]
297 }
298 bat """
299 cd cryptography
300 @set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH%
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700301 @set PYTHON="${pythonPath[toxenv]}"
302
303 @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE%
304 @set LIB="${opensslPaths[label]['lib']}";%LIB%
305 tox -r
306 IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
307 virtualenv .codecov
308 call .codecov/Scripts/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800309 REM this pin must be kept in sync with tox.ini
Paul Kehrercb175062017-06-03 08:26:56 -1000310 pip install coverage==4.3.4
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700311 pip install codecov
Paul Kehrer8396d432017-09-06 23:23:15 +0800312 codecov -e JOB_BASE_NAME,LABEL,TOXENV
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700313 """
314 } else if (label.contains("sierra") || label.contains("yosemite")) {
315 ansiColor {
316 sh """#!/usr/bin/env bash
317 set -xe
318 # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH
319 export PATH="/usr/local/bin:\${PATH}"
320 export PATH="/Users/jenkins/.pyenv/shims:\${PATH}"
321 cd cryptography
Paul Kehreradeaacf2017-05-24 12:49:18 -0700322 CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 \
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700323 LDFLAGS="/usr/local/opt/openssl\\@1.1/lib/libcrypto.a /usr/local/opt/openssl\\@1.1/lib/libssl.a" \
Paul Kehrerb637aec2017-05-30 20:56:15 -0500324 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" \
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700325 tox -r -- --color=yes
326 virtualenv .venv
327 source .venv/bin/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800328 # This pin must be kept in sync with tox.ini
Paul Kehrercb175062017-06-03 08:26:56 -1000329 pip install coverage==4.3.4
Paul Kehrer8396d432017-09-06 23:23:15 +0800330 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700331 """
332 }
333 } else {
334 ansiColor {
335 sh """#!/usr/bin/env bash
336 set -xe
337 cd cryptography
338 if [[ "\${IMAGE_NAME}" == *"libressl"* ]]; then
339 LD_LIBRARY_PATH="/usr/local/libressl/lib:\$LD_LIBRARY_PATH" \
340 LDFLAGS="-L/usr/local/libressl/lib" \
341 CFLAGS="-I/usr/local/libressl/include" \
342 tox -r -- --color=yes
343 else
344 tox -r -- --color=yes
345 fi
346 virtualenv .venv
347 source .venv/bin/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800348 # This pin must be kept in sync with tox.ini
Paul Kehrercb175062017-06-03 08:26:56 -1000349 pip install coverage==4.3.4
Paul Kehrer8396d432017-09-06 23:23:15 +0800350 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV,IMAGE_NAME
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700351 """
352 }
Alex Gaynor40226372017-05-23 14:14:18 -0700353 if (artifacts) {
354 archiveArtifacts artifacts: artifacts, excludes: artifactExcludes
355 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700356 }
357 }
358 }
359 }
360 } finally {
361 deleteDir()
362 }
363
364}
365
366def builders = [:]
367for (config in configs) {
368 def label = config["label"]
369 def toxenvs = config["toxenvs"]
Alex Gaynor40226372017-05-23 14:14:18 -0700370 def artifacts = config["artifacts"]
371 def artifactExcludes = config["artifactExcludes"]
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700372
373 for (_toxenv in toxenvs) {
374 def toxenv = _toxenv
375
376 if (label.contains("docker")) {
377 def imageName = config["imageName"]
378 def combinedName = "${imageName}-${toxenv}"
379 builders[combinedName] = {
380 node(label) {
381 stage(combinedName) {
Paul Kehrerc033c902017-07-07 13:20:29 -0500382 def buildImage = docker.image(imageName)
383 buildImage.pull()
384 buildImage.inside {
Alex Gaynor40226372017-05-23 14:14:18 -0700385 build(toxenv, label, imageName, artifacts, artifactExcludes)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700386 }
387 }
388 }
389 }
390 } else {
391 def combinedName = "${label}-${toxenv}"
392 builders[combinedName] = {
393 node(label) {
394 stage(combinedName) {
Alex Gaynor40226372017-05-23 14:14:18 -0700395 build(toxenv, label, '', null, null)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700396 }
397 }
398 }
399 }
400 }
401}
402
403/* Add the python setup.py test builder */
404builders["setup.py-test"] = {
405 node("docker") {
406 stage("python setup.py test") {
407 docker.image("pyca/cryptography-runner-ubuntu-rolling").inside {
408 try {
409 checkout_git("docker")
410 sh """#!/usr/bin/env bash
411 set -xe
412 cd cryptography
413 virtualenv .venv
414 source .venv/bin/activate
415 python setup.py test
416 """
417 } finally {
418 deleteDir()
419 }
420
421 }
422 }
423 }
424}
425
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700426for (downstream in downstreams) {
427 def downstreamName = downstream["downstreamName"]
428 def imageName = downstream["imageName"]
429 def label = downstream["label"]
430 def script = downstream["script"]
Paul Kehrer3d96afd2017-10-04 10:53:18 +0800431 builders[downstreamName] = {
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700432 node(label) {
433 docker.image(imageName).inside {
434 try {
435 timeout(time: 30, unit: 'MINUTES') {
436 checkout_git(label)
437 sh script
438 }
439 } finally {
440 deleteDir()
441 }
442 }
443 }
444 }
445}
446
Paul Kehrer3d96afd2017-10-04 10:53:18 +0800447parallel builders
448