blob: 60195a68fd2c0c194ed301a6d2bdac70f8ce68c4 [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 Kehrer4cf6e782017-10-12 06:06:01 +08008 toxenvs: ['py27', 'py34', 'py35', 'py36'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -07009 ],
10 [
11 label: 'windows64',
Paul Kehrer4cf6e782017-10-12 06:06:01 +080012 toxenvs: ['py27', 'py34', 'py35', 'py36'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070013 ],
14 [
15 label: 'freebsd11',
16 toxenvs: ['py27'],
17 ],
18 [
19 label: 'sierra',
Paul Kehrer90375552017-09-20 20:49:03 +080020 toxenvs: ['py27', 'py36'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070021 ],
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',
Alex Gaynora87daea2017-10-11 21:36:30 -040054 toxenvs: ['py27', 'py36'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070055 ],
56 [
57 label: 'docker',
58 imageName: 'pyca/cryptography-runner-jessie-libressl:2.4.5',
59 toxenvs: ['py27'],
60 ],
61 [
62 label: 'docker',
Alex Gaynorb5223242017-09-15 02:37:39 -040063 imageName: 'pyca/cryptography-runner-jessie-libressl:2.6.1',
Alex Gaynor45f2a422017-07-26 09:10:32 -040064 toxenvs: ['py27'],
65 ],
66 [
67 label: 'docker',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070068 imageName: 'pyca/cryptography-runner-ubuntu-xenial',
69 toxenvs: ['py27', 'py35'],
70 ],
71 [
72 label: 'docker',
73 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
Paul Kehrer9c635242017-07-08 12:02:15 -050074 toxenvs: ['py27', 'py35', 'randomorder'],
Alex Gaynor40226372017-05-23 14:14:18 -070075 ],
76 [
77 label: 'docker',
Paul Kehrer6bdae782017-06-06 08:45:01 -100078 imageName: 'pyca/cryptography-runner-sid',
Alex Gaynor40226372017-05-23 14:14:18 -070079 toxenvs: ['docs'],
80 artifacts: 'cryptography/docs/_build/html/**',
81 artifactExcludes: '**/*.doctree',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070082 ],
83 [
84 label: 'docker',
85 imageName: 'pyca/cryptography-runner-fedora',
Alex Gaynor2e64a3f2017-07-13 08:30:24 -040086 toxenvs: ['py27', 'py36'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070087 ],
Paul Kehrer8c0e7312017-06-25 12:22:07 -100088 [
89 label: 'docker',
90 imageName: 'pyca/cryptography-runner-alpine:latest',
91 toxenvs: ['py36'],
92 ],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070093]
94
95/* Add the linkcheck job to our config list if we're on master */
96if (env.BRANCH_NAME == "master") {
97 configs.add(
98 [
99 label: 'docker',
Paul Kehrer6bdae782017-06-06 08:45:01 -1000100 imageName: 'pyca/cryptography-runner-sid',
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700101 toxenvs: ['docs-linkcheck'],
102 ]
103 )
104}
105
106def downstreams = [
107 [
108 downstreamName: 'pyOpenSSL',
109 label: 'docker',
110 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
111 script: """#!/bin/bash -xe
Alex Gaynora7e9a222017-06-01 11:02:15 -0400112 git clone --depth=1 https://github.com/pyca/pyopenssl
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700113 cd pyopenssl
114 virtualenv .venv
115 source .venv/bin/activate
116 pip install ../cryptography
Paul Kehrerf564b7e2017-07-07 06:30:50 -0500117 pip install -e .[test]
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700118 pytest tests
119 """
120 ],
121 [
122 downstreamName: 'Twisted',
123 label: 'docker',
124 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
125 script: """#!/bin/bash -xe
Alex Gaynora7e9a222017-06-01 11:02:15 -0400126 git clone --depth=1 https://github.com/twisted/twisted
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700127 cd twisted
128 virtualenv .venv
129 source .venv/bin/activate
130 pip install ../cryptography
131 pip install pyopenssl service_identity pycrypto
132 pip install -e .
133 python -m twisted.trial src/twisted
134 """
135 ],
136 [
137 downstreamName: 'paramiko',
138 label: 'docker',
139 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
140 script: """#!/bin/bash -xe
Alex Gaynora7e9a222017-06-01 11:02:15 -0400141 git clone --depth=1 https://github.com/paramiko/paramiko
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700142 cd paramiko
143 virtualenv .venv
144 source .venv/bin/activate
145 pip install ../cryptography
146 pip install -e .
147 pip install -r dev-requirements.txt
148 inv test
149 """
150 ],
151]
152
153def checkout_git(label) {
Alex Gaynor42b25712017-06-03 12:04:32 -0400154 retry(3) {
155 def script = ""
156 if (env.BRANCH_NAME.startsWith('PR-')) {
157 script = """
158 git clone --depth=1 https://github.com/pyca/cryptography
159 cd cryptography
160 git fetch origin +refs/pull/${env.CHANGE_ID}/merge:
161 git checkout -qf FETCH_HEAD
Paul Kehrera119d2e2017-05-23 22:02:50 -0700162 """
Alex Gaynor42b25712017-06-03 12:04:32 -0400163 if (label.contains("windows")) {
164 bat script
165 } else {
166 sh """#!/bin/sh
167 set -xe
168 ${script}
169 """
170 }
171 } else {
172 checkout([
173 $class: 'GitSCM',
174 branches: [[name: "*/${env.BRANCH_NAME}"]],
175 doGenerateSubmoduleConfigurations: false,
176 extensions: [[
177 $class: 'RelativeTargetDirectory',
178 relativeTargetDir: 'cryptography'
179 ]],
180 submoduleCfg: [],
181 userRemoteConfigs: [[
182 'url': 'https://github.com/pyca/cryptography'
183 ]]
184 ])
Paul Kehrera119d2e2017-05-23 22:02:50 -0700185 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700186 }
187 if (label.contains("windows")) {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700188 bat """
189 cd cryptography
190 git rev-parse HEAD
191 """
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700192 } else {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700193 sh """
194 cd cryptography
195 git rev-parse HEAD
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700196 """
197 }
198}
Alex Gaynor40226372017-05-23 14:14:18 -0700199def build(toxenv, label, imageName, artifacts, artifactExcludes) {
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700200 try {
201 timeout(time: 30, unit: 'MINUTES') {
202
203 checkout_git(label)
204
205 withCredentials([string(credentialsId: 'cryptography-codecov-token', variable: 'CODECOV_TOKEN')]) {
206 withEnv(["LABEL=$label", "TOXENV=$toxenv", "IMAGE_NAME=$imageName"]) {
207 if (label.contains("windows")) {
208 def pythonPath = [
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700209 py27: "C:\\Python27\\python.exe",
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700210 py34: "C:\\Python34\\python.exe",
211 py35: "C:\\Python35\\python.exe",
212 py36: "C:\\Python36\\python.exe"
213 ]
214 if (toxenv == "py35" || toxenv == "py36") {
215 opensslPaths = [
216 "windows": [
217 "include": "C:\\OpenSSL-Win32-2015\\include",
218 "lib": "C:\\OpenSSL-Win32-2015\\lib"
219 ],
220 "windows64": [
221 "include": "C:\\OpenSSL-Win64-2015\\include",
222 "lib": "C:\\OpenSSL-Win64-2015\\lib"
223 ]
224 ]
225 } else {
226 opensslPaths = [
227 "windows": [
228 "include": "C:\\OpenSSL-Win32-2010\\include",
229 "lib": "C:\\OpenSSL-Win32-2010\\lib"
230 ],
231 "windows64": [
232 "include": "C:\\OpenSSL-Win64-2010\\include",
233 "lib": "C:\\OpenSSL-Win64-2010\\lib"
234 ]
235 ]
236 }
237 bat """
238 cd cryptography
239 @set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH%
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700240 @set PYTHON="${pythonPath[toxenv]}"
241
242 @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE%
243 @set LIB="${opensslPaths[label]['lib']}";%LIB%
244 tox -r
245 IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
246 virtualenv .codecov
247 call .codecov/Scripts/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800248 REM this pin must be kept in sync with tox.ini
Paul Kehrercb175062017-06-03 08:26:56 -1000249 pip install coverage==4.3.4
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700250 pip install codecov
Paul Kehrer8396d432017-09-06 23:23:15 +0800251 codecov -e JOB_BASE_NAME,LABEL,TOXENV
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700252 """
253 } else if (label.contains("sierra") || label.contains("yosemite")) {
254 ansiColor {
255 sh """#!/usr/bin/env bash
256 set -xe
257 # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH
258 export PATH="/usr/local/bin:\${PATH}"
259 export PATH="/Users/jenkins/.pyenv/shims:\${PATH}"
260 cd cryptography
Paul Kehreradeaacf2017-05-24 12:49:18 -0700261 CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 \
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700262 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 -0500263 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 -0700264 tox -r -- --color=yes
265 virtualenv .venv
266 source .venv/bin/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800267 # This pin must be kept in sync with tox.ini
Paul Kehrercb175062017-06-03 08:26:56 -1000268 pip install coverage==4.3.4
Paul Kehrer8396d432017-09-06 23:23:15 +0800269 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700270 """
271 }
272 } else {
273 ansiColor {
274 sh """#!/usr/bin/env bash
275 set -xe
276 cd cryptography
277 if [[ "\${IMAGE_NAME}" == *"libressl"* ]]; then
278 LD_LIBRARY_PATH="/usr/local/libressl/lib:\$LD_LIBRARY_PATH" \
279 LDFLAGS="-L/usr/local/libressl/lib" \
280 CFLAGS="-I/usr/local/libressl/include" \
281 tox -r -- --color=yes
282 else
283 tox -r -- --color=yes
284 fi
285 virtualenv .venv
286 source .venv/bin/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800287 # This pin must be kept in sync with tox.ini
Paul Kehrercb175062017-06-03 08:26:56 -1000288 pip install coverage==4.3.4
Paul Kehrer8396d432017-09-06 23:23:15 +0800289 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV,IMAGE_NAME
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700290 """
291 }
Alex Gaynor40226372017-05-23 14:14:18 -0700292 if (artifacts) {
293 archiveArtifacts artifacts: artifacts, excludes: artifactExcludes
294 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700295 }
296 }
297 }
298 }
299 } finally {
300 deleteDir()
301 }
302
303}
304
305def builders = [:]
306for (config in configs) {
307 def label = config["label"]
308 def toxenvs = config["toxenvs"]
Alex Gaynor40226372017-05-23 14:14:18 -0700309 def artifacts = config["artifacts"]
310 def artifactExcludes = config["artifactExcludes"]
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700311
312 for (_toxenv in toxenvs) {
313 def toxenv = _toxenv
314
315 if (label.contains("docker")) {
316 def imageName = config["imageName"]
317 def combinedName = "${imageName}-${toxenv}"
318 builders[combinedName] = {
319 node(label) {
320 stage(combinedName) {
Paul Kehrerc033c902017-07-07 13:20:29 -0500321 def buildImage = docker.image(imageName)
322 buildImage.pull()
323 buildImage.inside {
Alex Gaynor40226372017-05-23 14:14:18 -0700324 build(toxenv, label, imageName, artifacts, artifactExcludes)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700325 }
326 }
327 }
328 }
329 } else {
330 def combinedName = "${label}-${toxenv}"
331 builders[combinedName] = {
332 node(label) {
333 stage(combinedName) {
Alex Gaynor40226372017-05-23 14:14:18 -0700334 build(toxenv, label, '', null, null)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700335 }
336 }
337 }
338 }
339 }
340}
341
342/* Add the python setup.py test builder */
343builders["setup.py-test"] = {
344 node("docker") {
345 stage("python setup.py test") {
346 docker.image("pyca/cryptography-runner-ubuntu-rolling").inside {
347 try {
348 checkout_git("docker")
349 sh """#!/usr/bin/env bash
350 set -xe
351 cd cryptography
352 virtualenv .venv
353 source .venv/bin/activate
354 python setup.py test
355 """
356 } finally {
357 deleteDir()
358 }
359
360 }
361 }
362 }
363}
364
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700365for (downstream in downstreams) {
366 def downstreamName = downstream["downstreamName"]
367 def imageName = downstream["imageName"]
368 def label = downstream["label"]
369 def script = downstream["script"]
Paul Kehrer3d96afd2017-10-04 10:53:18 +0800370 builders[downstreamName] = {
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700371 node(label) {
372 docker.image(imageName).inside {
373 try {
374 timeout(time: 30, unit: 'MINUTES') {
375 checkout_git(label)
376 sh script
377 }
378 } finally {
379 deleteDir()
380 }
381 }
382 }
383 }
384}
385
Paul Kehrer3d96afd2017-10-04 10:53:18 +0800386parallel builders
387