blob: fab5de7d819f5a56cebc493791f2254fca1445af [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
107 pip install -e .
Paul Kehrerb16206e2017-06-29 22:17:08 -0500108 pip install pytest pretend
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700109 pytest tests
110 """
111 ],
112 [
113 downstreamName: 'Twisted',
114 label: 'docker',
115 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
116 script: """#!/bin/bash -xe
Alex Gaynora7e9a222017-06-01 11:02:15 -0400117 git clone --depth=1 https://github.com/twisted/twisted
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700118 cd twisted
119 virtualenv .venv
120 source .venv/bin/activate
121 pip install ../cryptography
122 pip install pyopenssl service_identity pycrypto
123 pip install -e .
124 python -m twisted.trial src/twisted
125 """
126 ],
127 [
128 downstreamName: 'paramiko',
129 label: 'docker',
130 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
131 script: """#!/bin/bash -xe
Alex Gaynora7e9a222017-06-01 11:02:15 -0400132 git clone --depth=1 https://github.com/paramiko/paramiko
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700133 cd paramiko
134 virtualenv .venv
135 source .venv/bin/activate
136 pip install ../cryptography
137 pip install -e .
138 pip install -r dev-requirements.txt
139 inv test
140 """
141 ],
142]
143
144def checkout_git(label) {
Alex Gaynor42b25712017-06-03 12:04:32 -0400145 retry(3) {
146 def script = ""
147 if (env.BRANCH_NAME.startsWith('PR-')) {
148 script = """
149 git clone --depth=1 https://github.com/pyca/cryptography
150 cd cryptography
151 git fetch origin +refs/pull/${env.CHANGE_ID}/merge:
152 git checkout -qf FETCH_HEAD
Paul Kehrera119d2e2017-05-23 22:02:50 -0700153 """
Alex Gaynor42b25712017-06-03 12:04:32 -0400154 if (label.contains("windows")) {
155 bat script
156 } else {
157 sh """#!/bin/sh
158 set -xe
159 ${script}
160 """
161 }
162 } else {
163 checkout([
164 $class: 'GitSCM',
165 branches: [[name: "*/${env.BRANCH_NAME}"]],
166 doGenerateSubmoduleConfigurations: false,
167 extensions: [[
168 $class: 'RelativeTargetDirectory',
169 relativeTargetDir: 'cryptography'
170 ]],
171 submoduleCfg: [],
172 userRemoteConfigs: [[
173 'url': 'https://github.com/pyca/cryptography'
174 ]]
175 ])
Paul Kehrera119d2e2017-05-23 22:02:50 -0700176 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700177 }
178 if (label.contains("windows")) {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700179 bat """
180 cd cryptography
181 git rev-parse HEAD
182 """
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700183 } else {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700184 sh """
185 cd cryptography
186 git rev-parse HEAD
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700187 """
188 }
189}
Alex Gaynor40226372017-05-23 14:14:18 -0700190def build(toxenv, label, imageName, artifacts, artifactExcludes) {
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700191 try {
192 timeout(time: 30, unit: 'MINUTES') {
193
194 checkout_git(label)
195
196 withCredentials([string(credentialsId: 'cryptography-codecov-token', variable: 'CODECOV_TOKEN')]) {
197 withEnv(["LABEL=$label", "TOXENV=$toxenv", "IMAGE_NAME=$imageName"]) {
198 if (label.contains("windows")) {
199 def pythonPath = [
200 py26: "C:\\Python26\\python.exe",
201 py27: "C:\\Python27\\python.exe",
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700202 py34: "C:\\Python34\\python.exe",
203 py35: "C:\\Python35\\python.exe",
204 py36: "C:\\Python36\\python.exe"
205 ]
206 if (toxenv == "py35" || toxenv == "py36") {
207 opensslPaths = [
208 "windows": [
209 "include": "C:\\OpenSSL-Win32-2015\\include",
210 "lib": "C:\\OpenSSL-Win32-2015\\lib"
211 ],
212 "windows64": [
213 "include": "C:\\OpenSSL-Win64-2015\\include",
214 "lib": "C:\\OpenSSL-Win64-2015\\lib"
215 ]
216 ]
217 } else {
218 opensslPaths = [
219 "windows": [
220 "include": "C:\\OpenSSL-Win32-2010\\include",
221 "lib": "C:\\OpenSSL-Win32-2010\\lib"
222 ],
223 "windows64": [
224 "include": "C:\\OpenSSL-Win64-2010\\include",
225 "lib": "C:\\OpenSSL-Win64-2010\\lib"
226 ]
227 ]
228 }
229 bat """
230 cd cryptography
231 @set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH%
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700232 @set PYTHON="${pythonPath[toxenv]}"
233
234 @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE%
235 @set LIB="${opensslPaths[label]['lib']}";%LIB%
236 tox -r
237 IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
238 virtualenv .codecov
239 call .codecov/Scripts/activate
Paul Kehrercb175062017-06-03 08:26:56 -1000240 pip install coverage==4.3.4
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700241 pip install codecov
242 codecov -e JOB_BASE_NAME,LABEL
243 """
244 } else if (label.contains("sierra") || label.contains("yosemite")) {
245 ansiColor {
246 sh """#!/usr/bin/env bash
247 set -xe
248 # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH
249 export PATH="/usr/local/bin:\${PATH}"
250 export PATH="/Users/jenkins/.pyenv/shims:\${PATH}"
251 cd cryptography
Paul Kehreradeaacf2017-05-24 12:49:18 -0700252 CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 \
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700253 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 -0500254 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 -0700255 tox -r -- --color=yes
256 virtualenv .venv
257 source .venv/bin/activate
Paul Kehrercb175062017-06-03 08:26:56 -1000258 pip install coverage==4.3.4
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700259 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL
260 """
261 }
262 } else {
263 ansiColor {
264 sh """#!/usr/bin/env bash
265 set -xe
266 cd cryptography
267 if [[ "\${IMAGE_NAME}" == *"libressl"* ]]; then
268 LD_LIBRARY_PATH="/usr/local/libressl/lib:\$LD_LIBRARY_PATH" \
269 LDFLAGS="-L/usr/local/libressl/lib" \
270 CFLAGS="-I/usr/local/libressl/include" \
271 tox -r -- --color=yes
272 else
273 tox -r -- --color=yes
274 fi
275 virtualenv .venv
276 source .venv/bin/activate
Paul Kehrercb175062017-06-03 08:26:56 -1000277 pip install coverage==4.3.4
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700278 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL
279 """
280 }
Alex Gaynor40226372017-05-23 14:14:18 -0700281 if (artifacts) {
282 archiveArtifacts artifacts: artifacts, excludes: artifactExcludes
283 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700284 }
285 }
286 }
287 }
288 } finally {
289 deleteDir()
290 }
291
292}
293
294def builders = [:]
295for (config in configs) {
296 def label = config["label"]
297 def toxenvs = config["toxenvs"]
Alex Gaynor40226372017-05-23 14:14:18 -0700298 def artifacts = config["artifacts"]
299 def artifactExcludes = config["artifactExcludes"]
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700300
301 for (_toxenv in toxenvs) {
302 def toxenv = _toxenv
303
304 if (label.contains("docker")) {
305 def imageName = config["imageName"]
306 def combinedName = "${imageName}-${toxenv}"
307 builders[combinedName] = {
308 node(label) {
309 stage(combinedName) {
310 docker.image(imageName).inside {
Alex Gaynor40226372017-05-23 14:14:18 -0700311 build(toxenv, label, imageName, artifacts, artifactExcludes)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700312 }
313 }
314 }
315 }
316 } else {
317 def combinedName = "${label}-${toxenv}"
318 builders[combinedName] = {
319 node(label) {
320 stage(combinedName) {
Alex Gaynor40226372017-05-23 14:14:18 -0700321 build(toxenv, label, '', null, null)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700322 }
323 }
324 }
325 }
326 }
327}
328
329/* Add the python setup.py test builder */
330builders["setup.py-test"] = {
331 node("docker") {
332 stage("python setup.py test") {
333 docker.image("pyca/cryptography-runner-ubuntu-rolling").inside {
334 try {
335 checkout_git("docker")
336 sh """#!/usr/bin/env bash
337 set -xe
338 cd cryptography
339 virtualenv .venv
340 source .venv/bin/activate
341 python setup.py test
342 """
343 } finally {
344 deleteDir()
345 }
346
347 }
348 }
349 }
350}
351
352parallel builders
353
354def downstreamBuilders = [:]
355for (downstream in downstreams) {
356 def downstreamName = downstream["downstreamName"]
357 def imageName = downstream["imageName"]
358 def label = downstream["label"]
359 def script = downstream["script"]
360 downstreamBuilders[downstreamName] = {
361 node(label) {
362 docker.image(imageName).inside {
363 try {
364 timeout(time: 30, unit: 'MINUTES') {
365 checkout_git(label)
366 sh script
367 }
368 } finally {
369 deleteDir()
370 }
371 }
372 }
373 }
374}
375
376stage("Downstreams") {
377 parallel downstreamBuilders
378}