blob: 8f291172a6be255fdb77573634eba1f7e4d86bde [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
180 """
181 ],
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700182]
183
184def checkout_git(label) {
Alex Gaynor42b25712017-06-03 12:04:32 -0400185 retry(3) {
186 def script = ""
187 if (env.BRANCH_NAME.startsWith('PR-')) {
188 script = """
189 git clone --depth=1 https://github.com/pyca/cryptography
190 cd cryptography
191 git fetch origin +refs/pull/${env.CHANGE_ID}/merge:
192 git checkout -qf FETCH_HEAD
Paul Kehrera119d2e2017-05-23 22:02:50 -0700193 """
Alex Gaynor42b25712017-06-03 12:04:32 -0400194 if (label.contains("windows")) {
195 bat script
196 } else {
197 sh """#!/bin/sh
198 set -xe
199 ${script}
200 """
201 }
202 } else {
203 checkout([
204 $class: 'GitSCM',
205 branches: [[name: "*/${env.BRANCH_NAME}"]],
206 doGenerateSubmoduleConfigurations: false,
207 extensions: [[
208 $class: 'RelativeTargetDirectory',
209 relativeTargetDir: 'cryptography'
210 ]],
211 submoduleCfg: [],
212 userRemoteConfigs: [[
213 'url': 'https://github.com/pyca/cryptography'
214 ]]
215 ])
Paul Kehrera119d2e2017-05-23 22:02:50 -0700216 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700217 }
218 if (label.contains("windows")) {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700219 bat """
220 cd cryptography
221 git rev-parse HEAD
222 """
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700223 } else {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700224 sh """
225 cd cryptography
226 git rev-parse HEAD
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700227 """
228 }
229}
Alex Gaynor40226372017-05-23 14:14:18 -0700230def build(toxenv, label, imageName, artifacts, artifactExcludes) {
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700231 try {
232 timeout(time: 30, unit: 'MINUTES') {
233
234 checkout_git(label)
235
236 withCredentials([string(credentialsId: 'cryptography-codecov-token', variable: 'CODECOV_TOKEN')]) {
237 withEnv(["LABEL=$label", "TOXENV=$toxenv", "IMAGE_NAME=$imageName"]) {
238 if (label.contains("windows")) {
239 def pythonPath = [
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700240 py27: "C:\\Python27\\python.exe",
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700241 py34: "C:\\Python34\\python.exe",
242 py35: "C:\\Python35\\python.exe",
243 py36: "C:\\Python36\\python.exe"
244 ]
245 if (toxenv == "py35" || toxenv == "py36") {
246 opensslPaths = [
247 "windows": [
248 "include": "C:\\OpenSSL-Win32-2015\\include",
249 "lib": "C:\\OpenSSL-Win32-2015\\lib"
250 ],
251 "windows64": [
252 "include": "C:\\OpenSSL-Win64-2015\\include",
253 "lib": "C:\\OpenSSL-Win64-2015\\lib"
254 ]
255 ]
256 } else {
257 opensslPaths = [
258 "windows": [
259 "include": "C:\\OpenSSL-Win32-2010\\include",
260 "lib": "C:\\OpenSSL-Win32-2010\\lib"
261 ],
262 "windows64": [
263 "include": "C:\\OpenSSL-Win64-2010\\include",
264 "lib": "C:\\OpenSSL-Win64-2010\\lib"
265 ]
266 ]
267 }
268 bat """
269 cd cryptography
270 @set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH%
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700271 @set PYTHON="${pythonPath[toxenv]}"
272
273 @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE%
274 @set LIB="${opensslPaths[label]['lib']}";%LIB%
275 tox -r
276 IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
277 virtualenv .codecov
278 call .codecov/Scripts/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800279 REM this pin must be kept in sync with tox.ini
Paul Kehrercb175062017-06-03 08:26:56 -1000280 pip install coverage==4.3.4
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700281 pip install codecov
Paul Kehrer8396d432017-09-06 23:23:15 +0800282 codecov -e JOB_BASE_NAME,LABEL,TOXENV
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700283 """
284 } else if (label.contains("sierra") || label.contains("yosemite")) {
285 ansiColor {
286 sh """#!/usr/bin/env bash
287 set -xe
288 # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH
289 export PATH="/usr/local/bin:\${PATH}"
290 export PATH="/Users/jenkins/.pyenv/shims:\${PATH}"
291 cd cryptography
Paul Kehreradeaacf2017-05-24 12:49:18 -0700292 CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 \
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700293 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 -0500294 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 -0700295 tox -r -- --color=yes
296 virtualenv .venv
297 source .venv/bin/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800298 # This pin must be kept in sync with tox.ini
Paul Kehrercb175062017-06-03 08:26:56 -1000299 pip install coverage==4.3.4
Paul Kehrer8396d432017-09-06 23:23:15 +0800300 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700301 """
302 }
303 } else {
304 ansiColor {
305 sh """#!/usr/bin/env bash
306 set -xe
307 cd cryptography
308 if [[ "\${IMAGE_NAME}" == *"libressl"* ]]; then
309 LD_LIBRARY_PATH="/usr/local/libressl/lib:\$LD_LIBRARY_PATH" \
310 LDFLAGS="-L/usr/local/libressl/lib" \
311 CFLAGS="-I/usr/local/libressl/include" \
312 tox -r -- --color=yes
313 else
314 tox -r -- --color=yes
315 fi
316 virtualenv .venv
317 source .venv/bin/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800318 # This pin must be kept in sync with tox.ini
Paul Kehrercb175062017-06-03 08:26:56 -1000319 pip install coverage==4.3.4
Paul Kehrer8396d432017-09-06 23:23:15 +0800320 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV,IMAGE_NAME
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700321 """
322 }
Alex Gaynor40226372017-05-23 14:14:18 -0700323 if (artifacts) {
324 archiveArtifacts artifacts: artifacts, excludes: artifactExcludes
325 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700326 }
327 }
328 }
329 }
330 } finally {
331 deleteDir()
332 }
333
334}
335
336def builders = [:]
337for (config in configs) {
338 def label = config["label"]
339 def toxenvs = config["toxenvs"]
Alex Gaynor40226372017-05-23 14:14:18 -0700340 def artifacts = config["artifacts"]
341 def artifactExcludes = config["artifactExcludes"]
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700342
343 for (_toxenv in toxenvs) {
344 def toxenv = _toxenv
345
346 if (label.contains("docker")) {
347 def imageName = config["imageName"]
348 def combinedName = "${imageName}-${toxenv}"
349 builders[combinedName] = {
350 node(label) {
351 stage(combinedName) {
Paul Kehrerc033c902017-07-07 13:20:29 -0500352 def buildImage = docker.image(imageName)
353 buildImage.pull()
354 buildImage.inside {
Alex Gaynor40226372017-05-23 14:14:18 -0700355 build(toxenv, label, imageName, artifacts, artifactExcludes)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700356 }
357 }
358 }
359 }
360 } else {
361 def combinedName = "${label}-${toxenv}"
362 builders[combinedName] = {
363 node(label) {
364 stage(combinedName) {
Alex Gaynor40226372017-05-23 14:14:18 -0700365 build(toxenv, label, '', null, null)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700366 }
367 }
368 }
369 }
370 }
371}
372
373/* Add the python setup.py test builder */
374builders["setup.py-test"] = {
375 node("docker") {
376 stage("python setup.py test") {
377 docker.image("pyca/cryptography-runner-ubuntu-rolling").inside {
378 try {
379 checkout_git("docker")
380 sh """#!/usr/bin/env bash
381 set -xe
382 cd cryptography
383 virtualenv .venv
384 source .venv/bin/activate
385 python setup.py test
386 """
387 } finally {
388 deleteDir()
389 }
390
391 }
392 }
393 }
394}
395
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700396for (downstream in downstreams) {
397 def downstreamName = downstream["downstreamName"]
398 def imageName = downstream["imageName"]
399 def label = downstream["label"]
400 def script = downstream["script"]
Paul Kehrer3d96afd2017-10-04 10:53:18 +0800401 builders[downstreamName] = {
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700402 node(label) {
403 docker.image(imageName).inside {
404 try {
405 timeout(time: 30, unit: 'MINUTES') {
406 checkout_git(label)
407 sh script
408 }
409 } finally {
410 deleteDir()
411 }
412 }
413 }
414 }
415}
416
Paul Kehrer3d96afd2017-10-04 10:53:18 +0800417parallel builders
418