blob: adaf9f03f10b05c8ac2aca3034730d77e0f29706 [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%
226 @set CRYPTOGRAPHY_WINDOWS_LINK_OPENSSL110=1
227 @set PYTHON="${pythonPath[toxenv]}"
228
229 @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE%
230 @set LIB="${opensslPaths[label]['lib']}";%LIB%
231 tox -r
232 IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
233 virtualenv .codecov
234 call .codecov/Scripts/activate
235 pip install codecov
236 codecov -e JOB_BASE_NAME,LABEL
237 """
238 } else if (label.contains("sierra") || label.contains("yosemite")) {
239 ansiColor {
240 sh """#!/usr/bin/env bash
241 set -xe
242 # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH
243 export PATH="/usr/local/bin:\${PATH}"
244 export PATH="/Users/jenkins/.pyenv/shims:\${PATH}"
245 cd cryptography
246 CRYPTOGRAPHY_OSX_NO_LINK_FLAGS=1 \
247 LDFLAGS="/usr/local/opt/openssl\\@1.1/lib/libcrypto.a /usr/local/opt/openssl\\@1.1/lib/libssl.a" \
248 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" \
249 tox -r -- --color=yes
250 virtualenv .venv
251 source .venv/bin/activate
252 pip install coverage
253 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL
254 """
255 }
256 } else {
257 ansiColor {
258 sh """#!/usr/bin/env bash
259 set -xe
260 cd cryptography
261 if [[ "\${IMAGE_NAME}" == *"libressl"* ]]; then
262 LD_LIBRARY_PATH="/usr/local/libressl/lib:\$LD_LIBRARY_PATH" \
263 LDFLAGS="-L/usr/local/libressl/lib" \
264 CFLAGS="-I/usr/local/libressl/include" \
265 tox -r -- --color=yes
266 else
267 tox -r -- --color=yes
268 fi
269 virtualenv .venv
270 source .venv/bin/activate
271 pip install coverage
272 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL
273 """
274 }
Alex Gaynor40226372017-05-23 14:14:18 -0700275 if (artifacts) {
276 archiveArtifacts artifacts: artifacts, excludes: artifactExcludes
277 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700278 }
279 }
280 }
281 }
282 } finally {
283 deleteDir()
284 }
285
286}
287
288def builders = [:]
289for (config in configs) {
290 def label = config["label"]
291 def toxenvs = config["toxenvs"]
Alex Gaynor40226372017-05-23 14:14:18 -0700292 def artifacts = config["artifacts"]
293 def artifactExcludes = config["artifactExcludes"]
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700294
295 for (_toxenv in toxenvs) {
296 def toxenv = _toxenv
297
298 if (label.contains("docker")) {
299 def imageName = config["imageName"]
300 def combinedName = "${imageName}-${toxenv}"
301 builders[combinedName] = {
302 node(label) {
303 stage(combinedName) {
304 docker.image(imageName).inside {
Alex Gaynor40226372017-05-23 14:14:18 -0700305 build(toxenv, label, imageName, artifacts, artifactExcludes)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700306 }
307 }
308 }
309 }
310 } else {
311 def combinedName = "${label}-${toxenv}"
312 builders[combinedName] = {
313 node(label) {
314 stage(combinedName) {
Alex Gaynor40226372017-05-23 14:14:18 -0700315 build(toxenv, label, '', null, null)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700316 }
317 }
318 }
319 }
320 }
321}
322
323/* Add the python setup.py test builder */
324builders["setup.py-test"] = {
325 node("docker") {
326 stage("python setup.py test") {
327 docker.image("pyca/cryptography-runner-ubuntu-rolling").inside {
328 try {
329 checkout_git("docker")
330 sh """#!/usr/bin/env bash
331 set -xe
332 cd cryptography
333 virtualenv .venv
334 source .venv/bin/activate
335 python setup.py test
336 """
337 } finally {
338 deleteDir()
339 }
340
341 }
342 }
343 }
344}
345
346parallel builders
347
348def downstreamBuilders = [:]
349for (downstream in downstreams) {
350 def downstreamName = downstream["downstreamName"]
351 def imageName = downstream["imageName"]
352 def label = downstream["label"]
353 def script = downstream["script"]
354 downstreamBuilders[downstreamName] = {
355 node(label) {
356 docker.image(imageName).inside {
357 try {
358 timeout(time: 30, unit: 'MINUTES') {
359 checkout_git(label)
360 sh script
361 }
362 } finally {
363 deleteDir()
364 }
365 }
366 }
367 }
368}
369
370stage("Downstreams") {
371 parallel downstreamBuilders
372}