blob: c7710d64c8d43c195b094543dc4ccf4238e67fc1 [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',
43 imageName: 'pyca/cryptography-runner-sid',
44 toxenvs: ['py27', 'py35'],
45 ],
46 [
47 label: 'docker',
48 imageName: 'pyca/cryptography-runner-stretch',
49 toxenvs: ['py27', 'py35'],
50 ],
51 [
52 label: 'docker',
53 imageName: 'pyca/cryptography-runner-jessie-libressl:2.4.5',
54 toxenvs: ['py27'],
55 ],
56 [
57 label: 'docker',
58 imageName: 'pyca/cryptography-runner-ubuntu-xenial',
59 toxenvs: ['py27', 'py35'],
60 ],
61 [
62 label: 'docker',
63 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
Alex Gaynor40226372017-05-23 14:14:18 -070064 toxenvs: ['py27', 'py35', 'pep8', 'py3pep8', 'randomorder'],
65 ],
66 [
67 label: 'docker',
Paul Kehrer6bdae782017-06-06 08:45:01 -100068 imageName: 'pyca/cryptography-runner-sid',
Alex Gaynor40226372017-05-23 14:14:18 -070069 toxenvs: ['docs'],
70 artifacts: 'cryptography/docs/_build/html/**',
71 artifactExcludes: '**/*.doctree',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070072 ],
73 [
74 label: 'docker',
75 imageName: 'pyca/cryptography-runner-fedora',
76 toxenvs: ['py27', 'py35'],
77 ],
Paul Kehrer8c0e7312017-06-25 12:22:07 -100078 [
79 label: 'docker',
80 imageName: 'pyca/cryptography-runner-alpine:latest',
81 toxenvs: ['py36'],
82 ],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070083]
84
85/* Add the linkcheck job to our config list if we're on master */
86if (env.BRANCH_NAME == "master") {
87 configs.add(
88 [
89 label: 'docker',
Paul Kehrer6bdae782017-06-06 08:45:01 -100090 imageName: 'pyca/cryptography-runner-sid',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070091 toxenvs: ['docs-linkcheck'],
92 ]
93 )
94}
95
96def downstreams = [
97 [
98 downstreamName: 'pyOpenSSL',
99 label: 'docker',
100 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
101 script: """#!/bin/bash -xe
Alex Gaynora7e9a222017-06-01 11:02:15 -0400102 git clone --depth=1 https://github.com/pyca/pyopenssl
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700103 cd pyopenssl
104 virtualenv .venv
105 source .venv/bin/activate
106 pip install ../cryptography
Paul Kehrerf564b7e2017-07-07 06:30:50 -0500107 pip install -e .[test]
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700108 pytest tests
109 """
110 ],
111 [
112 downstreamName: 'Twisted',
113 label: 'docker',
114 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
115 script: """#!/bin/bash -xe
Alex Gaynora7e9a222017-06-01 11:02:15 -0400116 git clone --depth=1 https://github.com/twisted/twisted
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700117 cd twisted
118 virtualenv .venv
119 source .venv/bin/activate
120 pip install ../cryptography
121 pip install pyopenssl service_identity pycrypto
122 pip install -e .
123 python -m twisted.trial src/twisted
124 """
125 ],
126 [
127 downstreamName: 'paramiko',
128 label: 'docker',
129 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
130 script: """#!/bin/bash -xe
Alex Gaynora7e9a222017-06-01 11:02:15 -0400131 git clone --depth=1 https://github.com/paramiko/paramiko
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700132 cd paramiko
133 virtualenv .venv
134 source .venv/bin/activate
135 pip install ../cryptography
136 pip install -e .
137 pip install -r dev-requirements.txt
138 inv test
139 """
140 ],
141]
142
143def checkout_git(label) {
Alex Gaynor42b25712017-06-03 12:04:32 -0400144 retry(3) {
145 def script = ""
146 if (env.BRANCH_NAME.startsWith('PR-')) {
147 script = """
148 git clone --depth=1 https://github.com/pyca/cryptography
149 cd cryptography
150 git fetch origin +refs/pull/${env.CHANGE_ID}/merge:
151 git checkout -qf FETCH_HEAD
Paul Kehrera119d2e2017-05-23 22:02:50 -0700152 """
Alex Gaynor42b25712017-06-03 12:04:32 -0400153 if (label.contains("windows")) {
154 bat script
155 } else {
156 sh """#!/bin/sh
157 set -xe
158 ${script}
159 """
160 }
161 } else {
162 checkout([
163 $class: 'GitSCM',
164 branches: [[name: "*/${env.BRANCH_NAME}"]],
165 doGenerateSubmoduleConfigurations: false,
166 extensions: [[
167 $class: 'RelativeTargetDirectory',
168 relativeTargetDir: 'cryptography'
169 ]],
170 submoduleCfg: [],
171 userRemoteConfigs: [[
172 'url': 'https://github.com/pyca/cryptography'
173 ]]
174 ])
Paul Kehrera119d2e2017-05-23 22:02:50 -0700175 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700176 }
177 if (label.contains("windows")) {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700178 bat """
179 cd cryptography
180 git rev-parse HEAD
181 """
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700182 } else {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700183 sh """
184 cd cryptography
185 git rev-parse HEAD
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700186 """
187 }
188}
Alex Gaynor40226372017-05-23 14:14:18 -0700189def build(toxenv, label, imageName, artifacts, artifactExcludes) {
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700190 try {
191 timeout(time: 30, unit: 'MINUTES') {
192
193 checkout_git(label)
194
195 withCredentials([string(credentialsId: 'cryptography-codecov-token', variable: 'CODECOV_TOKEN')]) {
196 withEnv(["LABEL=$label", "TOXENV=$toxenv", "IMAGE_NAME=$imageName"]) {
197 if (label.contains("windows")) {
198 def pythonPath = [
199 py26: "C:\\Python26\\python.exe",
200 py27: "C:\\Python27\\python.exe",
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700201 py34: "C:\\Python34\\python.exe",
202 py35: "C:\\Python35\\python.exe",
203 py36: "C:\\Python36\\python.exe"
204 ]
205 if (toxenv == "py35" || toxenv == "py36") {
206 opensslPaths = [
207 "windows": [
208 "include": "C:\\OpenSSL-Win32-2015\\include",
209 "lib": "C:\\OpenSSL-Win32-2015\\lib"
210 ],
211 "windows64": [
212 "include": "C:\\OpenSSL-Win64-2015\\include",
213 "lib": "C:\\OpenSSL-Win64-2015\\lib"
214 ]
215 ]
216 } else {
217 opensslPaths = [
218 "windows": [
219 "include": "C:\\OpenSSL-Win32-2010\\include",
220 "lib": "C:\\OpenSSL-Win32-2010\\lib"
221 ],
222 "windows64": [
223 "include": "C:\\OpenSSL-Win64-2010\\include",
224 "lib": "C:\\OpenSSL-Win64-2010\\lib"
225 ]
226 ]
227 }
228 bat """
229 cd cryptography
230 @set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH%
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700231 @set PYTHON="${pythonPath[toxenv]}"
232
233 @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE%
234 @set LIB="${opensslPaths[label]['lib']}";%LIB%
235 tox -r
236 IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
237 virtualenv .codecov
238 call .codecov/Scripts/activate
Paul Kehrercb175062017-06-03 08:26:56 -1000239 pip install coverage==4.3.4
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700240 pip install codecov
241 codecov -e JOB_BASE_NAME,LABEL
242 """
243 } else if (label.contains("sierra") || label.contains("yosemite")) {
244 ansiColor {
245 sh """#!/usr/bin/env bash
246 set -xe
247 # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH
248 export PATH="/usr/local/bin:\${PATH}"
249 export PATH="/Users/jenkins/.pyenv/shims:\${PATH}"
250 cd cryptography
Paul Kehreradeaacf2017-05-24 12:49:18 -0700251 CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 \
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700252 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 -0500253 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 -0700254 tox -r -- --color=yes
255 virtualenv .venv
256 source .venv/bin/activate
Paul Kehrercb175062017-06-03 08:26:56 -1000257 pip install coverage==4.3.4
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700258 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL
259 """
260 }
261 } else {
262 ansiColor {
263 sh """#!/usr/bin/env bash
264 set -xe
265 cd cryptography
266 if [[ "\${IMAGE_NAME}" == *"libressl"* ]]; then
267 LD_LIBRARY_PATH="/usr/local/libressl/lib:\$LD_LIBRARY_PATH" \
268 LDFLAGS="-L/usr/local/libressl/lib" \
269 CFLAGS="-I/usr/local/libressl/include" \
270 tox -r -- --color=yes
271 else
272 tox -r -- --color=yes
273 fi
274 virtualenv .venv
275 source .venv/bin/activate
Paul Kehrercb175062017-06-03 08:26:56 -1000276 pip install coverage==4.3.4
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700277 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL
278 """
279 }
Alex Gaynor40226372017-05-23 14:14:18 -0700280 if (artifacts) {
281 archiveArtifacts artifacts: artifacts, excludes: artifactExcludes
282 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700283 }
284 }
285 }
286 }
287 } finally {
288 deleteDir()
289 }
290
291}
292
293def builders = [:]
294for (config in configs) {
295 def label = config["label"]
296 def toxenvs = config["toxenvs"]
Alex Gaynor40226372017-05-23 14:14:18 -0700297 def artifacts = config["artifacts"]
298 def artifactExcludes = config["artifactExcludes"]
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700299
300 for (_toxenv in toxenvs) {
301 def toxenv = _toxenv
302
303 if (label.contains("docker")) {
304 def imageName = config["imageName"]
305 def combinedName = "${imageName}-${toxenv}"
306 builders[combinedName] = {
307 node(label) {
308 stage(combinedName) {
Paul Kehrerc033c902017-07-07 13:20:29 -0500309 def buildImage = docker.image(imageName)
310 buildImage.pull()
311 buildImage.inside {
Alex Gaynor40226372017-05-23 14:14:18 -0700312 build(toxenv, label, imageName, artifacts, artifactExcludes)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700313 }
314 }
315 }
316 }
317 } else {
318 def combinedName = "${label}-${toxenv}"
319 builders[combinedName] = {
320 node(label) {
321 stage(combinedName) {
Alex Gaynor40226372017-05-23 14:14:18 -0700322 build(toxenv, label, '', null, null)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700323 }
324 }
325 }
326 }
327 }
328}
329
330/* Add the python setup.py test builder */
331builders["setup.py-test"] = {
332 node("docker") {
333 stage("python setup.py test") {
334 docker.image("pyca/cryptography-runner-ubuntu-rolling").inside {
335 try {
336 checkout_git("docker")
337 sh """#!/usr/bin/env bash
338 set -xe
339 cd cryptography
340 virtualenv .venv
341 source .venv/bin/activate
342 python setup.py test
343 """
344 } finally {
345 deleteDir()
346 }
347
348 }
349 }
350 }
351}
352
353parallel builders
354
355def downstreamBuilders = [:]
356for (downstream in downstreams) {
357 def downstreamName = downstream["downstreamName"]
358 def imageName = downstream["imageName"]
359 def label = downstream["label"]
360 def script = downstream["script"]
361 downstreamBuilders[downstreamName] = {
362 node(label) {
363 docker.image(imageName).inside {
364 try {
365 timeout(time: 30, unit: 'MINUTES') {
366 checkout_git(label)
367 sh script
368 }
369 } finally {
370 deleteDir()
371 }
372 }
373 }
374 }
375}
376
377stage("Downstreams") {
378 parallel downstreamBuilders
379}