blob: 36cc00914a8dc33346a567e7489c19e9fed7778f [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',
Paul Kehrerd36bef02017-05-25 23:05:00 -050058 imageName: 'pyca/cryptography-runner-jessie-libressl:2.5.4',
59 toxenvs: ['py27'],
60 ],
61 [
62 label: 'docker',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070063 imageName: 'pyca/cryptography-runner-ubuntu-xenial',
64 toxenvs: ['py27', 'py35'],
65 ],
66 [
67 label: 'docker',
68 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
Alex Gaynor40226372017-05-23 14:14:18 -070069 toxenvs: ['py27', 'py35', 'pep8', 'py3pep8', 'randomorder'],
70 ],
71 [
72 label: 'docker',
73 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
74 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 ],
83]
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',
90 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
91 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 .
108 pip install pytest
109 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",
202 py33: "C:\\Python33\\python.exe",
203 py34: "C:\\Python34\\python.exe",
204 py35: "C:\\Python35\\python.exe",
205 py36: "C:\\Python36\\python.exe"
206 ]
207 if (toxenv == "py35" || toxenv == "py36") {
208 opensslPaths = [
209 "windows": [
210 "include": "C:\\OpenSSL-Win32-2015\\include",
211 "lib": "C:\\OpenSSL-Win32-2015\\lib"
212 ],
213 "windows64": [
214 "include": "C:\\OpenSSL-Win64-2015\\include",
215 "lib": "C:\\OpenSSL-Win64-2015\\lib"
216 ]
217 ]
218 } else {
219 opensslPaths = [
220 "windows": [
221 "include": "C:\\OpenSSL-Win32-2010\\include",
222 "lib": "C:\\OpenSSL-Win32-2010\\lib"
223 ],
224 "windows64": [
225 "include": "C:\\OpenSSL-Win64-2010\\include",
226 "lib": "C:\\OpenSSL-Win64-2010\\lib"
227 ]
228 ]
229 }
230 bat """
231 cd cryptography
232 @set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH%
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700233 @set PYTHON="${pythonPath[toxenv]}"
234
235 @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE%
236 @set LIB="${opensslPaths[label]['lib']}";%LIB%
237 tox -r
238 IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
239 virtualenv .codecov
240 call .codecov/Scripts/activate
Paul Kehrercb175062017-06-03 08:26:56 -1000241 pip install coverage==4.3.4
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700242 pip install codecov
243 codecov -e JOB_BASE_NAME,LABEL
244 """
245 } else if (label.contains("sierra") || label.contains("yosemite")) {
246 ansiColor {
247 sh """#!/usr/bin/env bash
248 set -xe
249 # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH
250 export PATH="/usr/local/bin:\${PATH}"
251 export PATH="/Users/jenkins/.pyenv/shims:\${PATH}"
252 cd cryptography
Paul Kehreradeaacf2017-05-24 12:49:18 -0700253 CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 \
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700254 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 -0500255 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 -0700256 tox -r -- --color=yes
257 virtualenv .venv
258 source .venv/bin/activate
Paul Kehrercb175062017-06-03 08:26:56 -1000259 pip install coverage==4.3.4
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700260 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL
261 """
262 }
263 } else {
264 ansiColor {
265 sh """#!/usr/bin/env bash
266 set -xe
267 cd cryptography
268 if [[ "\${IMAGE_NAME}" == *"libressl"* ]]; then
269 LD_LIBRARY_PATH="/usr/local/libressl/lib:\$LD_LIBRARY_PATH" \
270 LDFLAGS="-L/usr/local/libressl/lib" \
271 CFLAGS="-I/usr/local/libressl/include" \
272 tox -r -- --color=yes
273 else
274 tox -r -- --color=yes
275 fi
276 virtualenv .venv
277 source .venv/bin/activate
Paul Kehrercb175062017-06-03 08:26:56 -1000278 pip install coverage==4.3.4
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700279 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL
280 """
281 }
Alex Gaynor40226372017-05-23 14:14:18 -0700282 if (artifacts) {
283 archiveArtifacts artifacts: artifacts, excludes: artifactExcludes
284 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700285 }
286 }
287 }
288 }
289 } finally {
290 deleteDir()
291 }
292
293}
294
295def builders = [:]
296for (config in configs) {
297 def label = config["label"]
298 def toxenvs = config["toxenvs"]
Alex Gaynor40226372017-05-23 14:14:18 -0700299 def artifacts = config["artifacts"]
300 def artifactExcludes = config["artifactExcludes"]
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700301
302 for (_toxenv in toxenvs) {
303 def toxenv = _toxenv
304
305 if (label.contains("docker")) {
306 def imageName = config["imageName"]
307 def combinedName = "${imageName}-${toxenv}"
308 builders[combinedName] = {
309 node(label) {
310 stage(combinedName) {
311 docker.image(imageName).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}