blob: f89728f3a8d253d93724a3ea338e4dd8d25c92f4 [file] [log] [blame]
Paul Kehrerba58e1f2017-05-22 18:08:29 -07001if (env.BRANCH_NAME == "master") {
2 properties([pipelineTriggers([cron('@daily')])])
3}
4
5def configs = [
6 [
7 label: 'windows',
Paul Kehrer4ee1cb92018-06-27 20:07:14 -07008 toxenvs: ['py27', 'py34', 'py35', 'py36', 'py37'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -07009 ],
10 [
11 label: 'windows64',
Paul Kehrer4ee1cb92018-06-27 20:07:14 -070012 toxenvs: ['py27', 'py34', 'py35', 'py36', 'py37'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070013 ],
14 [
Paul Kehrerba58e1f2017-05-22 18:08:29 -070015 label: 'sierra',
Paul Kehrer90375552017-09-20 20:49:03 +080016 toxenvs: ['py27', 'py36'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070017 ],
18 [
19 label: 'yosemite',
20 toxenvs: ['py27'],
21 ],
22 [
23 label: 'docker',
24 imageName: 'pyca/cryptography-runner-centos7',
25 toxenvs: ['py27'],
26 ],
27 [
28 label: 'docker',
29 imageName: 'pyca/cryptography-runner-wheezy',
30 toxenvs: ['py27'],
31 ],
32 [
33 label: 'docker',
34 imageName: 'pyca/cryptography-runner-jessie',
35 toxenvs: ['py27', 'py34'],
36 ],
37 [
38 label: 'docker',
Alex Gaynor70639ed2017-07-08 11:53:58 -040039 imageName: 'pyca/cryptography-runner-stretch',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070040 toxenvs: ['py27', 'py35'],
41 ],
42 [
43 label: 'docker',
Alex Gaynor70639ed2017-07-08 11:53:58 -040044 imageName: 'pyca/cryptography-runner-buster',
Alex Gaynor20128c72017-10-28 19:16:49 -040045 toxenvs: ['py27', 'py36'],
Alex Gaynor70639ed2017-07-08 11:53:58 -040046 ],
47 [
48 label: 'docker',
49 imageName: 'pyca/cryptography-runner-sid',
Alex Gaynora87daea2017-10-11 21:36:30 -040050 toxenvs: ['py27', 'py36'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070051 ],
52 [
53 label: 'docker',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070054 imageName: 'pyca/cryptography-runner-ubuntu-xenial',
55 toxenvs: ['py27', 'py35'],
56 ],
57 [
58 label: 'docker',
59 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
Alex Gaynorf2a03332017-10-21 09:13:42 -040060 toxenvs: ['py27', 'py36', 'randomorder'],
Alex Gaynor40226372017-05-23 14:14:18 -070061 ],
62 [
63 label: 'docker',
Paul Kehrer6bdae782017-06-06 08:45:01 -100064 imageName: 'pyca/cryptography-runner-sid',
Alex Gaynor40226372017-05-23 14:14:18 -070065 toxenvs: ['docs'],
66 artifacts: 'cryptography/docs/_build/html/**',
67 artifactExcludes: '**/*.doctree',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070068 ],
69 [
70 label: 'docker',
71 imageName: 'pyca/cryptography-runner-fedora',
Alex Gaynor2e64a3f2017-07-13 08:30:24 -040072 toxenvs: ['py27', 'py36'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070073 ],
Paul Kehrer8c0e7312017-06-25 12:22:07 -100074 [
75 label: 'docker',
76 imageName: 'pyca/cryptography-runner-alpine:latest',
77 toxenvs: ['py36'],
78 ],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070079]
80
81/* Add the linkcheck job to our config list if we're on master */
82if (env.BRANCH_NAME == "master") {
83 configs.add(
84 [
85 label: 'docker',
Alex Gaynor378a2672018-08-30 18:04:57 -040086 imageName: 'pyca/cryptography-runner-buster',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070087 toxenvs: ['docs-linkcheck'],
88 ]
89 )
90}
91
Paul Kehrerba58e1f2017-05-22 18:08:29 -070092def checkout_git(label) {
Alex Gaynor42b25712017-06-03 12:04:32 -040093 retry(3) {
94 def script = ""
95 if (env.BRANCH_NAME.startsWith('PR-')) {
96 script = """
97 git clone --depth=1 https://github.com/pyca/cryptography
98 cd cryptography
99 git fetch origin +refs/pull/${env.CHANGE_ID}/merge:
100 git checkout -qf FETCH_HEAD
Paul Kehrera119d2e2017-05-23 22:02:50 -0700101 """
Alex Gaynor42b25712017-06-03 12:04:32 -0400102 if (label.contains("windows")) {
103 bat script
104 } else {
105 sh """#!/bin/sh
106 set -xe
107 ${script}
108 """
109 }
110 } else {
111 checkout([
112 $class: 'GitSCM',
113 branches: [[name: "*/${env.BRANCH_NAME}"]],
114 doGenerateSubmoduleConfigurations: false,
115 extensions: [[
116 $class: 'RelativeTargetDirectory',
117 relativeTargetDir: 'cryptography'
118 ]],
119 submoduleCfg: [],
120 userRemoteConfigs: [[
121 'url': 'https://github.com/pyca/cryptography'
122 ]]
123 ])
Paul Kehrera119d2e2017-05-23 22:02:50 -0700124 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700125 }
126 if (label.contains("windows")) {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700127 bat """
128 cd cryptography
129 git rev-parse HEAD
130 """
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700131 } else {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700132 sh """
133 cd cryptography
134 git rev-parse HEAD
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700135 """
136 }
137}
Alex Gaynor40226372017-05-23 14:14:18 -0700138def build(toxenv, label, imageName, artifacts, artifactExcludes) {
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700139 try {
140 timeout(time: 30, unit: 'MINUTES') {
141
142 checkout_git(label)
Alex Gaynor2e85a922018-07-16 11:18:33 -0400143 checkout([
144 $class: 'GitSCM',
145 extensions: [[
146 $class: 'RelativeTargetDirectory',
147 relativeTargetDir: 'wycheproof',
148 ]],
149 userRemoteConfigs: [[
150 'url': 'https://github.com/google/wycheproof',
151 ]]
152 ])
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700153
154 withCredentials([string(credentialsId: 'cryptography-codecov-token', variable: 'CODECOV_TOKEN')]) {
155 withEnv(["LABEL=$label", "TOXENV=$toxenv", "IMAGE_NAME=$imageName"]) {
156 if (label.contains("windows")) {
157 def pythonPath = [
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700158 py27: "C:\\Python27\\python.exe",
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700159 py34: "C:\\Python34\\python.exe",
160 py35: "C:\\Python35\\python.exe",
Paul Kehrer4ee1cb92018-06-27 20:07:14 -0700161 py36: "C:\\Python36\\python.exe",
162 py37: "C:\\Python37\\python.exe"
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700163 ]
Paul Kehrer4ee1cb92018-06-27 20:07:14 -0700164 if (toxenv == "py35" || toxenv == "py36" || toxenv == "py37") {
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700165 opensslPaths = [
166 "windows": [
167 "include": "C:\\OpenSSL-Win32-2015\\include",
168 "lib": "C:\\OpenSSL-Win32-2015\\lib"
169 ],
170 "windows64": [
171 "include": "C:\\OpenSSL-Win64-2015\\include",
172 "lib": "C:\\OpenSSL-Win64-2015\\lib"
173 ]
174 ]
175 } else {
176 opensslPaths = [
177 "windows": [
178 "include": "C:\\OpenSSL-Win32-2010\\include",
179 "lib": "C:\\OpenSSL-Win32-2010\\lib"
180 ],
181 "windows64": [
182 "include": "C:\\OpenSSL-Win64-2010\\include",
183 "lib": "C:\\OpenSSL-Win64-2010\\lib"
184 ]
185 ]
186 }
187 bat """
188 cd cryptography
189 @set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH%
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700190 @set PYTHON="${pythonPath[toxenv]}"
191
192 @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE%
193 @set LIB="${opensslPaths[label]['lib']}";%LIB%
Alex Gaynor2e85a922018-07-16 11:18:33 -0400194 tox -r -- --wycheproof-root=../wycheproof
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700195 IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
196 virtualenv .codecov
197 call .codecov/Scripts/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800198 REM this pin must be kept in sync with tox.ini
Paul Kehrer636ad602018-09-04 09:45:17 -0500199 pip install coverage
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700200 pip install codecov
Paul Kehrer8396d432017-09-06 23:23:15 +0800201 codecov -e JOB_BASE_NAME,LABEL,TOXENV
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700202 """
203 } else if (label.contains("sierra") || label.contains("yosemite")) {
204 ansiColor {
205 sh """#!/usr/bin/env bash
206 set -xe
207 # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH
208 export PATH="/usr/local/bin:\${PATH}"
209 export PATH="/Users/jenkins/.pyenv/shims:\${PATH}"
210 cd cryptography
Paul Kehreradeaacf2017-05-24 12:49:18 -0700211 CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 \
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700212 LDFLAGS="/usr/local/opt/openssl\\@1.1/lib/libcrypto.a /usr/local/opt/openssl\\@1.1/lib/libssl.a" \
Paul Kehrerb637aec2017-05-30 20:56:15 -0500213 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" \
Alex Gaynor2e85a922018-07-16 11:18:33 -0400214 tox -r -- --color=yes --wycheproof-root=../wycheproof
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700215 virtualenv .venv
216 source .venv/bin/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800217 # This pin must be kept in sync with tox.ini
Paul Kehrer636ad602018-09-04 09:45:17 -0500218 pip install coverage
Paul Kehrer8396d432017-09-06 23:23:15 +0800219 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700220 """
221 }
222 } else {
223 ansiColor {
224 sh """#!/usr/bin/env bash
225 set -xe
226 cd cryptography
Alex Gaynor2e85a922018-07-16 11:18:33 -0400227 tox -r -- --color=yes --wycheproof-root=../wycheproof
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700228 virtualenv .venv
229 source .venv/bin/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800230 # This pin must be kept in sync with tox.ini
Paul Kehrer636ad602018-09-04 09:45:17 -0500231 pip install coverage
Paul Kehrer8396d432017-09-06 23:23:15 +0800232 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV,IMAGE_NAME
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700233 """
234 }
Alex Gaynor40226372017-05-23 14:14:18 -0700235 if (artifacts) {
236 archiveArtifacts artifacts: artifacts, excludes: artifactExcludes
237 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700238 }
239 }
240 }
241 }
242 } finally {
243 deleteDir()
244 }
245
246}
247
248def builders = [:]
249for (config in configs) {
250 def label = config["label"]
251 def toxenvs = config["toxenvs"]
Alex Gaynor40226372017-05-23 14:14:18 -0700252 def artifacts = config["artifacts"]
253 def artifactExcludes = config["artifactExcludes"]
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700254
255 for (_toxenv in toxenvs) {
256 def toxenv = _toxenv
257
258 if (label.contains("docker")) {
259 def imageName = config["imageName"]
260 def combinedName = "${imageName}-${toxenv}"
261 builders[combinedName] = {
262 node(label) {
263 stage(combinedName) {
Paul Kehrerc033c902017-07-07 13:20:29 -0500264 def buildImage = docker.image(imageName)
265 buildImage.pull()
266 buildImage.inside {
Alex Gaynor40226372017-05-23 14:14:18 -0700267 build(toxenv, label, imageName, artifacts, artifactExcludes)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700268 }
269 }
270 }
271 }
272 } else {
273 def combinedName = "${label}-${toxenv}"
274 builders[combinedName] = {
275 node(label) {
276 stage(combinedName) {
Alex Gaynor40226372017-05-23 14:14:18 -0700277 build(toxenv, label, '', null, null)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700278 }
279 }
280 }
281 }
282 }
283}
284
285/* Add the python setup.py test builder */
286builders["setup.py-test"] = {
287 node("docker") {
288 stage("python setup.py test") {
289 docker.image("pyca/cryptography-runner-ubuntu-rolling").inside {
290 try {
291 checkout_git("docker")
292 sh """#!/usr/bin/env bash
293 set -xe
294 cd cryptography
295 virtualenv .venv
296 source .venv/bin/activate
297 python setup.py test
298 """
299 } finally {
300 deleteDir()
301 }
302
303 }
304 }
305 }
306}
307
Paul Kehrer3d96afd2017-10-04 10:53:18 +0800308parallel builders