blob: 3710b4c106dd8144a8f98693571a6951d7e0f8b8 [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',
64 toxenvs: ['py27', 'py35', 'docs', 'pep8', 'py3pep8', 'randomorder'],
65 ],
66 [
67 label: 'docker',
68 imageName: 'pyca/cryptography-runner-fedora',
69 toxenvs: ['py27', 'py35'],
70 ],
71]
72
73/* Add the linkcheck job to our config list if we're on master */
74if (env.BRANCH_NAME == "master") {
75 configs.add(
76 [
77 label: 'docker',
78 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
79 toxenvs: ['docs-linkcheck'],
80 ]
81 )
82}
83
84def downstreams = [
85 [
86 downstreamName: 'pyOpenSSL',
87 label: 'docker',
88 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
89 script: """#!/bin/bash -xe
90 git clone --depth=1 https://github.com/pyca/pyopenssl.git pyopenssl
91 cd pyopenssl
92 virtualenv .venv
93 source .venv/bin/activate
94 pip install ../cryptography
95 pip install -e .
96 pip install pytest
97 pytest tests
98 """
99 ],
100 [
101 downstreamName: 'Twisted',
102 label: 'docker',
103 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
104 script: """#!/bin/bash -xe
105 git clone --depth=1 https://github.com/twisted/twisted.git twisted
106 cd twisted
107 virtualenv .venv
108 source .venv/bin/activate
109 pip install ../cryptography
110 pip install pyopenssl service_identity pycrypto
111 pip install -e .
112 python -m twisted.trial src/twisted
113 """
114 ],
115 [
116 downstreamName: 'paramiko',
117 label: 'docker',
118 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
119 script: """#!/bin/bash -xe
120 git clone --depth=1 https://github.com/paramiko/paramiko.git paramiko
121 cd paramiko
122 virtualenv .venv
123 source .venv/bin/activate
124 pip install ../cryptography
125 pip install -e .
126 pip install -r dev-requirements.txt
127 inv test
128 """
129 ],
130]
131
132def checkout_git(label) {
133 def script = ""
134 if (env.BRANCH_NAME.startsWith('PR-')) {
135 script = """
136 git clone --depth=1 https://github.com/pyca/cryptography.git cryptography
137 cd cryptography
138 git fetch origin +refs/pull/${env.CHANGE_ID}/merge:
139 git checkout -qf FETCH_HEAD
140 git rev-parse HEAD
141 """
142 } else {
143 script = """
144 git clone --depth=1 https://github.com/pyca/cryptography.git cryptography
145 cd cryptography
146 git checkout ${env.BRANCH_NAME}
147 git rev-parse HEAD
148 """
149 }
150 if (label.contains("windows")) {
151 bat script
152 } else {
153 sh """#!/bin/sh
154 set -xe
155 ${script}
156 """
157 }
158}
159def build(toxenv, label, imageName) {
160 try {
161 timeout(time: 30, unit: 'MINUTES') {
162
163 checkout_git(label)
164
165 withCredentials([string(credentialsId: 'cryptography-codecov-token', variable: 'CODECOV_TOKEN')]) {
166 withEnv(["LABEL=$label", "TOXENV=$toxenv", "IMAGE_NAME=$imageName"]) {
167 if (label.contains("windows")) {
168 def pythonPath = [
169 py26: "C:\\Python26\\python.exe",
170 py27: "C:\\Python27\\python.exe",
171 py33: "C:\\Python33\\python.exe",
172 py34: "C:\\Python34\\python.exe",
173 py35: "C:\\Python35\\python.exe",
174 py36: "C:\\Python36\\python.exe"
175 ]
176 if (toxenv == "py35" || toxenv == "py36") {
177 opensslPaths = [
178 "windows": [
179 "include": "C:\\OpenSSL-Win32-2015\\include",
180 "lib": "C:\\OpenSSL-Win32-2015\\lib"
181 ],
182 "windows64": [
183 "include": "C:\\OpenSSL-Win64-2015\\include",
184 "lib": "C:\\OpenSSL-Win64-2015\\lib"
185 ]
186 ]
187 } else {
188 opensslPaths = [
189 "windows": [
190 "include": "C:\\OpenSSL-Win32-2010\\include",
191 "lib": "C:\\OpenSSL-Win32-2010\\lib"
192 ],
193 "windows64": [
194 "include": "C:\\OpenSSL-Win64-2010\\include",
195 "lib": "C:\\OpenSSL-Win64-2010\\lib"
196 ]
197 ]
198 }
199 bat """
200 cd cryptography
201 @set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH%
202 @set CRYPTOGRAPHY_WINDOWS_LINK_OPENSSL110=1
203 @set PYTHON="${pythonPath[toxenv]}"
204
205 @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE%
206 @set LIB="${opensslPaths[label]['lib']}";%LIB%
207 tox -r
208 IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
209 virtualenv .codecov
210 call .codecov/Scripts/activate
211 pip install codecov
212 codecov -e JOB_BASE_NAME,LABEL
213 """
214 } else if (label.contains("sierra") || label.contains("yosemite")) {
215 ansiColor {
216 sh """#!/usr/bin/env bash
217 set -xe
218 # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH
219 export PATH="/usr/local/bin:\${PATH}"
220 export PATH="/Users/jenkins/.pyenv/shims:\${PATH}"
221 cd cryptography
222 CRYPTOGRAPHY_OSX_NO_LINK_FLAGS=1 \
223 LDFLAGS="/usr/local/opt/openssl\\@1.1/lib/libcrypto.a /usr/local/opt/openssl\\@1.1/lib/libssl.a" \
224 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" \
225 tox -r -- --color=yes
226 virtualenv .venv
227 source .venv/bin/activate
228 pip install coverage
229 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL
230 """
231 }
232 } else {
233 ansiColor {
234 sh """#!/usr/bin/env bash
235 set -xe
236 cd cryptography
237 if [[ "\${IMAGE_NAME}" == *"libressl"* ]]; then
238 LD_LIBRARY_PATH="/usr/local/libressl/lib:\$LD_LIBRARY_PATH" \
239 LDFLAGS="-L/usr/local/libressl/lib" \
240 CFLAGS="-I/usr/local/libressl/include" \
241 tox -r -- --color=yes
242 else
243 tox -r -- --color=yes
244 fi
245 virtualenv .venv
246 source .venv/bin/activate
247 pip install coverage
248 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL
249 """
250 }
251 }
252 }
253 }
254 }
255 } finally {
256 deleteDir()
257 }
258
259}
260
261def builders = [:]
262for (config in configs) {
263 def label = config["label"]
264 def toxenvs = config["toxenvs"]
265
266 for (_toxenv in toxenvs) {
267 def toxenv = _toxenv
268
269 if (label.contains("docker")) {
270 def imageName = config["imageName"]
271 def combinedName = "${imageName}-${toxenv}"
272 builders[combinedName] = {
273 node(label) {
274 stage(combinedName) {
275 docker.image(imageName).inside {
276 build(toxenv, label, imageName)
277 }
278 }
279 }
280 }
281 } else {
282 def combinedName = "${label}-${toxenv}"
283 builders[combinedName] = {
284 node(label) {
285 stage(combinedName) {
286 build(toxenv, label, '')
287 }
288 }
289 }
290 }
291 }
292}
293
294/* Add the python setup.py test builder */
295builders["setup.py-test"] = {
296 node("docker") {
297 stage("python setup.py test") {
298 docker.image("pyca/cryptography-runner-ubuntu-rolling").inside {
299 try {
300 checkout_git("docker")
301 sh """#!/usr/bin/env bash
302 set -xe
303 cd cryptography
304 virtualenv .venv
305 source .venv/bin/activate
306 python setup.py test
307 """
308 } finally {
309 deleteDir()
310 }
311
312 }
313 }
314 }
315}
316
317parallel builders
318
319def downstreamBuilders = [:]
320for (downstream in downstreams) {
321 def downstreamName = downstream["downstreamName"]
322 def imageName = downstream["imageName"]
323 def label = downstream["label"]
324 def script = downstream["script"]
325 downstreamBuilders[downstreamName] = {
326 node(label) {
327 docker.image(imageName).inside {
328 try {
329 timeout(time: 30, unit: 'MINUTES') {
330 checkout_git(label)
331 sh script
332 }
333 } finally {
334 deleteDir()
335 }
336 }
337 }
338 }
339}
340
341stage("Downstreams") {
342 parallel downstreamBuilders
343}