Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 1 | if (env.BRANCH_NAME == "master") { |
| 2 | properties([pipelineTriggers([cron('@daily')])]) |
| 3 | } |
| 4 | |
| 5 | def configs = [ |
| 6 | [ |
| 7 | label: 'windows', |
Paul Kehrer | e3a2fb2 | 2017-06-26 15:08:33 -1000 | [diff] [blame] | 8 | toxenvs: ['py26', 'py27', 'py34', 'py35', 'py36'], |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 9 | ], |
| 10 | [ |
| 11 | label: 'windows64', |
Paul Kehrer | e3a2fb2 | 2017-06-26 15:08:33 -1000 | [diff] [blame] | 12 | toxenvs: ['py26', 'py27', 'py34', 'py35', 'py36'], |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 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', |
Alex Gaynor | 70639ed | 2017-07-08 11:53:58 -0400 | [diff] [blame] | 43 | imageName: 'pyca/cryptography-runner-stretch', |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 44 | toxenvs: ['py27', 'py35'], |
| 45 | ], |
| 46 | [ |
| 47 | label: 'docker', |
Alex Gaynor | 70639ed | 2017-07-08 11:53:58 -0400 | [diff] [blame] | 48 | imageName: 'pyca/cryptography-runner-buster', |
| 49 | toxenvs: ['py27', 'py35'], |
| 50 | ], |
| 51 | [ |
| 52 | label: 'docker', |
| 53 | imageName: 'pyca/cryptography-runner-sid', |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 54 | toxenvs: ['py27', 'py35'], |
| 55 | ], |
| 56 | [ |
| 57 | label: 'docker', |
| 58 | imageName: 'pyca/cryptography-runner-jessie-libressl:2.4.5', |
| 59 | toxenvs: ['py27'], |
| 60 | ], |
| 61 | [ |
| 62 | label: 'docker', |
Alex Gaynor | b522324 | 2017-09-15 02:37:39 -0400 | [diff] [blame^] | 63 | imageName: 'pyca/cryptography-runner-jessie-libressl:2.6.1', |
Alex Gaynor | 45f2a42 | 2017-07-26 09:10:32 -0400 | [diff] [blame] | 64 | toxenvs: ['py27'], |
| 65 | ], |
| 66 | [ |
| 67 | label: 'docker', |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 68 | imageName: 'pyca/cryptography-runner-ubuntu-xenial', |
| 69 | toxenvs: ['py27', 'py35'], |
| 70 | ], |
| 71 | [ |
| 72 | label: 'docker', |
| 73 | imageName: 'pyca/cryptography-runner-ubuntu-rolling', |
Paul Kehrer | 9c63524 | 2017-07-08 12:02:15 -0500 | [diff] [blame] | 74 | toxenvs: ['py27', 'py35', 'randomorder'], |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 75 | ], |
| 76 | [ |
| 77 | label: 'docker', |
Paul Kehrer | 6bdae78 | 2017-06-06 08:45:01 -1000 | [diff] [blame] | 78 | imageName: 'pyca/cryptography-runner-sid', |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 79 | toxenvs: ['docs'], |
| 80 | artifacts: 'cryptography/docs/_build/html/**', |
| 81 | artifactExcludes: '**/*.doctree', |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 82 | ], |
| 83 | [ |
| 84 | label: 'docker', |
| 85 | imageName: 'pyca/cryptography-runner-fedora', |
Alex Gaynor | 2e64a3f | 2017-07-13 08:30:24 -0400 | [diff] [blame] | 86 | toxenvs: ['py27', 'py36'], |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 87 | ], |
Paul Kehrer | 8c0e731 | 2017-06-25 12:22:07 -1000 | [diff] [blame] | 88 | [ |
| 89 | label: 'docker', |
| 90 | imageName: 'pyca/cryptography-runner-alpine:latest', |
| 91 | toxenvs: ['py36'], |
| 92 | ], |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 93 | ] |
| 94 | |
| 95 | /* Add the linkcheck job to our config list if we're on master */ |
| 96 | if (env.BRANCH_NAME == "master") { |
| 97 | configs.add( |
| 98 | [ |
| 99 | label: 'docker', |
Paul Kehrer | 6bdae78 | 2017-06-06 08:45:01 -1000 | [diff] [blame] | 100 | imageName: 'pyca/cryptography-runner-sid', |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 101 | toxenvs: ['docs-linkcheck'], |
| 102 | ] |
| 103 | ) |
| 104 | } |
| 105 | |
| 106 | def downstreams = [ |
| 107 | [ |
| 108 | downstreamName: 'pyOpenSSL', |
| 109 | label: 'docker', |
| 110 | imageName: 'pyca/cryptography-runner-ubuntu-rolling', |
| 111 | script: """#!/bin/bash -xe |
Alex Gaynor | a7e9a22 | 2017-06-01 11:02:15 -0400 | [diff] [blame] | 112 | git clone --depth=1 https://github.com/pyca/pyopenssl |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 113 | cd pyopenssl |
| 114 | virtualenv .venv |
| 115 | source .venv/bin/activate |
| 116 | pip install ../cryptography |
Paul Kehrer | f564b7e | 2017-07-07 06:30:50 -0500 | [diff] [blame] | 117 | pip install -e .[test] |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 118 | pytest tests |
| 119 | """ |
| 120 | ], |
| 121 | [ |
| 122 | downstreamName: 'Twisted', |
| 123 | label: 'docker', |
| 124 | imageName: 'pyca/cryptography-runner-ubuntu-rolling', |
| 125 | script: """#!/bin/bash -xe |
Alex Gaynor | a7e9a22 | 2017-06-01 11:02:15 -0400 | [diff] [blame] | 126 | git clone --depth=1 https://github.com/twisted/twisted |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 127 | 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 Gaynor | a7e9a22 | 2017-06-01 11:02:15 -0400 | [diff] [blame] | 141 | git clone --depth=1 https://github.com/paramiko/paramiko |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 142 | 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 | |
| 153 | def checkout_git(label) { |
Alex Gaynor | 42b2571 | 2017-06-03 12:04:32 -0400 | [diff] [blame] | 154 | 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 Kehrer | a119d2e | 2017-05-23 22:02:50 -0700 | [diff] [blame] | 162 | """ |
Alex Gaynor | 42b2571 | 2017-06-03 12:04:32 -0400 | [diff] [blame] | 163 | 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 Kehrer | a119d2e | 2017-05-23 22:02:50 -0700 | [diff] [blame] | 185 | } |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 186 | } |
| 187 | if (label.contains("windows")) { |
Paul Kehrer | a119d2e | 2017-05-23 22:02:50 -0700 | [diff] [blame] | 188 | bat """ |
| 189 | cd cryptography |
| 190 | git rev-parse HEAD |
| 191 | """ |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 192 | } else { |
Paul Kehrer | a119d2e | 2017-05-23 22:02:50 -0700 | [diff] [blame] | 193 | sh """ |
| 194 | cd cryptography |
| 195 | git rev-parse HEAD |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 196 | """ |
| 197 | } |
| 198 | } |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 199 | def build(toxenv, label, imageName, artifacts, artifactExcludes) { |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 200 | 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 = [ |
| 209 | py26: "C:\\Python26\\python.exe", |
| 210 | py27: "C:\\Python27\\python.exe", |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 211 | py34: "C:\\Python34\\python.exe", |
| 212 | py35: "C:\\Python35\\python.exe", |
| 213 | py36: "C:\\Python36\\python.exe" |
| 214 | ] |
| 215 | if (toxenv == "py35" || toxenv == "py36") { |
| 216 | opensslPaths = [ |
| 217 | "windows": [ |
| 218 | "include": "C:\\OpenSSL-Win32-2015\\include", |
| 219 | "lib": "C:\\OpenSSL-Win32-2015\\lib" |
| 220 | ], |
| 221 | "windows64": [ |
| 222 | "include": "C:\\OpenSSL-Win64-2015\\include", |
| 223 | "lib": "C:\\OpenSSL-Win64-2015\\lib" |
| 224 | ] |
| 225 | ] |
| 226 | } else { |
| 227 | opensslPaths = [ |
| 228 | "windows": [ |
| 229 | "include": "C:\\OpenSSL-Win32-2010\\include", |
| 230 | "lib": "C:\\OpenSSL-Win32-2010\\lib" |
| 231 | ], |
| 232 | "windows64": [ |
| 233 | "include": "C:\\OpenSSL-Win64-2010\\include", |
| 234 | "lib": "C:\\OpenSSL-Win64-2010\\lib" |
| 235 | ] |
| 236 | ] |
| 237 | } |
| 238 | bat """ |
| 239 | cd cryptography |
| 240 | @set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH% |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 241 | @set PYTHON="${pythonPath[toxenv]}" |
| 242 | |
| 243 | @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE% |
| 244 | @set LIB="${opensslPaths[label]['lib']}";%LIB% |
| 245 | tox -r |
| 246 | IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% |
| 247 | virtualenv .codecov |
| 248 | call .codecov/Scripts/activate |
Paul Kehrer | e535985 | 2017-09-13 09:30:51 +0800 | [diff] [blame] | 249 | REM this pin must be kept in sync with tox.ini |
Paul Kehrer | cb17506 | 2017-06-03 08:26:56 -1000 | [diff] [blame] | 250 | pip install coverage==4.3.4 |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 251 | pip install codecov |
Paul Kehrer | 8396d43 | 2017-09-06 23:23:15 +0800 | [diff] [blame] | 252 | codecov -e JOB_BASE_NAME,LABEL,TOXENV |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 253 | """ |
| 254 | } else if (label.contains("sierra") || label.contains("yosemite")) { |
| 255 | ansiColor { |
| 256 | sh """#!/usr/bin/env bash |
| 257 | set -xe |
| 258 | # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH |
| 259 | export PATH="/usr/local/bin:\${PATH}" |
| 260 | export PATH="/Users/jenkins/.pyenv/shims:\${PATH}" |
| 261 | cd cryptography |
Paul Kehrer | adeaacf | 2017-05-24 12:49:18 -0700 | [diff] [blame] | 262 | CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 \ |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 263 | LDFLAGS="/usr/local/opt/openssl\\@1.1/lib/libcrypto.a /usr/local/opt/openssl\\@1.1/lib/libssl.a" \ |
Paul Kehrer | b637aec | 2017-05-30 20:56:15 -0500 | [diff] [blame] | 264 | 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 Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 265 | tox -r -- --color=yes |
| 266 | virtualenv .venv |
| 267 | source .venv/bin/activate |
Paul Kehrer | e535985 | 2017-09-13 09:30:51 +0800 | [diff] [blame] | 268 | # This pin must be kept in sync with tox.ini |
Paul Kehrer | cb17506 | 2017-06-03 08:26:56 -1000 | [diff] [blame] | 269 | pip install coverage==4.3.4 |
Paul Kehrer | 8396d43 | 2017-09-06 23:23:15 +0800 | [diff] [blame] | 270 | bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 271 | """ |
| 272 | } |
| 273 | } else { |
| 274 | ansiColor { |
| 275 | sh """#!/usr/bin/env bash |
| 276 | set -xe |
| 277 | cd cryptography |
| 278 | if [[ "\${IMAGE_NAME}" == *"libressl"* ]]; then |
| 279 | LD_LIBRARY_PATH="/usr/local/libressl/lib:\$LD_LIBRARY_PATH" \ |
| 280 | LDFLAGS="-L/usr/local/libressl/lib" \ |
| 281 | CFLAGS="-I/usr/local/libressl/include" \ |
| 282 | tox -r -- --color=yes |
| 283 | else |
| 284 | tox -r -- --color=yes |
| 285 | fi |
| 286 | virtualenv .venv |
| 287 | source .venv/bin/activate |
Paul Kehrer | e535985 | 2017-09-13 09:30:51 +0800 | [diff] [blame] | 288 | # This pin must be kept in sync with tox.ini |
Paul Kehrer | cb17506 | 2017-06-03 08:26:56 -1000 | [diff] [blame] | 289 | pip install coverage==4.3.4 |
Paul Kehrer | 8396d43 | 2017-09-06 23:23:15 +0800 | [diff] [blame] | 290 | bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV,IMAGE_NAME |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 291 | """ |
| 292 | } |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 293 | if (artifacts) { |
| 294 | archiveArtifacts artifacts: artifacts, excludes: artifactExcludes |
| 295 | } |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 296 | } |
| 297 | } |
| 298 | } |
| 299 | } |
| 300 | } finally { |
| 301 | deleteDir() |
| 302 | } |
| 303 | |
| 304 | } |
| 305 | |
| 306 | def builders = [:] |
| 307 | for (config in configs) { |
| 308 | def label = config["label"] |
| 309 | def toxenvs = config["toxenvs"] |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 310 | def artifacts = config["artifacts"] |
| 311 | def artifactExcludes = config["artifactExcludes"] |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 312 | |
| 313 | for (_toxenv in toxenvs) { |
| 314 | def toxenv = _toxenv |
| 315 | |
| 316 | if (label.contains("docker")) { |
| 317 | def imageName = config["imageName"] |
| 318 | def combinedName = "${imageName}-${toxenv}" |
| 319 | builders[combinedName] = { |
| 320 | node(label) { |
| 321 | stage(combinedName) { |
Paul Kehrer | c033c90 | 2017-07-07 13:20:29 -0500 | [diff] [blame] | 322 | def buildImage = docker.image(imageName) |
| 323 | buildImage.pull() |
| 324 | buildImage.inside { |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 325 | build(toxenv, label, imageName, artifacts, artifactExcludes) |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 326 | } |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | } else { |
| 331 | def combinedName = "${label}-${toxenv}" |
| 332 | builders[combinedName] = { |
| 333 | node(label) { |
| 334 | stage(combinedName) { |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 335 | build(toxenv, label, '', null, null) |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 336 | } |
| 337 | } |
| 338 | } |
| 339 | } |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | /* Add the python setup.py test builder */ |
| 344 | builders["setup.py-test"] = { |
| 345 | node("docker") { |
| 346 | stage("python setup.py test") { |
| 347 | docker.image("pyca/cryptography-runner-ubuntu-rolling").inside { |
| 348 | try { |
| 349 | checkout_git("docker") |
| 350 | sh """#!/usr/bin/env bash |
| 351 | set -xe |
| 352 | cd cryptography |
| 353 | virtualenv .venv |
| 354 | source .venv/bin/activate |
| 355 | python setup.py test |
| 356 | """ |
| 357 | } finally { |
| 358 | deleteDir() |
| 359 | } |
| 360 | |
| 361 | } |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | parallel builders |
| 367 | |
| 368 | def downstreamBuilders = [:] |
| 369 | for (downstream in downstreams) { |
| 370 | def downstreamName = downstream["downstreamName"] |
| 371 | def imageName = downstream["imageName"] |
| 372 | def label = downstream["label"] |
| 373 | def script = downstream["script"] |
| 374 | downstreamBuilders[downstreamName] = { |
| 375 | node(label) { |
| 376 | docker.image(imageName).inside { |
| 377 | try { |
| 378 | timeout(time: 30, unit: 'MINUTES') { |
| 379 | checkout_git(label) |
| 380 | sh script |
| 381 | } |
| 382 | } finally { |
| 383 | deleteDir() |
| 384 | } |
| 385 | } |
| 386 | } |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | stage("Downstreams") { |
| 391 | parallel downstreamBuilders |
| 392 | } |