blob: 816e9de84ba80179912910e251107338c909baec [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 [
15 label: 'freebsd11',
16 toxenvs: ['py27'],
17 ],
18 [
19 label: 'sierra',
Paul Kehrer90375552017-09-20 20:49:03 +080020 toxenvs: ['py27', 'py36'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070021 ],
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',
Alex Gaynor70639ed2017-07-08 11:53:58 -040043 imageName: 'pyca/cryptography-runner-stretch',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070044 toxenvs: ['py27', 'py35'],
45 ],
46 [
47 label: 'docker',
Alex Gaynor70639ed2017-07-08 11:53:58 -040048 imageName: 'pyca/cryptography-runner-buster',
Alex Gaynor20128c72017-10-28 19:16:49 -040049 toxenvs: ['py27', 'py36'],
Alex Gaynor70639ed2017-07-08 11:53:58 -040050 ],
51 [
52 label: 'docker',
53 imageName: 'pyca/cryptography-runner-sid',
Alex Gaynora87daea2017-10-11 21:36:30 -040054 toxenvs: ['py27', 'py36'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070055 ],
56 [
57 label: 'docker',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070058 imageName: 'pyca/cryptography-runner-ubuntu-xenial',
59 toxenvs: ['py27', 'py35'],
60 ],
61 [
62 label: 'docker',
63 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
Alex Gaynorf2a03332017-10-21 09:13:42 -040064 toxenvs: ['py27', 'py36', 'randomorder'],
Alex Gaynor40226372017-05-23 14:14:18 -070065 ],
66 [
67 label: 'docker',
Paul Kehrer6bdae782017-06-06 08:45:01 -100068 imageName: 'pyca/cryptography-runner-sid',
Alex Gaynor40226372017-05-23 14:14:18 -070069 toxenvs: ['docs'],
70 artifacts: 'cryptography/docs/_build/html/**',
71 artifactExcludes: '**/*.doctree',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070072 ],
73 [
74 label: 'docker',
75 imageName: 'pyca/cryptography-runner-fedora',
Alex Gaynor2e64a3f2017-07-13 08:30:24 -040076 toxenvs: ['py27', 'py36'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070077 ],
Paul Kehrer8c0e7312017-06-25 12:22:07 -100078 [
79 label: 'docker',
80 imageName: 'pyca/cryptography-runner-alpine:latest',
81 toxenvs: ['py36'],
82 ],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070083]
84
85/* Add the linkcheck job to our config list if we're on master */
86if (env.BRANCH_NAME == "master") {
87 configs.add(
88 [
89 label: 'docker',
Paul Kehrer6bdae782017-06-06 08:45:01 -100090 imageName: 'pyca/cryptography-runner-sid',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070091 toxenvs: ['docs-linkcheck'],
92 ]
93 )
94}
95
Paul Kehrerba58e1f2017-05-22 18:08:29 -070096def checkout_git(label) {
Alex Gaynor42b25712017-06-03 12:04:32 -040097 retry(3) {
98 def script = ""
99 if (env.BRANCH_NAME.startsWith('PR-')) {
100 script = """
101 git clone --depth=1 https://github.com/pyca/cryptography
102 cd cryptography
103 git fetch origin +refs/pull/${env.CHANGE_ID}/merge:
104 git checkout -qf FETCH_HEAD
Paul Kehrera119d2e2017-05-23 22:02:50 -0700105 """
Alex Gaynor42b25712017-06-03 12:04:32 -0400106 if (label.contains("windows")) {
107 bat script
108 } else {
109 sh """#!/bin/sh
110 set -xe
111 ${script}
112 """
113 }
114 } else {
115 checkout([
116 $class: 'GitSCM',
117 branches: [[name: "*/${env.BRANCH_NAME}"]],
118 doGenerateSubmoduleConfigurations: false,
119 extensions: [[
120 $class: 'RelativeTargetDirectory',
121 relativeTargetDir: 'cryptography'
122 ]],
123 submoduleCfg: [],
124 userRemoteConfigs: [[
125 'url': 'https://github.com/pyca/cryptography'
126 ]]
127 ])
Paul Kehrera119d2e2017-05-23 22:02:50 -0700128 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700129 }
130 if (label.contains("windows")) {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700131 bat """
132 cd cryptography
133 git rev-parse HEAD
134 """
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700135 } else {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700136 sh """
137 cd cryptography
138 git rev-parse HEAD
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700139 """
140 }
141}
Alex Gaynor40226372017-05-23 14:14:18 -0700142def build(toxenv, label, imageName, artifacts, artifactExcludes) {
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700143 try {
144 timeout(time: 30, unit: 'MINUTES') {
145
146 checkout_git(label)
Alex Gaynor2e85a922018-07-16 11:18:33 -0400147 checkout([
148 $class: 'GitSCM',
149 extensions: [[
150 $class: 'RelativeTargetDirectory',
151 relativeTargetDir: 'wycheproof',
152 ]],
153 userRemoteConfigs: [[
154 'url': 'https://github.com/google/wycheproof',
155 ]]
156 ])
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700157
158 withCredentials([string(credentialsId: 'cryptography-codecov-token', variable: 'CODECOV_TOKEN')]) {
159 withEnv(["LABEL=$label", "TOXENV=$toxenv", "IMAGE_NAME=$imageName"]) {
160 if (label.contains("windows")) {
161 def pythonPath = [
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700162 py27: "C:\\Python27\\python.exe",
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700163 py34: "C:\\Python34\\python.exe",
164 py35: "C:\\Python35\\python.exe",
Paul Kehrer4ee1cb92018-06-27 20:07:14 -0700165 py36: "C:\\Python36\\python.exe",
166 py37: "C:\\Python37\\python.exe"
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700167 ]
Paul Kehrer4ee1cb92018-06-27 20:07:14 -0700168 if (toxenv == "py35" || toxenv == "py36" || toxenv == "py37") {
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700169 opensslPaths = [
170 "windows": [
171 "include": "C:\\OpenSSL-Win32-2015\\include",
172 "lib": "C:\\OpenSSL-Win32-2015\\lib"
173 ],
174 "windows64": [
175 "include": "C:\\OpenSSL-Win64-2015\\include",
176 "lib": "C:\\OpenSSL-Win64-2015\\lib"
177 ]
178 ]
179 } else {
180 opensslPaths = [
181 "windows": [
182 "include": "C:\\OpenSSL-Win32-2010\\include",
183 "lib": "C:\\OpenSSL-Win32-2010\\lib"
184 ],
185 "windows64": [
186 "include": "C:\\OpenSSL-Win64-2010\\include",
187 "lib": "C:\\OpenSSL-Win64-2010\\lib"
188 ]
189 ]
190 }
191 bat """
192 cd cryptography
193 @set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH%
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700194 @set PYTHON="${pythonPath[toxenv]}"
195
196 @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE%
197 @set LIB="${opensslPaths[label]['lib']}";%LIB%
Alex Gaynor2e85a922018-07-16 11:18:33 -0400198 tox -r -- --wycheproof-root=../wycheproof
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700199 IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
200 virtualenv .codecov
201 call .codecov/Scripts/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800202 REM this pin must be kept in sync with tox.ini
Paul Kehrercb175062017-06-03 08:26:56 -1000203 pip install coverage==4.3.4
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700204 pip install codecov
Paul Kehrer8396d432017-09-06 23:23:15 +0800205 codecov -e JOB_BASE_NAME,LABEL,TOXENV
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700206 """
207 } else if (label.contains("sierra") || label.contains("yosemite")) {
208 ansiColor {
209 sh """#!/usr/bin/env bash
210 set -xe
211 # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH
212 export PATH="/usr/local/bin:\${PATH}"
213 export PATH="/Users/jenkins/.pyenv/shims:\${PATH}"
214 cd cryptography
Paul Kehreradeaacf2017-05-24 12:49:18 -0700215 CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 \
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700216 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 -0500217 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 -0400218 tox -r -- --color=yes --wycheproof-root=../wycheproof
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700219 virtualenv .venv
220 source .venv/bin/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800221 # This pin must be kept in sync with tox.ini
Paul Kehrercb175062017-06-03 08:26:56 -1000222 pip install coverage==4.3.4
Paul Kehrer8396d432017-09-06 23:23:15 +0800223 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700224 """
225 }
226 } else {
227 ansiColor {
228 sh """#!/usr/bin/env bash
229 set -xe
230 cd cryptography
Alex Gaynor2e85a922018-07-16 11:18:33 -0400231 tox -r -- --color=yes --wycheproof-root=../wycheproof
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700232 virtualenv .venv
233 source .venv/bin/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800234 # This pin must be kept in sync with tox.ini
Alex Gaynoraf3f9b82018-04-20 00:29:28 -0400235 pip install coverage==4.3.4
Paul Kehrer8396d432017-09-06 23:23:15 +0800236 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV,IMAGE_NAME
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700237 """
238 }
Alex Gaynor40226372017-05-23 14:14:18 -0700239 if (artifacts) {
240 archiveArtifacts artifacts: artifacts, excludes: artifactExcludes
241 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700242 }
243 }
244 }
245 }
246 } finally {
247 deleteDir()
248 }
249
250}
251
252def builders = [:]
253for (config in configs) {
254 def label = config["label"]
255 def toxenvs = config["toxenvs"]
Alex Gaynor40226372017-05-23 14:14:18 -0700256 def artifacts = config["artifacts"]
257 def artifactExcludes = config["artifactExcludes"]
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700258
259 for (_toxenv in toxenvs) {
260 def toxenv = _toxenv
261
262 if (label.contains("docker")) {
263 def imageName = config["imageName"]
264 def combinedName = "${imageName}-${toxenv}"
265 builders[combinedName] = {
266 node(label) {
267 stage(combinedName) {
Paul Kehrerc033c902017-07-07 13:20:29 -0500268 def buildImage = docker.image(imageName)
269 buildImage.pull()
270 buildImage.inside {
Alex Gaynor40226372017-05-23 14:14:18 -0700271 build(toxenv, label, imageName, artifacts, artifactExcludes)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700272 }
273 }
274 }
275 }
276 } else {
277 def combinedName = "${label}-${toxenv}"
278 builders[combinedName] = {
279 node(label) {
280 stage(combinedName) {
Alex Gaynor40226372017-05-23 14:14:18 -0700281 build(toxenv, label, '', null, null)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700282 }
283 }
284 }
285 }
286 }
287}
288
289/* Add the python setup.py test builder */
290builders["setup.py-test"] = {
291 node("docker") {
292 stage("python setup.py test") {
293 docker.image("pyca/cryptography-runner-ubuntu-rolling").inside {
294 try {
295 checkout_git("docker")
296 sh """#!/usr/bin/env bash
297 set -xe
298 cd cryptography
299 virtualenv .venv
300 source .venv/bin/activate
301 python setup.py test
302 """
303 } finally {
304 deleteDir()
305 }
306
307 }
308 }
309 }
310}
311
Paul Kehrer3d96afd2017-10-04 10:53:18 +0800312parallel builders