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', |
| 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', |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 64 | toxenvs: ['py27', 'py35', 'pep8', 'py3pep8', 'randomorder'], |
| 65 | ], |
| 66 | [ |
| 67 | label: 'docker', |
Paul Kehrer | 6bdae78 | 2017-06-06 08:45:01 -1000 | [diff] [blame] | 68 | imageName: 'pyca/cryptography-runner-sid', |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 69 | toxenvs: ['docs'], |
| 70 | artifacts: 'cryptography/docs/_build/html/**', |
| 71 | artifactExcludes: '**/*.doctree', |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 72 | ], |
| 73 | [ |
| 74 | label: 'docker', |
| 75 | imageName: 'pyca/cryptography-runner-fedora', |
| 76 | toxenvs: ['py27', 'py35'], |
| 77 | ], |
Paul Kehrer | 8c0e731 | 2017-06-25 12:22:07 -1000 | [diff] [blame] | 78 | [ |
| 79 | label: 'docker', |
| 80 | imageName: 'pyca/cryptography-runner-alpine:latest', |
| 81 | toxenvs: ['py36'], |
| 82 | ], |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 83 | ] |
| 84 | |
| 85 | /* Add the linkcheck job to our config list if we're on master */ |
| 86 | if (env.BRANCH_NAME == "master") { |
| 87 | configs.add( |
| 88 | [ |
| 89 | label: 'docker', |
Paul Kehrer | 6bdae78 | 2017-06-06 08:45:01 -1000 | [diff] [blame] | 90 | imageName: 'pyca/cryptography-runner-sid', |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 91 | toxenvs: ['docs-linkcheck'], |
| 92 | ] |
| 93 | ) |
| 94 | } |
| 95 | |
| 96 | def downstreams = [ |
| 97 | [ |
| 98 | downstreamName: 'pyOpenSSL', |
| 99 | label: 'docker', |
| 100 | imageName: 'pyca/cryptography-runner-ubuntu-rolling', |
| 101 | script: """#!/bin/bash -xe |
Alex Gaynor | a7e9a22 | 2017-06-01 11:02:15 -0400 | [diff] [blame] | 102 | git clone --depth=1 https://github.com/pyca/pyopenssl |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 103 | cd pyopenssl |
| 104 | virtualenv .venv |
| 105 | source .venv/bin/activate |
| 106 | pip install ../cryptography |
| 107 | pip install -e . |
Paul Kehrer | b16206e | 2017-06-29 22:17:08 -0500 | [diff] [blame] | 108 | pip install pytest pretend |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 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 Gaynor | a7e9a22 | 2017-06-01 11:02:15 -0400 | [diff] [blame] | 117 | git clone --depth=1 https://github.com/twisted/twisted |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 118 | 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 Gaynor | a7e9a22 | 2017-06-01 11:02:15 -0400 | [diff] [blame] | 132 | git clone --depth=1 https://github.com/paramiko/paramiko |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 133 | 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 | |
| 144 | def checkout_git(label) { |
Alex Gaynor | 42b2571 | 2017-06-03 12:04:32 -0400 | [diff] [blame] | 145 | 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 Kehrer | a119d2e | 2017-05-23 22:02:50 -0700 | [diff] [blame] | 153 | """ |
Alex Gaynor | 42b2571 | 2017-06-03 12:04:32 -0400 | [diff] [blame] | 154 | 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 Kehrer | a119d2e | 2017-05-23 22:02:50 -0700 | [diff] [blame] | 176 | } |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 177 | } |
| 178 | if (label.contains("windows")) { |
Paul Kehrer | a119d2e | 2017-05-23 22:02:50 -0700 | [diff] [blame] | 179 | bat """ |
| 180 | cd cryptography |
| 181 | git rev-parse HEAD |
| 182 | """ |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 183 | } else { |
Paul Kehrer | a119d2e | 2017-05-23 22:02:50 -0700 | [diff] [blame] | 184 | sh """ |
| 185 | cd cryptography |
| 186 | git rev-parse HEAD |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 187 | """ |
| 188 | } |
| 189 | } |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 190 | def build(toxenv, label, imageName, artifacts, artifactExcludes) { |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 191 | 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", |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 202 | py34: "C:\\Python34\\python.exe", |
| 203 | py35: "C:\\Python35\\python.exe", |
| 204 | py36: "C:\\Python36\\python.exe" |
| 205 | ] |
| 206 | if (toxenv == "py35" || toxenv == "py36") { |
| 207 | opensslPaths = [ |
| 208 | "windows": [ |
| 209 | "include": "C:\\OpenSSL-Win32-2015\\include", |
| 210 | "lib": "C:\\OpenSSL-Win32-2015\\lib" |
| 211 | ], |
| 212 | "windows64": [ |
| 213 | "include": "C:\\OpenSSL-Win64-2015\\include", |
| 214 | "lib": "C:\\OpenSSL-Win64-2015\\lib" |
| 215 | ] |
| 216 | ] |
| 217 | } else { |
| 218 | opensslPaths = [ |
| 219 | "windows": [ |
| 220 | "include": "C:\\OpenSSL-Win32-2010\\include", |
| 221 | "lib": "C:\\OpenSSL-Win32-2010\\lib" |
| 222 | ], |
| 223 | "windows64": [ |
| 224 | "include": "C:\\OpenSSL-Win64-2010\\include", |
| 225 | "lib": "C:\\OpenSSL-Win64-2010\\lib" |
| 226 | ] |
| 227 | ] |
| 228 | } |
| 229 | bat """ |
| 230 | cd cryptography |
| 231 | @set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH% |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 232 | @set PYTHON="${pythonPath[toxenv]}" |
| 233 | |
| 234 | @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE% |
| 235 | @set LIB="${opensslPaths[label]['lib']}";%LIB% |
| 236 | tox -r |
| 237 | IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% |
| 238 | virtualenv .codecov |
| 239 | call .codecov/Scripts/activate |
Paul Kehrer | cb17506 | 2017-06-03 08:26:56 -1000 | [diff] [blame] | 240 | pip install coverage==4.3.4 |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 241 | pip install codecov |
| 242 | codecov -e JOB_BASE_NAME,LABEL |
| 243 | """ |
| 244 | } else if (label.contains("sierra") || label.contains("yosemite")) { |
| 245 | ansiColor { |
| 246 | sh """#!/usr/bin/env bash |
| 247 | set -xe |
| 248 | # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH |
| 249 | export PATH="/usr/local/bin:\${PATH}" |
| 250 | export PATH="/Users/jenkins/.pyenv/shims:\${PATH}" |
| 251 | cd cryptography |
Paul Kehrer | adeaacf | 2017-05-24 12:49:18 -0700 | [diff] [blame] | 252 | CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 \ |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 253 | 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] | 254 | 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] | 255 | tox -r -- --color=yes |
| 256 | virtualenv .venv |
| 257 | source .venv/bin/activate |
Paul Kehrer | cb17506 | 2017-06-03 08:26:56 -1000 | [diff] [blame] | 258 | pip install coverage==4.3.4 |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 259 | bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL |
| 260 | """ |
| 261 | } |
| 262 | } else { |
| 263 | ansiColor { |
| 264 | sh """#!/usr/bin/env bash |
| 265 | set -xe |
| 266 | cd cryptography |
| 267 | if [[ "\${IMAGE_NAME}" == *"libressl"* ]]; then |
| 268 | LD_LIBRARY_PATH="/usr/local/libressl/lib:\$LD_LIBRARY_PATH" \ |
| 269 | LDFLAGS="-L/usr/local/libressl/lib" \ |
| 270 | CFLAGS="-I/usr/local/libressl/include" \ |
| 271 | tox -r -- --color=yes |
| 272 | else |
| 273 | tox -r -- --color=yes |
| 274 | fi |
| 275 | virtualenv .venv |
| 276 | source .venv/bin/activate |
Paul Kehrer | cb17506 | 2017-06-03 08:26:56 -1000 | [diff] [blame] | 277 | pip install coverage==4.3.4 |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 278 | bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL |
| 279 | """ |
| 280 | } |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 281 | if (artifacts) { |
| 282 | archiveArtifacts artifacts: artifacts, excludes: artifactExcludes |
| 283 | } |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 284 | } |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | } finally { |
| 289 | deleteDir() |
| 290 | } |
| 291 | |
| 292 | } |
| 293 | |
| 294 | def builders = [:] |
| 295 | for (config in configs) { |
| 296 | def label = config["label"] |
| 297 | def toxenvs = config["toxenvs"] |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 298 | def artifacts = config["artifacts"] |
| 299 | def artifactExcludes = config["artifactExcludes"] |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 300 | |
| 301 | for (_toxenv in toxenvs) { |
| 302 | def toxenv = _toxenv |
| 303 | |
| 304 | if (label.contains("docker")) { |
| 305 | def imageName = config["imageName"] |
| 306 | def combinedName = "${imageName}-${toxenv}" |
| 307 | builders[combinedName] = { |
| 308 | node(label) { |
| 309 | stage(combinedName) { |
| 310 | docker.image(imageName).inside { |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 311 | build(toxenv, label, imageName, artifacts, artifactExcludes) |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 312 | } |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | } else { |
| 317 | def combinedName = "${label}-${toxenv}" |
| 318 | builders[combinedName] = { |
| 319 | node(label) { |
| 320 | stage(combinedName) { |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 321 | build(toxenv, label, '', null, null) |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 322 | } |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | /* Add the python setup.py test builder */ |
| 330 | builders["setup.py-test"] = { |
| 331 | node("docker") { |
| 332 | stage("python setup.py test") { |
| 333 | docker.image("pyca/cryptography-runner-ubuntu-rolling").inside { |
| 334 | try { |
| 335 | checkout_git("docker") |
| 336 | sh """#!/usr/bin/env bash |
| 337 | set -xe |
| 338 | cd cryptography |
| 339 | virtualenv .venv |
| 340 | source .venv/bin/activate |
| 341 | python setup.py test |
| 342 | """ |
| 343 | } finally { |
| 344 | deleteDir() |
| 345 | } |
| 346 | |
| 347 | } |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | parallel builders |
| 353 | |
| 354 | def downstreamBuilders = [:] |
| 355 | for (downstream in downstreams) { |
| 356 | def downstreamName = downstream["downstreamName"] |
| 357 | def imageName = downstream["imageName"] |
| 358 | def label = downstream["label"] |
| 359 | def script = downstream["script"] |
| 360 | downstreamBuilders[downstreamName] = { |
| 361 | node(label) { |
| 362 | docker.image(imageName).inside { |
| 363 | try { |
| 364 | timeout(time: 30, unit: 'MINUTES') { |
| 365 | checkout_git(label) |
| 366 | sh script |
| 367 | } |
| 368 | } finally { |
| 369 | deleteDir() |
| 370 | } |
| 371 | } |
| 372 | } |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | stage("Downstreams") { |
| 377 | parallel downstreamBuilders |
| 378 | } |