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 | 4ee1cb9 | 2018-06-27 20:07:14 -0700 | [diff] [blame] | 8 | toxenvs: ['py27', 'py34', 'py35', 'py36', 'py37'], |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 9 | ], |
| 10 | [ |
| 11 | label: 'windows64', |
Paul Kehrer | 4ee1cb9 | 2018-06-27 20:07:14 -0700 | [diff] [blame] | 12 | toxenvs: ['py27', 'py34', 'py35', 'py36', 'py37'], |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 13 | ], |
| 14 | [ |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 15 | label: 'sierra', |
Paul Kehrer | 9037555 | 2017-09-20 20:49:03 +0800 | [diff] [blame] | 16 | toxenvs: ['py27', 'py36'], |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 17 | ], |
| 18 | [ |
| 19 | label: 'yosemite', |
| 20 | toxenvs: ['py27'], |
| 21 | ], |
| 22 | [ |
| 23 | label: 'docker', |
Paul Kehrer | 6bdae78 | 2017-06-06 08:45:01 -1000 | [diff] [blame] | 24 | imageName: 'pyca/cryptography-runner-sid', |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 25 | toxenvs: ['docs'], |
| 26 | artifacts: 'cryptography/docs/_build/html/**', |
| 27 | artifactExcludes: '**/*.doctree', |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 28 | ], |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 29 | ] |
| 30 | |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 31 | def checkout_git(label) { |
Alex Gaynor | 42b2571 | 2017-06-03 12:04:32 -0400 | [diff] [blame] | 32 | retry(3) { |
| 33 | def script = "" |
| 34 | if (env.BRANCH_NAME.startsWith('PR-')) { |
| 35 | script = """ |
| 36 | git clone --depth=1 https://github.com/pyca/cryptography |
| 37 | cd cryptography |
| 38 | git fetch origin +refs/pull/${env.CHANGE_ID}/merge: |
| 39 | git checkout -qf FETCH_HEAD |
Paul Kehrer | a119d2e | 2017-05-23 22:02:50 -0700 | [diff] [blame] | 40 | """ |
Alex Gaynor | 42b2571 | 2017-06-03 12:04:32 -0400 | [diff] [blame] | 41 | if (label.contains("windows")) { |
| 42 | bat script |
| 43 | } else { |
| 44 | sh """#!/bin/sh |
| 45 | set -xe |
| 46 | ${script} |
| 47 | """ |
| 48 | } |
| 49 | } else { |
| 50 | checkout([ |
| 51 | $class: 'GitSCM', |
| 52 | branches: [[name: "*/${env.BRANCH_NAME}"]], |
| 53 | doGenerateSubmoduleConfigurations: false, |
| 54 | extensions: [[ |
| 55 | $class: 'RelativeTargetDirectory', |
| 56 | relativeTargetDir: 'cryptography' |
| 57 | ]], |
| 58 | submoduleCfg: [], |
| 59 | userRemoteConfigs: [[ |
| 60 | 'url': 'https://github.com/pyca/cryptography' |
| 61 | ]] |
| 62 | ]) |
Paul Kehrer | a119d2e | 2017-05-23 22:02:50 -0700 | [diff] [blame] | 63 | } |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 64 | } |
| 65 | if (label.contains("windows")) { |
Paul Kehrer | a119d2e | 2017-05-23 22:02:50 -0700 | [diff] [blame] | 66 | bat """ |
| 67 | cd cryptography |
| 68 | git rev-parse HEAD |
| 69 | """ |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 70 | } else { |
Paul Kehrer | a119d2e | 2017-05-23 22:02:50 -0700 | [diff] [blame] | 71 | sh """ |
| 72 | cd cryptography |
| 73 | git rev-parse HEAD |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 74 | """ |
| 75 | } |
| 76 | } |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 77 | def build(toxenv, label, imageName, artifacts, artifactExcludes) { |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 78 | try { |
| 79 | timeout(time: 30, unit: 'MINUTES') { |
| 80 | |
| 81 | checkout_git(label) |
Alex Gaynor | 2e85a92 | 2018-07-16 11:18:33 -0400 | [diff] [blame] | 82 | checkout([ |
| 83 | $class: 'GitSCM', |
| 84 | extensions: [[ |
| 85 | $class: 'RelativeTargetDirectory', |
| 86 | relativeTargetDir: 'wycheproof', |
| 87 | ]], |
| 88 | userRemoteConfigs: [[ |
| 89 | 'url': 'https://github.com/google/wycheproof', |
| 90 | ]] |
| 91 | ]) |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 92 | |
| 93 | withCredentials([string(credentialsId: 'cryptography-codecov-token', variable: 'CODECOV_TOKEN')]) { |
| 94 | withEnv(["LABEL=$label", "TOXENV=$toxenv", "IMAGE_NAME=$imageName"]) { |
| 95 | if (label.contains("windows")) { |
| 96 | def pythonPath = [ |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 97 | py27: "C:\\Python27\\python.exe", |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 98 | py34: "C:\\Python34\\python.exe", |
| 99 | py35: "C:\\Python35\\python.exe", |
Paul Kehrer | 4ee1cb9 | 2018-06-27 20:07:14 -0700 | [diff] [blame] | 100 | py36: "C:\\Python36\\python.exe", |
| 101 | py37: "C:\\Python37\\python.exe" |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 102 | ] |
Paul Kehrer | 4ee1cb9 | 2018-06-27 20:07:14 -0700 | [diff] [blame] | 103 | if (toxenv == "py35" || toxenv == "py36" || toxenv == "py37") { |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 104 | opensslPaths = [ |
| 105 | "windows": [ |
| 106 | "include": "C:\\OpenSSL-Win32-2015\\include", |
| 107 | "lib": "C:\\OpenSSL-Win32-2015\\lib" |
| 108 | ], |
| 109 | "windows64": [ |
| 110 | "include": "C:\\OpenSSL-Win64-2015\\include", |
| 111 | "lib": "C:\\OpenSSL-Win64-2015\\lib" |
| 112 | ] |
| 113 | ] |
| 114 | } else { |
| 115 | opensslPaths = [ |
| 116 | "windows": [ |
| 117 | "include": "C:\\OpenSSL-Win32-2010\\include", |
| 118 | "lib": "C:\\OpenSSL-Win32-2010\\lib" |
| 119 | ], |
| 120 | "windows64": [ |
| 121 | "include": "C:\\OpenSSL-Win64-2010\\include", |
| 122 | "lib": "C:\\OpenSSL-Win64-2010\\lib" |
| 123 | ] |
| 124 | ] |
| 125 | } |
| 126 | bat """ |
| 127 | cd cryptography |
| 128 | @set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH% |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 129 | @set PYTHON="${pythonPath[toxenv]}" |
| 130 | |
| 131 | @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE% |
| 132 | @set LIB="${opensslPaths[label]['lib']}";%LIB% |
Alex Gaynor | 2e85a92 | 2018-07-16 11:18:33 -0400 | [diff] [blame] | 133 | tox -r -- --wycheproof-root=../wycheproof |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 134 | IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% |
| 135 | virtualenv .codecov |
| 136 | call .codecov/Scripts/activate |
Paul Kehrer | e535985 | 2017-09-13 09:30:51 +0800 | [diff] [blame] | 137 | REM this pin must be kept in sync with tox.ini |
Paul Kehrer | 636ad60 | 2018-09-04 09:45:17 -0500 | [diff] [blame] | 138 | pip install coverage |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 139 | pip install codecov |
Paul Kehrer | 8396d43 | 2017-09-06 23:23:15 +0800 | [diff] [blame] | 140 | codecov -e JOB_BASE_NAME,LABEL,TOXENV |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 141 | """ |
| 142 | } else if (label.contains("sierra") || label.contains("yosemite")) { |
| 143 | ansiColor { |
| 144 | sh """#!/usr/bin/env bash |
| 145 | set -xe |
| 146 | # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH |
| 147 | export PATH="/usr/local/bin:\${PATH}" |
| 148 | export PATH="/Users/jenkins/.pyenv/shims:\${PATH}" |
| 149 | cd cryptography |
Paul Kehrer | adeaacf | 2017-05-24 12:49:18 -0700 | [diff] [blame] | 150 | CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 \ |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 151 | LDFLAGS="/usr/local/opt/openssl\\@1.1/lib/libcrypto.a /usr/local/opt/openssl\\@1.1/lib/libssl.a" \ |
Paul Kehrer | f88aea5 | 2018-09-05 21:44:29 -0500 | [diff] [blame] | 152 | CFLAGS="-I/usr/local/opt/openssl\\@1.1/include -Werror -Wno-error=deprecated-declarations -Wno-error=incompatible-pointer-types-discards-qualifiers -Wno-error=unused-function -Wno-error=unused-command-line-argument -mmacosx-version-min=10.9" \ |
Alex Gaynor | 2e85a92 | 2018-07-16 11:18:33 -0400 | [diff] [blame] | 153 | tox -r -- --color=yes --wycheproof-root=../wycheproof |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 154 | virtualenv .venv |
| 155 | source .venv/bin/activate |
Paul Kehrer | e535985 | 2017-09-13 09:30:51 +0800 | [diff] [blame] | 156 | # This pin must be kept in sync with tox.ini |
Paul Kehrer | 636ad60 | 2018-09-04 09:45:17 -0500 | [diff] [blame] | 157 | pip install coverage |
Paul Kehrer | 8396d43 | 2017-09-06 23:23:15 +0800 | [diff] [blame] | 158 | 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] | 159 | """ |
| 160 | } |
| 161 | } else { |
| 162 | ansiColor { |
| 163 | sh """#!/usr/bin/env bash |
| 164 | set -xe |
| 165 | cd cryptography |
Alex Gaynor | 2e85a92 | 2018-07-16 11:18:33 -0400 | [diff] [blame] | 166 | tox -r -- --color=yes --wycheproof-root=../wycheproof |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 167 | virtualenv .venv |
| 168 | source .venv/bin/activate |
Paul Kehrer | e535985 | 2017-09-13 09:30:51 +0800 | [diff] [blame] | 169 | # This pin must be kept in sync with tox.ini |
Paul Kehrer | 636ad60 | 2018-09-04 09:45:17 -0500 | [diff] [blame] | 170 | pip install coverage |
Paul Kehrer | 8396d43 | 2017-09-06 23:23:15 +0800 | [diff] [blame] | 171 | 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] | 172 | """ |
| 173 | } |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 174 | if (artifacts) { |
| 175 | archiveArtifacts artifacts: artifacts, excludes: artifactExcludes |
| 176 | } |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 177 | } |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 | } finally { |
| 182 | deleteDir() |
| 183 | } |
| 184 | |
| 185 | } |
| 186 | |
| 187 | def builders = [:] |
| 188 | for (config in configs) { |
| 189 | def label = config["label"] |
| 190 | def toxenvs = config["toxenvs"] |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 191 | def artifacts = config["artifacts"] |
| 192 | def artifactExcludes = config["artifactExcludes"] |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 193 | |
| 194 | for (_toxenv in toxenvs) { |
| 195 | def toxenv = _toxenv |
| 196 | |
| 197 | if (label.contains("docker")) { |
| 198 | def imageName = config["imageName"] |
| 199 | def combinedName = "${imageName}-${toxenv}" |
| 200 | builders[combinedName] = { |
| 201 | node(label) { |
| 202 | stage(combinedName) { |
Paul Kehrer | c033c90 | 2017-07-07 13:20:29 -0500 | [diff] [blame] | 203 | def buildImage = docker.image(imageName) |
| 204 | buildImage.pull() |
| 205 | buildImage.inside { |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 206 | build(toxenv, label, imageName, artifacts, artifactExcludes) |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 207 | } |
| 208 | } |
| 209 | } |
| 210 | } |
| 211 | } else { |
| 212 | def combinedName = "${label}-${toxenv}" |
| 213 | builders[combinedName] = { |
| 214 | node(label) { |
| 215 | stage(combinedName) { |
Alex Gaynor | 4022637 | 2017-05-23 14:14:18 -0700 | [diff] [blame] | 216 | build(toxenv, label, '', null, null) |
Paul Kehrer | ba58e1f | 2017-05-22 18:08:29 -0700 | [diff] [blame] | 217 | } |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | /* Add the python setup.py test builder */ |
| 225 | builders["setup.py-test"] = { |
| 226 | node("docker") { |
| 227 | stage("python setup.py test") { |
| 228 | docker.image("pyca/cryptography-runner-ubuntu-rolling").inside { |
| 229 | try { |
| 230 | checkout_git("docker") |
| 231 | sh """#!/usr/bin/env bash |
| 232 | set -xe |
| 233 | cd cryptography |
| 234 | virtualenv .venv |
| 235 | source .venv/bin/activate |
| 236 | python setup.py test |
| 237 | """ |
| 238 | } finally { |
| 239 | deleteDir() |
| 240 | } |
| 241 | |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | } |
| 246 | |
Paul Kehrer | 3d96afd | 2017-10-04 10:53:18 +0800 | [diff] [blame] | 247 | parallel builders |