blob: d953a48e78bb3823d3879e27c4f4661d38934ef3 [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',
63 imageName: 'pyca/cryptography-runner-ubuntu-xenial',
64 toxenvs: ['py27', 'py35'],
65 ],
66 [
67 label: 'docker',
68 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
Paul Kehrer9c635242017-07-08 12:02:15 -050069 toxenvs: ['py27', 'py35', 'randomorder'],
Alex Gaynor40226372017-05-23 14:14:18 -070070 ],
71 [
72 label: 'docker',
Paul Kehrer6bdae782017-06-06 08:45:01 -100073 imageName: 'pyca/cryptography-runner-sid',
Alex Gaynor40226372017-05-23 14:14:18 -070074 toxenvs: ['docs'],
75 artifacts: 'cryptography/docs/_build/html/**',
76 artifactExcludes: '**/*.doctree',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070077 ],
78 [
79 label: 'docker',
80 imageName: 'pyca/cryptography-runner-fedora',
81 toxenvs: ['py27', 'py35'],
82 ],
Paul Kehrer8c0e7312017-06-25 12:22:07 -100083 [
84 label: 'docker',
85 imageName: 'pyca/cryptography-runner-alpine:latest',
86 toxenvs: ['py36'],
87 ],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070088]
89
90/* Add the linkcheck job to our config list if we're on master */
91if (env.BRANCH_NAME == "master") {
92 configs.add(
93 [
94 label: 'docker',
Paul Kehrer6bdae782017-06-06 08:45:01 -100095 imageName: 'pyca/cryptography-runner-sid',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070096 toxenvs: ['docs-linkcheck'],
97 ]
98 )
99}
100
101def downstreams = [
102 [
103 downstreamName: 'pyOpenSSL',
104 label: 'docker',
105 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
106 script: """#!/bin/bash -xe
Alex Gaynora7e9a222017-06-01 11:02:15 -0400107 git clone --depth=1 https://github.com/pyca/pyopenssl
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700108 cd pyopenssl
109 virtualenv .venv
110 source .venv/bin/activate
111 pip install ../cryptography
Paul Kehrerf564b7e2017-07-07 06:30:50 -0500112 pip install -e .[test]
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700113 pytest tests
114 """
115 ],
116 [
117 downstreamName: 'Twisted',
118 label: 'docker',
119 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
120 script: """#!/bin/bash -xe
Alex Gaynora7e9a222017-06-01 11:02:15 -0400121 git clone --depth=1 https://github.com/twisted/twisted
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700122 cd twisted
123 virtualenv .venv
124 source .venv/bin/activate
125 pip install ../cryptography
126 pip install pyopenssl service_identity pycrypto
127 pip install -e .
128 python -m twisted.trial src/twisted
129 """
130 ],
131 [
132 downstreamName: 'paramiko',
133 label: 'docker',
134 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
135 script: """#!/bin/bash -xe
Alex Gaynora7e9a222017-06-01 11:02:15 -0400136 git clone --depth=1 https://github.com/paramiko/paramiko
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700137 cd paramiko
138 virtualenv .venv
139 source .venv/bin/activate
140 pip install ../cryptography
141 pip install -e .
142 pip install -r dev-requirements.txt
143 inv test
144 """
145 ],
146]
147
148def checkout_git(label) {
Alex Gaynor42b25712017-06-03 12:04:32 -0400149 retry(3) {
150 def script = ""
151 if (env.BRANCH_NAME.startsWith('PR-')) {
152 script = """
153 git clone --depth=1 https://github.com/pyca/cryptography
154 cd cryptography
155 git fetch origin +refs/pull/${env.CHANGE_ID}/merge:
156 git checkout -qf FETCH_HEAD
Paul Kehrera119d2e2017-05-23 22:02:50 -0700157 """
Alex Gaynor42b25712017-06-03 12:04:32 -0400158 if (label.contains("windows")) {
159 bat script
160 } else {
161 sh """#!/bin/sh
162 set -xe
163 ${script}
164 """
165 }
166 } else {
167 checkout([
168 $class: 'GitSCM',
169 branches: [[name: "*/${env.BRANCH_NAME}"]],
170 doGenerateSubmoduleConfigurations: false,
171 extensions: [[
172 $class: 'RelativeTargetDirectory',
173 relativeTargetDir: 'cryptography'
174 ]],
175 submoduleCfg: [],
176 userRemoteConfigs: [[
177 'url': 'https://github.com/pyca/cryptography'
178 ]]
179 ])
Paul Kehrera119d2e2017-05-23 22:02:50 -0700180 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700181 }
182 if (label.contains("windows")) {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700183 bat """
184 cd cryptography
185 git rev-parse HEAD
186 """
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700187 } else {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700188 sh """
189 cd cryptography
190 git rev-parse HEAD
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700191 """
192 }
193}
Alex Gaynor40226372017-05-23 14:14:18 -0700194def build(toxenv, label, imageName, artifacts, artifactExcludes) {
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700195 try {
196 timeout(time: 30, unit: 'MINUTES') {
197
198 checkout_git(label)
199
200 withCredentials([string(credentialsId: 'cryptography-codecov-token', variable: 'CODECOV_TOKEN')]) {
201 withEnv(["LABEL=$label", "TOXENV=$toxenv", "IMAGE_NAME=$imageName"]) {
202 if (label.contains("windows")) {
203 def pythonPath = [
204 py26: "C:\\Python26\\python.exe",
205 py27: "C:\\Python27\\python.exe",
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700206 py34: "C:\\Python34\\python.exe",
207 py35: "C:\\Python35\\python.exe",
208 py36: "C:\\Python36\\python.exe"
209 ]
210 if (toxenv == "py35" || toxenv == "py36") {
211 opensslPaths = [
212 "windows": [
213 "include": "C:\\OpenSSL-Win32-2015\\include",
214 "lib": "C:\\OpenSSL-Win32-2015\\lib"
215 ],
216 "windows64": [
217 "include": "C:\\OpenSSL-Win64-2015\\include",
218 "lib": "C:\\OpenSSL-Win64-2015\\lib"
219 ]
220 ]
221 } else {
222 opensslPaths = [
223 "windows": [
224 "include": "C:\\OpenSSL-Win32-2010\\include",
225 "lib": "C:\\OpenSSL-Win32-2010\\lib"
226 ],
227 "windows64": [
228 "include": "C:\\OpenSSL-Win64-2010\\include",
229 "lib": "C:\\OpenSSL-Win64-2010\\lib"
230 ]
231 ]
232 }
233 bat """
234 cd cryptography
235 @set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH%
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700236 @set PYTHON="${pythonPath[toxenv]}"
237
238 @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE%
239 @set LIB="${opensslPaths[label]['lib']}";%LIB%
240 tox -r
241 IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
242 virtualenv .codecov
243 call .codecov/Scripts/activate
Paul Kehrercb175062017-06-03 08:26:56 -1000244 pip install coverage==4.3.4
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700245 pip install codecov
246 codecov -e JOB_BASE_NAME,LABEL
247 """
248 } else if (label.contains("sierra") || label.contains("yosemite")) {
249 ansiColor {
250 sh """#!/usr/bin/env bash
251 set -xe
252 # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH
253 export PATH="/usr/local/bin:\${PATH}"
254 export PATH="/Users/jenkins/.pyenv/shims:\${PATH}"
255 cd cryptography
Paul Kehreradeaacf2017-05-24 12:49:18 -0700256 CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 \
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700257 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 -0500258 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 -0700259 tox -r -- --color=yes
260 virtualenv .venv
261 source .venv/bin/activate
Paul Kehrercb175062017-06-03 08:26:56 -1000262 pip install coverage==4.3.4
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700263 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL
264 """
265 }
266 } else {
267 ansiColor {
268 sh """#!/usr/bin/env bash
269 set -xe
270 cd cryptography
271 if [[ "\${IMAGE_NAME}" == *"libressl"* ]]; then
272 LD_LIBRARY_PATH="/usr/local/libressl/lib:\$LD_LIBRARY_PATH" \
273 LDFLAGS="-L/usr/local/libressl/lib" \
274 CFLAGS="-I/usr/local/libressl/include" \
275 tox -r -- --color=yes
276 else
277 tox -r -- --color=yes
278 fi
279 virtualenv .venv
280 source .venv/bin/activate
Paul Kehrercb175062017-06-03 08:26:56 -1000281 pip install coverage==4.3.4
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700282 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL
283 """
284 }
Alex Gaynor40226372017-05-23 14:14:18 -0700285 if (artifacts) {
286 archiveArtifacts artifacts: artifacts, excludes: artifactExcludes
287 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700288 }
289 }
290 }
291 }
292 } finally {
293 deleteDir()
294 }
295
296}
297
298def builders = [:]
299for (config in configs) {
300 def label = config["label"]
301 def toxenvs = config["toxenvs"]
Alex Gaynor40226372017-05-23 14:14:18 -0700302 def artifacts = config["artifacts"]
303 def artifactExcludes = config["artifactExcludes"]
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700304
305 for (_toxenv in toxenvs) {
306 def toxenv = _toxenv
307
308 if (label.contains("docker")) {
309 def imageName = config["imageName"]
310 def combinedName = "${imageName}-${toxenv}"
311 builders[combinedName] = {
312 node(label) {
313 stage(combinedName) {
Paul Kehrerc033c902017-07-07 13:20:29 -0500314 def buildImage = docker.image(imageName)
315 buildImage.pull()
316 buildImage.inside {
Alex Gaynor40226372017-05-23 14:14:18 -0700317 build(toxenv, label, imageName, artifacts, artifactExcludes)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700318 }
319 }
320 }
321 }
322 } else {
323 def combinedName = "${label}-${toxenv}"
324 builders[combinedName] = {
325 node(label) {
326 stage(combinedName) {
Alex Gaynor40226372017-05-23 14:14:18 -0700327 build(toxenv, label, '', null, null)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700328 }
329 }
330 }
331 }
332 }
333}
334
335/* Add the python setup.py test builder */
336builders["setup.py-test"] = {
337 node("docker") {
338 stage("python setup.py test") {
339 docker.image("pyca/cryptography-runner-ubuntu-rolling").inside {
340 try {
341 checkout_git("docker")
342 sh """#!/usr/bin/env bash
343 set -xe
344 cd cryptography
345 virtualenv .venv
346 source .venv/bin/activate
347 python setup.py test
348 """
349 } finally {
350 deleteDir()
351 }
352
353 }
354 }
355 }
356}
357
358parallel builders
359
360def downstreamBuilders = [:]
361for (downstream in downstreams) {
362 def downstreamName = downstream["downstreamName"]
363 def imageName = downstream["imageName"]
364 def label = downstream["label"]
365 def script = downstream["script"]
366 downstreamBuilders[downstreamName] = {
367 node(label) {
368 docker.image(imageName).inside {
369 try {
370 timeout(time: 30, unit: 'MINUTES') {
371 checkout_git(label)
372 sh script
373 }
374 } finally {
375 deleteDir()
376 }
377 }
378 }
379 }
380}
381
382stage("Downstreams") {
383 parallel downstreamBuilders
384}