blob: 44e9ab9b275cfd0bbee704d9dd0587191fd698e9 [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 Kehrer4cf6e782017-10-12 06:06:01 +08008 toxenvs: ['py27', 'py34', 'py35', 'py36'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -07009 ],
10 [
11 label: 'windows64',
Paul Kehrer4cf6e782017-10-12 06:06:01 +080012 toxenvs: ['py27', 'py34', 'py35', 'py36'],
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',
58 imageName: 'pyca/cryptography-runner-jessie-libressl:2.4.5',
59 toxenvs: ['py27'],
60 ],
61 [
62 label: 'docker',
Alex Gaynor24bb7a02017-12-25 13:49:48 -050063 imageName: 'pyca/cryptography-runner-jessie-libressl:2.6.4',
Alex Gaynor45f2a422017-07-26 09:10:32 -040064 toxenvs: ['py27'],
65 ],
66 [
67 label: 'docker',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070068 imageName: 'pyca/cryptography-runner-ubuntu-xenial',
69 toxenvs: ['py27', 'py35'],
70 ],
71 [
72 label: 'docker',
73 imageName: 'pyca/cryptography-runner-ubuntu-rolling',
Alex Gaynorf2a03332017-10-21 09:13:42 -040074 toxenvs: ['py27', 'py36', 'randomorder'],
Alex Gaynor40226372017-05-23 14:14:18 -070075 ],
76 [
77 label: 'docker',
Paul Kehrer6bdae782017-06-06 08:45:01 -100078 imageName: 'pyca/cryptography-runner-sid',
Alex Gaynor40226372017-05-23 14:14:18 -070079 toxenvs: ['docs'],
80 artifacts: 'cryptography/docs/_build/html/**',
81 artifactExcludes: '**/*.doctree',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070082 ],
83 [
84 label: 'docker',
85 imageName: 'pyca/cryptography-runner-fedora',
Alex Gaynor2e64a3f2017-07-13 08:30:24 -040086 toxenvs: ['py27', 'py36'],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070087 ],
Paul Kehrer8c0e7312017-06-25 12:22:07 -100088 [
89 label: 'docker',
90 imageName: 'pyca/cryptography-runner-alpine:latest',
91 toxenvs: ['py36'],
92 ],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070093]
94
95/* Add the linkcheck job to our config list if we're on master */
96if (env.BRANCH_NAME == "master") {
97 configs.add(
98 [
99 label: 'docker',
Paul Kehrer6bdae782017-06-06 08:45:01 -1000100 imageName: 'pyca/cryptography-runner-sid',
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700101 toxenvs: ['docs-linkcheck'],
102 ]
103 )
104}
105
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700106def checkout_git(label) {
Alex Gaynor42b25712017-06-03 12:04:32 -0400107 retry(3) {
108 def script = ""
109 if (env.BRANCH_NAME.startsWith('PR-')) {
110 script = """
111 git clone --depth=1 https://github.com/pyca/cryptography
112 cd cryptography
113 git fetch origin +refs/pull/${env.CHANGE_ID}/merge:
114 git checkout -qf FETCH_HEAD
Paul Kehrera119d2e2017-05-23 22:02:50 -0700115 """
Alex Gaynor42b25712017-06-03 12:04:32 -0400116 if (label.contains("windows")) {
117 bat script
118 } else {
119 sh """#!/bin/sh
120 set -xe
121 ${script}
122 """
123 }
124 } else {
125 checkout([
126 $class: 'GitSCM',
127 branches: [[name: "*/${env.BRANCH_NAME}"]],
128 doGenerateSubmoduleConfigurations: false,
129 extensions: [[
130 $class: 'RelativeTargetDirectory',
131 relativeTargetDir: 'cryptography'
132 ]],
133 submoduleCfg: [],
134 userRemoteConfigs: [[
135 'url': 'https://github.com/pyca/cryptography'
136 ]]
137 ])
Paul Kehrera119d2e2017-05-23 22:02:50 -0700138 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700139 }
140 if (label.contains("windows")) {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700141 bat """
142 cd cryptography
143 git rev-parse HEAD
144 """
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700145 } else {
Paul Kehrera119d2e2017-05-23 22:02:50 -0700146 sh """
147 cd cryptography
148 git rev-parse HEAD
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700149 """
150 }
151}
Alex Gaynor40226372017-05-23 14:14:18 -0700152def build(toxenv, label, imageName, artifacts, artifactExcludes) {
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700153 try {
154 timeout(time: 30, unit: 'MINUTES') {
155
156 checkout_git(label)
157
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",
165 py36: "C:\\Python36\\python.exe"
166 ]
167 if (toxenv == "py35" || toxenv == "py36") {
168 opensslPaths = [
169 "windows": [
170 "include": "C:\\OpenSSL-Win32-2015\\include",
171 "lib": "C:\\OpenSSL-Win32-2015\\lib"
172 ],
173 "windows64": [
174 "include": "C:\\OpenSSL-Win64-2015\\include",
175 "lib": "C:\\OpenSSL-Win64-2015\\lib"
176 ]
177 ]
178 } else {
179 opensslPaths = [
180 "windows": [
181 "include": "C:\\OpenSSL-Win32-2010\\include",
182 "lib": "C:\\OpenSSL-Win32-2010\\lib"
183 ],
184 "windows64": [
185 "include": "C:\\OpenSSL-Win64-2010\\include",
186 "lib": "C:\\OpenSSL-Win64-2010\\lib"
187 ]
188 ]
189 }
190 bat """
191 cd cryptography
192 @set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH%
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700193 @set PYTHON="${pythonPath[toxenv]}"
194
195 @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE%
196 @set LIB="${opensslPaths[label]['lib']}";%LIB%
197 tox -r
198 IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
199 virtualenv .codecov
200 call .codecov/Scripts/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800201 REM this pin must be kept in sync with tox.ini
Paul Kehrercb175062017-06-03 08:26:56 -1000202 pip install coverage==4.3.4
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700203 pip install codecov
Paul Kehrer8396d432017-09-06 23:23:15 +0800204 codecov -e JOB_BASE_NAME,LABEL,TOXENV
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700205 """
206 } else if (label.contains("sierra") || label.contains("yosemite")) {
207 ansiColor {
208 sh """#!/usr/bin/env bash
209 set -xe
210 # Jenkins logs in as a non-interactive shell, so we don't even have /usr/local/bin in PATH
211 export PATH="/usr/local/bin:\${PATH}"
212 export PATH="/Users/jenkins/.pyenv/shims:\${PATH}"
213 cd cryptography
Paul Kehreradeaacf2017-05-24 12:49:18 -0700214 CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 \
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700215 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 -0500216 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 Kehrerba58e1f2017-05-22 18:08:29 -0700217 tox -r -- --color=yes
218 virtualenv .venv
219 source .venv/bin/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800220 # This pin must be kept in sync with tox.ini
Paul Kehrercb175062017-06-03 08:26:56 -1000221 pip install coverage==4.3.4
Paul Kehrer8396d432017-09-06 23:23:15 +0800222 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700223 """
224 }
225 } else {
226 ansiColor {
227 sh """#!/usr/bin/env bash
228 set -xe
229 cd cryptography
230 if [[ "\${IMAGE_NAME}" == *"libressl"* ]]; then
231 LD_LIBRARY_PATH="/usr/local/libressl/lib:\$LD_LIBRARY_PATH" \
232 LDFLAGS="-L/usr/local/libressl/lib" \
233 CFLAGS="-I/usr/local/libressl/include" \
234 tox -r -- --color=yes
235 else
236 tox -r -- --color=yes
237 fi
238 virtualenv .venv
239 source .venv/bin/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800240 # This pin must be kept in sync with tox.ini
Alex Gaynoraf3f9b82018-04-20 00:29:28 -0400241 pip install coverage==4.3.4
Paul Kehrer8396d432017-09-06 23:23:15 +0800242 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV,IMAGE_NAME
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700243 """
244 }
Alex Gaynor40226372017-05-23 14:14:18 -0700245 if (artifacts) {
246 archiveArtifacts artifacts: artifacts, excludes: artifactExcludes
247 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700248 }
249 }
250 }
251 }
252 } finally {
253 deleteDir()
254 }
255
256}
257
258def builders = [:]
259for (config in configs) {
260 def label = config["label"]
261 def toxenvs = config["toxenvs"]
Alex Gaynor40226372017-05-23 14:14:18 -0700262 def artifacts = config["artifacts"]
263 def artifactExcludes = config["artifactExcludes"]
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700264
265 for (_toxenv in toxenvs) {
266 def toxenv = _toxenv
267
268 if (label.contains("docker")) {
269 def imageName = config["imageName"]
270 def combinedName = "${imageName}-${toxenv}"
271 builders[combinedName] = {
272 node(label) {
273 stage(combinedName) {
Paul Kehrerc033c902017-07-07 13:20:29 -0500274 def buildImage = docker.image(imageName)
275 buildImage.pull()
276 buildImage.inside {
Alex Gaynor40226372017-05-23 14:14:18 -0700277 build(toxenv, label, imageName, artifacts, artifactExcludes)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700278 }
279 }
280 }
281 }
282 } else {
283 def combinedName = "${label}-${toxenv}"
284 builders[combinedName] = {
285 node(label) {
286 stage(combinedName) {
Alex Gaynor40226372017-05-23 14:14:18 -0700287 build(toxenv, label, '', null, null)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700288 }
289 }
290 }
291 }
292 }
293}
294
295/* Add the python setup.py test builder */
296builders["setup.py-test"] = {
297 node("docker") {
298 stage("python setup.py test") {
299 docker.image("pyca/cryptography-runner-ubuntu-rolling").inside {
300 try {
301 checkout_git("docker")
302 sh """#!/usr/bin/env bash
303 set -xe
304 cd cryptography
305 virtualenv .venv
306 source .venv/bin/activate
307 python setup.py test
308 """
309 } finally {
310 deleteDir()
311 }
312
313 }
314 }
315 }
316}
317
Paul Kehrer3d96afd2017-10-04 10:53:18 +0800318parallel builders