blob: 6cdf1623e0b833ef28ade3e0825a36263958c6c1 [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',
8 toxenvs: ['py26', 'py27', 'py33', 'py34', 'py35', 'py36'],
9 ],
10 [
11 label: 'windows64',
12 toxenvs: ['py26', 'py27', 'py33', 'py34', 'py35', 'py36'],
13 ],
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',
68 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
69 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 ],
78]
79
80/* Add the linkcheck job to our config list if we're on master */
81if (env.BRANCH_NAME == "master") {
82 configs.add(
83 [
84 label: 'docker',
85 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
86 toxenvs: ['docs-linkcheck'],
87 ]
88 )
89}
90
91def downstreams = [
92 [
93 downstreamName: 'pyOpenSSL',
94 label: 'docker',
95 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
96 script: """#!/bin/bash -xe
97 git clone --depth=1 https://github.com/pyca/pyopenssl.git pyopenssl
98 cd pyopenssl
99 virtualenv .venv
100 source .venv/bin/activate
101 pip install ../cryptography
102 pip install -e .
103 pip install pytest
104 pytest tests
105 """
106 ],
107 [
108 downstreamName: 'Twisted',
109 label: 'docker',
110 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
111 script: """#!/bin/bash -xe
112 git clone --depth=1 https://github.com/twisted/twisted.git twisted
113 cd twisted
114 virtualenv .venv
115 source .venv/bin/activate
116 pip install ../cryptography
117 pip install pyopenssl service_identity pycrypto
118 pip install -e .
119 python -m twisted.trial src/twisted
120 """
121 ],
122 [
123 downstreamName: 'paramiko',
124 label: 'docker',
125 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
126 script: """#!/bin/bash -xe
127 git clone --depth=1 https://github.com/paramiko/paramiko.git paramiko
128 cd paramiko
129 virtualenv .venv
130 source .venv/bin/activate
131 pip install ../cryptography
132 pip install -e .
133 pip install -r dev-requirements.txt
134 inv test
135 """
136 ],
137]
138
139def checkout_git(label) {
140 def script = ""
141 if (env.BRANCH_NAME.startsWith('PR-')) {
142 script = """
143 git clone --depth=1 https://github.com/pyca/cryptography.git cryptography
144 cd cryptography
145 git fetch origin +refs/pull/${env.CHANGE_ID}/merge:
146 git checkout -qf FETCH_HEAD
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700147 """
Paul Kehrera119d2e2017-05-23 22:02:50 -0700148 if (label.contains("windows")) {
149 bat script
150 } else {
151 sh """#!/bin/sh
152 set -xe
153 ${script}
154 """
155 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700156 } else {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700157 checkout([
158 $class: 'GitSCM',
159 branches: [[name: "*/${env.BRANCH_NAME}"]],
160 doGenerateSubmoduleConfigurations: false,
161 extensions: [[
162 $class: 'RelativeTargetDirectory',
163 relativeTargetDir: 'cryptography'
164 ]],
165 submoduleCfg: [],
166 userRemoteConfigs: [[
167 'url': 'https://github.com/pyca/cryptography'
168 ]]
169 ])
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700170 }
171 if (label.contains("windows")) {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700172 bat """
173 cd cryptography
174 git rev-parse HEAD
175 """
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700176 } else {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700177 sh """
178 cd cryptography
179 git rev-parse HEAD
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700180 """
181 }
182}
Alex Gaynor40226372017-05-23 14:14:18 -0700183def build(toxenv, label, imageName, artifacts, artifactExcludes) {
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700184 try {
185 timeout(time: 30, unit: 'MINUTES') {
186
187 checkout_git(label)
188
189 withCredentials([string(credentialsId: 'cryptography-codecov-token', variable: 'CODECOV_TOKEN')]) {
190 withEnv(["LABEL=$label", "TOXENV=$toxenv", "IMAGE_NAME=$imageName"]) {
191 if (label.contains("windows")) {
192 def pythonPath = [
193 py26: "C:\\Python26\\python.exe",
194 py27: "C:\\Python27\\python.exe",
195 py33: "C:\\Python33\\python.exe",
196 py34: "C:\\Python34\\python.exe",
197 py35: "C:\\Python35\\python.exe",
198 py36: "C:\\Python36\\python.exe"
199 ]
200 if (toxenv == "py35" || toxenv == "py36") {
201 opensslPaths = [
202 "windows": [
203 "include": "C:\\OpenSSL-Win32-2015\\include",
204 "lib": "C:\\OpenSSL-Win32-2015\\lib"
205 ],
206 "windows64": [
207 "include": "C:\\OpenSSL-Win64-2015\\include",
208 "lib": "C:\\OpenSSL-Win64-2015\\lib"
209 ]
210 ]
211 } else {
212 opensslPaths = [
213 "windows": [
214 "include": "C:\\OpenSSL-Win32-2010\\include",
215 "lib": "C:\\OpenSSL-Win32-2010\\lib"
216 ],
217 "windows64": [
218 "include": "C:\\OpenSSL-Win64-2010\\include",
219 "lib": "C:\\OpenSSL-Win64-2010\\lib"
220 ]
221 ]
222 }
223 bat """
224 cd cryptography
225 @set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH%
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700226 @set PYTHON="${pythonPath[toxenv]}"
227
228 @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE%
229 @set LIB="${opensslPaths[label]['lib']}";%LIB%
230 tox -r
231 IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
232 virtualenv .codecov
233 call .codecov/Scripts/activate
234 pip install codecov
235 codecov -e JOB_BASE_NAME,LABEL
236 """
237 } else if (label.contains("sierra") || label.contains("yosemite")) {
238 ansiColor {
239 sh """#!/usr/bin/env bash
240 set -xe
241 # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH
242 export PATH="/usr/local/bin:\${PATH}"
243 export PATH="/Users/jenkins/.pyenv/shims:\${PATH}"
244 cd cryptography
Paul Kehreradeaacf2017-05-24 12:49:18 -0700245 CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 \
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700246 LDFLAGS="/usr/local/opt/openssl\\@1.1/lib/libcrypto.a /usr/local/opt/openssl\\@1.1/lib/libssl.a" \
247 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" \
248 tox -r -- --color=yes
249 virtualenv .venv
250 source .venv/bin/activate
251 pip install coverage
252 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL
253 """
254 }
255 } else {
256 ansiColor {
257 sh """#!/usr/bin/env bash
258 set -xe
259 cd cryptography
260 if [[ "\${IMAGE_NAME}" == *"libressl"* ]]; then
261 LD_LIBRARY_PATH="/usr/local/libressl/lib:\$LD_LIBRARY_PATH" \
262 LDFLAGS="-L/usr/local/libressl/lib" \
263 CFLAGS="-I/usr/local/libressl/include" \
264 tox -r -- --color=yes
265 else
266 tox -r -- --color=yes
267 fi
268 virtualenv .venv
269 source .venv/bin/activate
270 pip install coverage
271 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL
272 """
273 }
Alex Gaynor40226372017-05-23 14:14:18 -0700274 if (artifacts) {
275 archiveArtifacts artifacts: artifacts, excludes: artifactExcludes
276 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700277 }
278 }
279 }
280 }
281 } finally {
282 deleteDir()
283 }
284
285}
286
287def builders = [:]
288for (config in configs) {
289 def label = config["label"]
290 def toxenvs = config["toxenvs"]
Alex Gaynor40226372017-05-23 14:14:18 -0700291 def artifacts = config["artifacts"]
292 def artifactExcludes = config["artifactExcludes"]
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700293
294 for (_toxenv in toxenvs) {
295 def toxenv = _toxenv
296
297 if (label.contains("docker")) {
298 def imageName = config["imageName"]
299 def combinedName = "${imageName}-${toxenv}"
300 builders[combinedName] = {
301 node(label) {
302 stage(combinedName) {
303 docker.image(imageName).inside {
Alex Gaynor40226372017-05-23 14:14:18 -0700304 build(toxenv, label, imageName, artifacts, artifactExcludes)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700305 }
306 }
307 }
308 }
309 } else {
310 def combinedName = "${label}-${toxenv}"
311 builders[combinedName] = {
312 node(label) {
313 stage(combinedName) {
Alex Gaynor40226372017-05-23 14:14:18 -0700314 build(toxenv, label, '', null, null)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700315 }
316 }
317 }
318 }
319 }
320}
321
322/* Add the python setup.py test builder */
323builders["setup.py-test"] = {
324 node("docker") {
325 stage("python setup.py test") {
326 docker.image("pyca/cryptography-runner-ubuntu-rolling").inside {
327 try {
328 checkout_git("docker")
329 sh """#!/usr/bin/env bash
330 set -xe
331 cd cryptography
332 virtualenv .venv
333 source .venv/bin/activate
334 python setup.py test
335 """
336 } finally {
337 deleteDir()
338 }
339
340 }
341 }
342 }
343}
344
345parallel builders
346
347def downstreamBuilders = [:]
348for (downstream in downstreams) {
349 def downstreamName = downstream["downstreamName"]
350 def imageName = downstream["imageName"]
351 def label = downstream["label"]
352 def script = downstream["script"]
353 downstreamBuilders[downstreamName] = {
354 node(label) {
355 docker.image(imageName).inside {
356 try {
357 timeout(time: 30, unit: 'MINUTES') {
358 checkout_git(label)
359 sh script
360 }
361 } finally {
362 deleteDir()
363 }
364 }
365 }
366 }
367}
368
369stage("Downstreams") {
370 parallel downstreamBuilders
371}