blob: e152d921aed29ae438e7a1f61dad50ff9fc14942 [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',
Alex Gaynor20128c72017-10-28 19:16:49 -040049 toxenvs: ['py27', 'py36'],
Alex Gaynor70639ed2017-07-08 11:53:58 -040050 ],
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 Gaynor24bb7a02017-12-25 13:49:48 -050063 imageName: 'pyca/cryptography-runner-jessie-libressl:2.6.4',
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',
Alex Gaynorf2a03332017-10-21 09:13:42 -040074 toxenvs: ['py27', 'py36', '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 ],
Paul Kehrer7254db52018-02-13 20:07:14 +0400151 [
152 downstreamName: 'aws-encryption-sdk',
153 label: 'docker',
154 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
155 script: """#!/bin/bash -xe
156 git clone --depth=1 https://github.com/awslabs/aws-encryption-sdk-python
157 cd aws-encryption-sdk-python
158 virtualenv .venv
159 source .venv/bin/activate
160 pip install ../cryptography
161 pip install pytest pytest-mock mock
162 pip install -e .
163 AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID="arn:aws:kms:us-west-2:nonsense" pytest -m local -l
164 """
165 ],
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700166]
167
168def checkout_git(label) {
Alex Gaynor42b25712017-06-03 12:04:32 -0400169 retry(3) {
170 def script = ""
171 if (env.BRANCH_NAME.startsWith('PR-')) {
172 script = """
173 git clone --depth=1 https://github.com/pyca/cryptography
174 cd cryptography
175 git fetch origin +refs/pull/${env.CHANGE_ID}/merge:
176 git checkout -qf FETCH_HEAD
Paul Kehrera119d2e2017-05-23 22:02:50 -0700177 """
Alex Gaynor42b25712017-06-03 12:04:32 -0400178 if (label.contains("windows")) {
179 bat script
180 } else {
181 sh """#!/bin/sh
182 set -xe
183 ${script}
184 """
185 }
186 } else {
187 checkout([
188 $class: 'GitSCM',
189 branches: [[name: "*/${env.BRANCH_NAME}"]],
190 doGenerateSubmoduleConfigurations: false,
191 extensions: [[
192 $class: 'RelativeTargetDirectory',
193 relativeTargetDir: 'cryptography'
194 ]],
195 submoduleCfg: [],
196 userRemoteConfigs: [[
197 'url': 'https://github.com/pyca/cryptography'
198 ]]
199 ])
Paul Kehrera119d2e2017-05-23 22:02:50 -0700200 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700201 }
202 if (label.contains("windows")) {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700203 bat """
204 cd cryptography
205 git rev-parse HEAD
206 """
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700207 } else {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700208 sh """
209 cd cryptography
210 git rev-parse HEAD
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700211 """
212 }
213}
Alex Gaynor40226372017-05-23 14:14:18 -0700214def build(toxenv, label, imageName, artifacts, artifactExcludes) {
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700215 try {
216 timeout(time: 30, unit: 'MINUTES') {
217
218 checkout_git(label)
219
220 withCredentials([string(credentialsId: 'cryptography-codecov-token', variable: 'CODECOV_TOKEN')]) {
221 withEnv(["LABEL=$label", "TOXENV=$toxenv", "IMAGE_NAME=$imageName"]) {
222 if (label.contains("windows")) {
223 def pythonPath = [
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700224 py27: "C:\\Python27\\python.exe",
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700225 py34: "C:\\Python34\\python.exe",
226 py35: "C:\\Python35\\python.exe",
227 py36: "C:\\Python36\\python.exe"
228 ]
229 if (toxenv == "py35" || toxenv == "py36") {
230 opensslPaths = [
231 "windows": [
232 "include": "C:\\OpenSSL-Win32-2015\\include",
233 "lib": "C:\\OpenSSL-Win32-2015\\lib"
234 ],
235 "windows64": [
236 "include": "C:\\OpenSSL-Win64-2015\\include",
237 "lib": "C:\\OpenSSL-Win64-2015\\lib"
238 ]
239 ]
240 } else {
241 opensslPaths = [
242 "windows": [
243 "include": "C:\\OpenSSL-Win32-2010\\include",
244 "lib": "C:\\OpenSSL-Win32-2010\\lib"
245 ],
246 "windows64": [
247 "include": "C:\\OpenSSL-Win64-2010\\include",
248 "lib": "C:\\OpenSSL-Win64-2010\\lib"
249 ]
250 ]
251 }
252 bat """
253 cd cryptography
254 @set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH%
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700255 @set PYTHON="${pythonPath[toxenv]}"
256
257 @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE%
258 @set LIB="${opensslPaths[label]['lib']}";%LIB%
259 tox -r
260 IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
261 virtualenv .codecov
262 call .codecov/Scripts/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800263 REM this pin must be kept in sync with tox.ini
Paul Kehrercb175062017-06-03 08:26:56 -1000264 pip install coverage==4.3.4
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700265 pip install codecov
Paul Kehrer8396d432017-09-06 23:23:15 +0800266 codecov -e JOB_BASE_NAME,LABEL,TOXENV
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700267 """
268 } else if (label.contains("sierra") || label.contains("yosemite")) {
269 ansiColor {
270 sh """#!/usr/bin/env bash
271 set -xe
272 # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH
273 export PATH="/usr/local/bin:\${PATH}"
274 export PATH="/Users/jenkins/.pyenv/shims:\${PATH}"
275 cd cryptography
Paul Kehreradeaacf2017-05-24 12:49:18 -0700276 CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 \
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700277 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 -0500278 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 -0700279 tox -r -- --color=yes
280 virtualenv .venv
281 source .venv/bin/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800282 # This pin must be kept in sync with tox.ini
Paul Kehrercb175062017-06-03 08:26:56 -1000283 pip install coverage==4.3.4
Paul Kehrer8396d432017-09-06 23:23:15 +0800284 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700285 """
286 }
287 } else {
288 ansiColor {
289 sh """#!/usr/bin/env bash
290 set -xe
291 cd cryptography
292 if [[ "\${IMAGE_NAME}" == *"libressl"* ]]; then
293 LD_LIBRARY_PATH="/usr/local/libressl/lib:\$LD_LIBRARY_PATH" \
294 LDFLAGS="-L/usr/local/libressl/lib" \
295 CFLAGS="-I/usr/local/libressl/include" \
296 tox -r -- --color=yes
297 else
298 tox -r -- --color=yes
299 fi
300 virtualenv .venv
301 source .venv/bin/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800302 # This pin must be kept in sync with tox.ini
Paul Kehrercb175062017-06-03 08:26:56 -1000303 pip install coverage==4.3.4
Paul Kehrer8396d432017-09-06 23:23:15 +0800304 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV,IMAGE_NAME
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700305 """
306 }
Alex Gaynor40226372017-05-23 14:14:18 -0700307 if (artifacts) {
308 archiveArtifacts artifacts: artifacts, excludes: artifactExcludes
309 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700310 }
311 }
312 }
313 }
314 } finally {
315 deleteDir()
316 }
317
318}
319
320def builders = [:]
321for (config in configs) {
322 def label = config["label"]
323 def toxenvs = config["toxenvs"]
Alex Gaynor40226372017-05-23 14:14:18 -0700324 def artifacts = config["artifacts"]
325 def artifactExcludes = config["artifactExcludes"]
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700326
327 for (_toxenv in toxenvs) {
328 def toxenv = _toxenv
329
330 if (label.contains("docker")) {
331 def imageName = config["imageName"]
332 def combinedName = "${imageName}-${toxenv}"
333 builders[combinedName] = {
334 node(label) {
335 stage(combinedName) {
Paul Kehrerc033c902017-07-07 13:20:29 -0500336 def buildImage = docker.image(imageName)
337 buildImage.pull()
338 buildImage.inside {
Alex Gaynor40226372017-05-23 14:14:18 -0700339 build(toxenv, label, imageName, artifacts, artifactExcludes)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700340 }
341 }
342 }
343 }
344 } else {
345 def combinedName = "${label}-${toxenv}"
346 builders[combinedName] = {
347 node(label) {
348 stage(combinedName) {
Alex Gaynor40226372017-05-23 14:14:18 -0700349 build(toxenv, label, '', null, null)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700350 }
351 }
352 }
353 }
354 }
355}
356
357/* Add the python setup.py test builder */
358builders["setup.py-test"] = {
359 node("docker") {
360 stage("python setup.py test") {
361 docker.image("pyca/cryptography-runner-ubuntu-rolling").inside {
362 try {
363 checkout_git("docker")
364 sh """#!/usr/bin/env bash
365 set -xe
366 cd cryptography
367 virtualenv .venv
368 source .venv/bin/activate
369 python setup.py test
370 """
371 } finally {
372 deleteDir()
373 }
374
375 }
376 }
377 }
378}
379
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700380for (downstream in downstreams) {
381 def downstreamName = downstream["downstreamName"]
382 def imageName = downstream["imageName"]
383 def label = downstream["label"]
384 def script = downstream["script"]
Paul Kehrer3d96afd2017-10-04 10:53:18 +0800385 builders[downstreamName] = {
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700386 node(label) {
387 docker.image(imageName).inside {
388 try {
389 timeout(time: 30, unit: 'MINUTES') {
390 checkout_git(label)
391 sh script
392 }
393 } finally {
394 deleteDir()
395 }
396 }
397 }
398 }
399}
400
Paul Kehrer3d96afd2017-10-04 10:53:18 +0800401parallel builders
402