blob: 14a1ed7fd37cdf604c4a39e7f3b8102532aa8ba9 [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',
Paul Kehrer6bdae782017-06-06 08:45:01 -100024 imageName: 'pyca/cryptography-runner-sid',
Alex Gaynor40226372017-05-23 14:14:18 -070025 toxenvs: ['docs'],
26 artifacts: 'cryptography/docs/_build/html/**',
27 artifactExcludes: '**/*.doctree',
Paul Kehrerba58e1f2017-05-22 18:08:29 -070028 ],
Paul Kehrerba58e1f2017-05-22 18:08:29 -070029]
30
Paul Kehrerba58e1f2017-05-22 18:08:29 -070031def checkout_git(label) {
Alex Gaynor42b25712017-06-03 12:04:32 -040032 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 Kehrera119d2e2017-05-23 22:02:50 -070040 """
Alex Gaynor42b25712017-06-03 12:04:32 -040041 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 Kehrera119d2e2017-05-23 22:02:50 -070063 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -070064 }
65 if (label.contains("windows")) {
Paul Kehrera119d2e2017-05-23 22:02:50 -070066 bat """
67 cd cryptography
68 git rev-parse HEAD
69 """
Paul Kehrerba58e1f2017-05-22 18:08:29 -070070 } else {
Paul Kehrera119d2e2017-05-23 22:02:50 -070071 sh """
72 cd cryptography
73 git rev-parse HEAD
Paul Kehrerba58e1f2017-05-22 18:08:29 -070074 """
75 }
76}
Alex Gaynor40226372017-05-23 14:14:18 -070077def build(toxenv, label, imageName, artifacts, artifactExcludes) {
Paul Kehrerba58e1f2017-05-22 18:08:29 -070078 try {
79 timeout(time: 30, unit: 'MINUTES') {
80
81 checkout_git(label)
Alex Gaynor2e85a922018-07-16 11:18:33 -040082 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 Kehrerba58e1f2017-05-22 18:08:29 -070092
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 Kehrerba58e1f2017-05-22 18:08:29 -070097 py27: "C:\\Python27\\python.exe",
Paul Kehrerba58e1f2017-05-22 18:08:29 -070098 py34: "C:\\Python34\\python.exe",
99 py35: "C:\\Python35\\python.exe",
Paul Kehrer4ee1cb92018-06-27 20:07:14 -0700100 py36: "C:\\Python36\\python.exe",
101 py37: "C:\\Python37\\python.exe"
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700102 ]
Paul Kehrer4ee1cb92018-06-27 20:07:14 -0700103 if (toxenv == "py35" || toxenv == "py36" || toxenv == "py37") {
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700104 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 Kehrerba58e1f2017-05-22 18:08:29 -0700129 @set PYTHON="${pythonPath[toxenv]}"
130
131 @set INCLUDE="${opensslPaths[label]['include']}";%INCLUDE%
132 @set LIB="${opensslPaths[label]['lib']}";%LIB%
Alex Gaynor2e85a922018-07-16 11:18:33 -0400133 tox -r -- --wycheproof-root=../wycheproof
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700134 IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
135 virtualenv .codecov
136 call .codecov/Scripts/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800137 REM this pin must be kept in sync with tox.ini
Paul Kehrer636ad602018-09-04 09:45:17 -0500138 pip install coverage
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700139 pip install codecov
Paul Kehrer8396d432017-09-06 23:23:15 +0800140 codecov -e JOB_BASE_NAME,LABEL,TOXENV
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700141 """
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 Kehreradeaacf2017-05-24 12:49:18 -0700150 CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 \
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700151 LDFLAGS="/usr/local/opt/openssl\\@1.1/lib/libcrypto.a /usr/local/opt/openssl\\@1.1/lib/libssl.a" \
Paul Kehrerf88aea52018-09-05 21:44:29 -0500152 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 Gaynor2e85a922018-07-16 11:18:33 -0400153 tox -r -- --color=yes --wycheproof-root=../wycheproof
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700154 virtualenv .venv
155 source .venv/bin/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800156 # This pin must be kept in sync with tox.ini
Paul Kehrer636ad602018-09-04 09:45:17 -0500157 pip install coverage
Paul Kehrer8396d432017-09-06 23:23:15 +0800158 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700159 """
160 }
161 } else {
162 ansiColor {
163 sh """#!/usr/bin/env bash
164 set -xe
165 cd cryptography
Alex Gaynor2e85a922018-07-16 11:18:33 -0400166 tox -r -- --color=yes --wycheproof-root=../wycheproof
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700167 virtualenv .venv
168 source .venv/bin/activate
Paul Kehrere5359852017-09-13 09:30:51 +0800169 # This pin must be kept in sync with tox.ini
Paul Kehrer636ad602018-09-04 09:45:17 -0500170 pip install coverage
Paul Kehrer8396d432017-09-06 23:23:15 +0800171 bash <(curl -s https://codecov.io/bash) -e JOB_BASE_NAME,LABEL,TOXENV,IMAGE_NAME
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700172 """
173 }
Alex Gaynor40226372017-05-23 14:14:18 -0700174 if (artifacts) {
175 archiveArtifacts artifacts: artifacts, excludes: artifactExcludes
176 }
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700177 }
178 }
179 }
180 }
181 } finally {
182 deleteDir()
183 }
184
185}
186
187def builders = [:]
188for (config in configs) {
189 def label = config["label"]
190 def toxenvs = config["toxenvs"]
Alex Gaynor40226372017-05-23 14:14:18 -0700191 def artifacts = config["artifacts"]
192 def artifactExcludes = config["artifactExcludes"]
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700193
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 Kehrerc033c902017-07-07 13:20:29 -0500203 def buildImage = docker.image(imageName)
204 buildImage.pull()
205 buildImage.inside {
Alex Gaynor40226372017-05-23 14:14:18 -0700206 build(toxenv, label, imageName, artifacts, artifactExcludes)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700207 }
208 }
209 }
210 }
211 } else {
212 def combinedName = "${label}-${toxenv}"
213 builders[combinedName] = {
214 node(label) {
215 stage(combinedName) {
Alex Gaynor40226372017-05-23 14:14:18 -0700216 build(toxenv, label, '', null, null)
Paul Kehrerba58e1f2017-05-22 18:08:29 -0700217 }
218 }
219 }
220 }
221 }
222}
223
224/* Add the python setup.py test builder */
225builders["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 Kehrer3d96afd2017-10-04 10:53:18 +0800247parallel builders