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 |
Paul Kehrer | f564b7e | 2017-07-07 06:30:50 -0500 | [diff] [blame] | 107 | pip install -e .[test] |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 108 | pytest tests |
| 109 | """ |
| 110 | ], |
| 111 | [ |
| 112 | downstreamName: 'Twisted', |
| 113 | label: 'docker', |
| 114 | imageName: 'pyca/cryptography-runner-ubuntu-rolling', |
| 115 | script: """#!/bin/bash -xe |
Alex Gaynor | a7e9a22 | 2017-06-01 11:02:15 -0400 | [diff] [blame] | 116 | git clone --depth=1 https://github.com/twisted/twisted |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 117 | cd twisted |
| 118 | virtualenv .venv |
| 119 | source .venv/bin/activate |
| 120 | pip install ../cryptography |
| 121 | pip install pyopenssl service_identity pycrypto |
| 122 | pip install -e . |
| 123 | python -m twisted.trial src/twisted |
| 124 | """ |
| 125 | ], |
| 126 | [ |
| 127 | downstreamName: 'paramiko', |
| 128 | label: 'docker', |
| 129 | imageName: 'pyca/cryptography-runner-ubuntu-rolling', |
| 130 | script: """#!/bin/bash -xe |
Alex Gaynor | a7e9a22 | 2017-06-01 11:02:15 -0400 | [diff] [blame] | 131 | git clone --depth=1 https://github.com/paramiko/paramiko |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 132 | cd paramiko |
| 133 | virtualenv .venv |
| 134 | source .venv/bin/activate |
| 135 | pip install ../cryptography |
| 136 | pip install -e . |
| 137 | pip install -r dev-requirements.txt |
| 138 | inv test |
| 139 | """ |
| 140 | ], |
| 141 | ] |
| 142 | |
| 143 | def checkout_git(label) { |
Alex Gaynor | 42b2571 | 2017-06-03 12:04:32 -0400 | [diff] [blame] | 144 | retry(3) { |
| 145 | def script = "" |
| 146 | if (env.BRANCH_NAME.startsWith('PR-')) { |
| 147 | script = """ |
| 148 | git clone --depth=1 https://github.com/pyca/cryptography |
| 149 | cd cryptography |
| 150 | git fetch origin +refs/pull/${env.CHANGE_ID}/merge: |
| 151 | git checkout -qf FETCH_HEAD |
Paul Kehrer | a119d2e | 2017-05-23 22:02:50 -0700 | [diff] [blame] | 152 | """ |
Alex Gaynor | 42b2571 | 2017-06-03 12:04:32 -0400 | [diff] [blame] | 153 | if (label.contains("windows")) { |
| 154 | bat script |
| 155 | } else { |
| 156 | sh """#!/bin/sh |
| 157 | set -xe |
| 158 | ${script} |
| 159 | """ |
| 160 | } |
| 161 | } else { |
| 162 | checkout([ |
| 163 | $class: 'GitSCM', |
| 164 | branches: [[name: "*/${env.BRANCH_NAME}"]], |
| 165 | doGenerateSubmoduleConfigurations: false, |
| 166 | extensions: [[ |
| 167 | $class: 'RelativeTargetDirectory', |
| 168 | relativeTargetDir: 'cryptography' |
| 169 | ]], |
| 170 | submoduleCfg: [], |
| 171 | userRemoteConfigs: [[ |
| 172 | 'url': 'https://github.com/pyca/cryptography' |
| 173 | ]] |
| 174 | ]) |
Paul Kehrer | a119d2e | 2017-05-23 22:02:50 -0700 | [diff] [blame] | 175 | } |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 176 | } |
| 177 | if (label.contains("windows")) { |
Paul Kehrer | a119d2e | 2017-05-23 22:02:50 -0700 | [diff] [blame] | 178 | bat """ |
| 179 | cd cryptography |
| 180 | git rev-parse HEAD |
| 181 | """ |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 182 | } else { |
Paul Kehrer | a119d2e | 2017-05-23 22:02:50 -0700 | [diff] [blame] | 183 | sh """ |
| 184 | cd cryptography |
| 185 | git rev-parse HEAD |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 186 | """ |
| 187 | } |
| 188 | } |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 189 | def build(toxenv, label, imageName, artifacts, artifactExcludes) { |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 190 | try { |
| 191 | timeout(time: 30, unit: 'MINUTES') { |
| 192 | |
| 193 | checkout_git(label) |
| 194 | |
| 195 | withCredentials([string(credentialsId: 'cryptography-codecov-token', variable: 'CODECOV_TOKEN')]) { |
| 196 | withEnv(["LABEL=$label", "TOXENV=$toxenv", "IMAGE_NAME=$imageName"]) { |
| 197 | if (label.contains("windows")) { |
| 198 | def pythonPath = [ |
| 199 | py26: "C:\\Python26\\python.exe", |
| 200 | py27: "C:\\Python27\\python.exe", |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 201 | py34: "C:\\Python34\\python.exe", |
| 202 | py35: "C:\\Python35\\python.exe", |
| 203 | py36: "C:\\Python36\\python.exe" |
| 204 | ] |
| 205 | if (toxenv == "py35" || toxenv == "py36") { |
| 206 | opensslPaths = [ |
| 207 | "windows": [ |
| 208 | "include": "C:\\OpenSSL-Win32-2015\\include", |
| 209 | "lib": "C:\\OpenSSL-Win32-2015\\lib" |
| 210 | ], |
| 211 | "windows64": [ |
| 212 | "include": "C:\\OpenSSL-Win64-2015\\include", |
| 213 | "lib": "C:\\OpenSSL-Win64-2015\\lib" |
| 214 | ] |
| 215 | ] |
| 216 | } else { |
| 217 | opensslPaths = [ |
| 218 | "windows": [ |
| 219 | "include": "C:\\OpenSSL-Win32-2010\\include", |
| 220 | "lib": "C:\\OpenSSL-Win32-2010\\lib" |
| 221 | ], |
| 222 | "windows64": [ |
| 223 | "include": "C:\\OpenSSL-Win64-2010\\include", |
| 224 | "lib": "C:\\OpenSSL-Win64-2010\\lib" |
| 225 | ] |
| 226 | ] |
| 227 | } |
| 228 | bat """ |
| 229 | cd cryptography |
| 230 | @set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH% |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 231 | @set PYTHON="${pythonPath[toxenv]}" |
| 232 | |
| 233 | @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE% |
| 234 | @set LIB="${opensslPaths[label]['lib']}";%LIB% |
| 235 | tox -r |
| 236 | IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% |
| 237 | virtualenv .codecov |
| 238 | call .codecov/Scripts/activate |
Paul Kehrer | cb17506 | 2017-06-03 08:26:56 -1000 | [diff] [blame] | 239 | pip install coverage==4.3.4 |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 240 | pip install codecov |
| 241 | codecov -e JOB_BASE_NAME,LABEL |
| 242 | """ |
| 243 | } else if (label.contains("sierra") || label.contains("yosemite")) { |
| 244 | ansiColor { |
| 245 | sh """#!/usr/bin/env bash |
| 246 | set -xe |
| 247 | # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH |
| 248 | export PATH="/usr/local/bin:\${PATH}" |
| 249 | export PATH="/Users/jenkins/.pyenv/shims:\${PATH}" |
| 250 | cd cryptography |
Paul Kehrer | adeaacf | 2017-05-24 12:49:18 -0700 | [diff] [blame] | 251 | CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 \ |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 252 | 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] | 253 | 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] | 254 | tox -r -- --color=yes |
| 255 | virtualenv .venv |
| 256 | source .venv/bin/activate |
Paul Kehrer | cb17506 | 2017-06-03 08:26:56 -1000 | [diff] [blame] | 257 | pip install coverage==4.3.4 |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 258 | bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL |
| 259 | """ |
| 260 | } |
| 261 | } else { |
| 262 | ansiColor { |
| 263 | sh """#!/usr/bin/env bash |
| 264 | set -xe |
| 265 | cd cryptography |
| 266 | if [[ "\${IMAGE_NAME}" == *"libressl"* ]]; then |
| 267 | LD_LIBRARY_PATH="/usr/local/libressl/lib:\$LD_LIBRARY_PATH" \ |
| 268 | LDFLAGS="-L/usr/local/libressl/lib" \ |
| 269 | CFLAGS="-I/usr/local/libressl/include" \ |
| 270 | tox -r -- --color=yes |
| 271 | else |
| 272 | tox -r -- --color=yes |
| 273 | fi |
| 274 | virtualenv .venv |
| 275 | source .venv/bin/activate |
Paul Kehrer | cb17506 | 2017-06-03 08:26:56 -1000 | [diff] [blame] | 276 | pip install coverage==4.3.4 |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 277 | bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL |
| 278 | """ |
| 279 | } |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 280 | if (artifacts) { |
| 281 | archiveArtifacts artifacts: artifacts, excludes: artifactExcludes |
| 282 | } |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 283 | } |
| 284 | } |
| 285 | } |
| 286 | } |
| 287 | } finally { |
| 288 | deleteDir() |
| 289 | } |
| 290 | |
| 291 | } |
| 292 | |
| 293 | def builders = [:] |
| 294 | for (config in configs) { |
| 295 | def label = config["label"] |
| 296 | def toxenvs = config["toxenvs"] |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 297 | def artifacts = config["artifacts"] |
| 298 | def artifactExcludes = config["artifactExcludes"] |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 299 | |
| 300 | for (_toxenv in toxenvs) { |
| 301 | def toxenv = _toxenv |
| 302 | |
| 303 | if (label.contains("docker")) { |
| 304 | def imageName = config["imageName"] |
| 305 | def combinedName = "${imageName}-${toxenv}" |
| 306 | builders[combinedName] = { |
| 307 | node(label) { |
| 308 | stage(combinedName) { |
Paul Kehrer | c033c90 | 2017-07-07 13:20:29 -0500 | [diff] [blame] | 309 | def buildImage = docker.image(imageName) |
| 310 | buildImage.pull() |
| 311 | buildImage.inside { |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 312 | build(toxenv, label, imageName, artifacts, artifactExcludes) |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 313 | } |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | } else { |
| 318 | def combinedName = "${label}-${toxenv}" |
| 319 | builders[combinedName] = { |
| 320 | node(label) { |
| 321 | stage(combinedName) { |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 322 | build(toxenv, label, '', null, null) |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 323 | } |
| 324 | } |
| 325 | } |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | /* Add the python setup.py test builder */ |
| 331 | builders["setup.py-test"] = { |
| 332 | node("docker") { |
| 333 | stage("python setup.py test") { |
| 334 | docker.image("pyca/cryptography-runner-ubuntu-rolling").inside { |
| 335 | try { |
| 336 | checkout_git("docker") |
| 337 | sh """#!/usr/bin/env bash |
| 338 | set -xe |
| 339 | cd cryptography |
| 340 | virtualenv .venv |
| 341 | source .venv/bin/activate |
| 342 | python setup.py test |
| 343 | """ |
| 344 | } finally { |
| 345 | deleteDir() |
| 346 | } |
| 347 | |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | parallel builders |
| 354 | |
| 355 | def downstreamBuilders = [:] |
| 356 | for (downstream in downstreams) { |
| 357 | def downstreamName = downstream["downstreamName"] |
| 358 | def imageName = downstream["imageName"] |
| 359 | def label = downstream["label"] |
| 360 | def script = downstream["script"] |
| 361 | downstreamBuilders[downstreamName] = { |
| 362 | node(label) { |
| 363 | docker.image(imageName).inside { |
| 364 | try { |
| 365 | timeout(time: 30, unit: 'MINUTES') { |
| 366 | checkout_git(label) |
| 367 | sh script |
| 368 | } |
| 369 | } finally { |
| 370 | deleteDir() |
| 371 | } |
| 372 | } |
| 373 | } |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | stage("Downstreams") { |
| 378 | parallel downstreamBuilders |
| 379 | } |