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