blob: 8742e85889a656070e76919aa92ddc3dbe3603b4 [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 Kehrere3a2fb22017-06-26 15:08:33 -10008 toxenvs: ['py26', 'py27', 'py34', 'py35', 'py36'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -07009 ],
10 [
11 label: 'windows64',
Paul Kehrere3a2fb22017-06-26 15:08:33 -100012 toxenvs: ['py26', 'py27', 'py34', 'py35', 'py36'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070013 ],
14 [
15 label: 'freebsd11',
16 toxenvs: ['py27'],
17 ],
18 [
19 label: 'sierra',
20 toxenvs: ['py27'],
21 ],
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',
49 toxenvs: ['py27', 'py35'],
50 ],
51 [
52 label: 'docker',
53 imageName: 'pyca/cryptography-runner-sid',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070054 toxenvs: ['py27', 'py35'],
55 ],
56 [
57 label: 'docker',
58 imageName: 'pyca/cryptography-runner-jessie-libressl:2.4.5',
59 toxenvs: ['py27'],
60 ],
61 [
62 label: 'docker',
Alex Gaynorb5223242017-09-15 02:37:39 -040063 imageName: 'pyca/cryptography-runner-jessie-libressl:2.6.1',
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',
Paul Kehrer9c635242017-07-08 12:02:15 -050074 toxenvs: ['py27', 'py35', '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 ],
151]
152
153def checkout_git(label) {
Alex Gaynor42b25712017-06-03 12:04:32 -0400154 retry(3) {
155 def script = ""
156 if (env.BRANCH_NAME.startsWith('PR-')) {
157 script = """
158 git clone --depth=1 https://github.com/pyca/cryptography
159 cd cryptography
160 git fetch origin +refs/pull/${env.CHANGE_ID}/merge:
161 git checkout -qf FETCH_HEAD
Paul Kehrera119d2e2017-05-23 22:02:50 -0700162 """
Alex Gaynor42b25712017-06-03 12:04:32 -0400163 if (label.contains("windows")) {
164 bat script
165 } else {
166 sh """#!/bin/sh
167 set -xe
168 ${script}
169 """
170 }
171 } else {
172 checkout([
173 $class: 'GitSCM',
174 branches: [[name: "*/${env.BRANCH_NAME}"]],
175 doGenerateSubmoduleConfigurations: false,
176 extensions: [[
177 $class: 'RelativeTargetDirectory',
178 relativeTargetDir: 'cryptography'
179 ]],
180 submoduleCfg: [],
181 userRemoteConfigs: [[
182 'url': 'https://github.com/pyca/cryptography'
183 ]]
184 ])
Paul Kehrera119d2e2017-05-23 22:02:50 -0700185 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700186 }
187 if (label.contains("windows")) {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700188 bat """
189 cd cryptography
190 git rev-parse HEAD
191 """
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700192 } else {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700193 sh """
194 cd cryptography
195 git rev-parse HEAD
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700196 """
197 }
198}
Alex Gaynor40226372017-05-23 14:14:18 -0700199def build(toxenv, label, imageName, artifacts, artifactExcludes) {
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700200 try {
201 timeout(time: 30, unit: 'MINUTES') {
202
203 checkout_git(label)
204
205 withCredentials([string(credentialsId: 'cryptography-codecov-token', variable: 'CODECOV_TOKEN')]) {
206 withEnv(["LABEL=$label", "TOXENV=$toxenv", "IMAGE_NAME=$imageName"]) {
207 if (label.contains("windows")) {
208 def pythonPath = [
209 py26: "C:\\Python26\\python.exe",
210 py27: "C:\\Python27\\python.exe",
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700211 py34: "C:\\Python34\\python.exe",
212 py35: "C:\\Python35\\python.exe",
213 py36: "C:\\Python36\\python.exe"
214 ]
215 if (toxenv == "py35" || toxenv == "py36") {
216 opensslPaths = [
217 "windows": [
218 "include": "C:\\OpenSSL-Win32-2015\\include",
219 "lib": "C:\\OpenSSL-Win32-2015\\lib"
220 ],
221 "windows64": [
222 "include": "C:\\OpenSSL-Win64-2015\\include",
223 "lib": "C:\\OpenSSL-Win64-2015\\lib"
224 ]
225 ]
226 } else {
227 opensslPaths = [
228 "windows": [
229 "include": "C:\\OpenSSL-Win32-2010\\include",
230 "lib": "C:\\OpenSSL-Win32-2010\\lib"
231 ],
232 "windows64": [
233 "include": "C:\\OpenSSL-Win64-2010\\include",
234 "lib": "C:\\OpenSSL-Win64-2010\\lib"
235 ]
236 ]
237 }
238 bat """
239 cd cryptography
240 @set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH%
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700241 @set PYTHON="${pythonPath[toxenv]}"
242
243 @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE%
244 @set LIB="${opensslPaths[label]['lib']}";%LIB%
245 tox -r
246 IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
247 virtualenv .codecov
248 call .codecov/Scripts/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800249 REM this pin must be kept in sync with tox.ini
Paul Kehrercb175062017-06-03 08:26:56 -1000250 pip install coverage==4.3.4
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700251 pip install codecov
Paul Kehrer8396d432017-09-06 23:23:15 +0800252 codecov -e JOB_BASE_NAME,LABEL,TOXENV
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700253 """
254 } else if (label.contains("sierra") || label.contains("yosemite")) {
255 ansiColor {
256 sh """#!/usr/bin/env bash
257 set -xe
258 # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH
259 export PATH="/usr/local/bin:\${PATH}"
260 export PATH="/Users/jenkins/.pyenv/shims:\${PATH}"
261 cd cryptography
Paul Kehreradeaacf2017-05-24 12:49:18 -0700262 CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 \
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700263 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 -0500264 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 -0700265 tox -r -- --color=yes
266 virtualenv .venv
267 source .venv/bin/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800268 # This pin must be kept in sync with tox.ini
Paul Kehrercb175062017-06-03 08:26:56 -1000269 pip install coverage==4.3.4
Paul Kehrer8396d432017-09-06 23:23:15 +0800270 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700271 """
272 }
273 } else {
274 ansiColor {
275 sh """#!/usr/bin/env bash
276 set -xe
277 cd cryptography
278 if [[ "\${IMAGE_NAME}" == *"libressl"* ]]; then
279 LD_LIBRARY_PATH="/usr/local/libressl/lib:\$LD_LIBRARY_PATH" \
280 LDFLAGS="-L/usr/local/libressl/lib" \
281 CFLAGS="-I/usr/local/libressl/include" \
282 tox -r -- --color=yes
283 else
284 tox -r -- --color=yes
285 fi
286 virtualenv .venv
287 source .venv/bin/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800288 # This pin must be kept in sync with tox.ini
Paul Kehrercb175062017-06-03 08:26:56 -1000289 pip install coverage==4.3.4
Paul Kehrer8396d432017-09-06 23:23:15 +0800290 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV,IMAGE_NAME
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700291 """
292 }
Alex Gaynor40226372017-05-23 14:14:18 -0700293 if (artifacts) {
294 archiveArtifacts artifacts: artifacts, excludes: artifactExcludes
295 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700296 }
297 }
298 }
299 }
300 } finally {
301 deleteDir()
302 }
303
304}
305
306def builders = [:]
307for (config in configs) {
308 def label = config["label"]
309 def toxenvs = config["toxenvs"]
Alex Gaynor40226372017-05-23 14:14:18 -0700310 def artifacts = config["artifacts"]
311 def artifactExcludes = config["artifactExcludes"]
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700312
313 for (_toxenv in toxenvs) {
314 def toxenv = _toxenv
315
316 if (label.contains("docker")) {
317 def imageName = config["imageName"]
318 def combinedName = "${imageName}-${toxenv}"
319 builders[combinedName] = {
320 node(label) {
321 stage(combinedName) {
Paul Kehrerc033c902017-07-07 13:20:29 -0500322 def buildImage = docker.image(imageName)
323 buildImage.pull()
324 buildImage.inside {
Alex Gaynor40226372017-05-23 14:14:18 -0700325 build(toxenv, label, imageName, artifacts, artifactExcludes)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700326 }
327 }
328 }
329 }
330 } else {
331 def combinedName = "${label}-${toxenv}"
332 builders[combinedName] = {
333 node(label) {
334 stage(combinedName) {
Alex Gaynor40226372017-05-23 14:14:18 -0700335 build(toxenv, label, '', null, null)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700336 }
337 }
338 }
339 }
340 }
341}
342
343/* Add the python setup.py test builder */
344builders["setup.py-test"] = {
345 node("docker") {
346 stage("python setup.py test") {
347 docker.image("pyca/cryptography-runner-ubuntu-rolling").inside {
348 try {
349 checkout_git("docker")
350 sh """#!/usr/bin/env bash
351 set -xe
352 cd cryptography
353 virtualenv .venv
354 source .venv/bin/activate
355 python setup.py test
356 """
357 } finally {
358 deleteDir()
359 }
360
361 }
362 }
363 }
364}
365
366parallel builders
367
368def downstreamBuilders = [:]
369for (downstream in downstreams) {
370 def downstreamName = downstream["downstreamName"]
371 def imageName = downstream["imageName"]
372 def label = downstream["label"]
373 def script = downstream["script"]
374 downstreamBuilders[downstreamName] = {
375 node(label) {
376 docker.image(imageName).inside {
377 try {
378 timeout(time: 30, unit: 'MINUTES') {
379 checkout_git(label)
380 sh script
381 }
382 } finally {
383 deleteDir()
384 }
385 }
386 }
387 }
388}
389
390stage("Downstreams") {
391 parallel downstreamBuilders
392}