From 86201594026f1e505b746633eeedd4a5820d4d89 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Wed, 19 Feb 2014 14:01:06 -0800 Subject: Refs #506 -- Trigger creation of wheels when doing a release --- tasks.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tasks.py') diff --git a/tasks.py b/tasks.py index f72f43ba..4b2209af 100644 --- a/tasks.py +++ b/tasks.py @@ -12,8 +12,14 @@ # limitations under the License. from __future__ import absolute_import, division, print_function +import getpass + import invoke +import requests + + +JENKINS_ROOT = "http://jenkins.cryptography.io" @invoke.task def release(version): @@ -25,3 +31,12 @@ def release(version): invoke.run("python setup.py sdist") invoke.run("twine upload -s dist/cryptography-{0}*".format(version)) + + token = getpass.getpass("Input the Jenkins token") + requests.post( + "{0}/job/cryptography-wheel-builder/build".format(JENKINS_ROOT), + params={ + "token": token, + "cause": "Building wheels for {0}".format(version) + } + ) -- cgit v1.2.3 From c9e4c6af4ce77c703c32b4c611075987960f7b64 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Wed, 19 Feb 2014 14:29:37 -0800 Subject: Raise on failure --- tasks.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tasks.py') diff --git a/tasks.py b/tasks.py index 4b2209af..5fa86986 100644 --- a/tasks.py +++ b/tasks.py @@ -21,6 +21,7 @@ import requests JENKINS_ROOT = "http://jenkins.cryptography.io" + @invoke.task def release(version): """ @@ -33,10 +34,11 @@ def release(version): invoke.run("twine upload -s dist/cryptography-{0}*".format(version)) token = getpass.getpass("Input the Jenkins token") - requests.post( + response = requests.post( "{0}/job/cryptography-wheel-builder/build".format(JENKINS_ROOT), params={ "token": token, "cause": "Building wheels for {0}".format(version) } ) + response.raise_for_status() -- cgit v1.2.3 From a1dff05cd4d88ba3fd2b3b87e1b1f5aea1075327 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Wed, 19 Feb 2014 16:44:06 -0800 Subject: Wait for the wheel job to finish building the windows wheels. Refs #506 --- tasks.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'tasks.py') diff --git a/tasks.py b/tasks.py index 5fa86986..8f398aad 100644 --- a/tasks.py +++ b/tasks.py @@ -13,13 +13,28 @@ from __future__ import absolute_import, division, print_function import getpass +import time import invoke import requests -JENKINS_ROOT = "http://jenkins.cryptography.io" +JENKINS_URL = "http://jenkins.cryptography.io/job/cryptography-wheel-builder" + + +def wait_for_build_completed(): + while True: + response = requests.get( + "{0}/lastBuild/api/json/".format(JENKINS_URL), + headers={ + "Accept": "application/json", + } + ) + response.raise_for_status() + if not response.json()["building"]: + break + time.sleep(0.1) @invoke.task @@ -35,10 +50,11 @@ def release(version): token = getpass.getpass("Input the Jenkins token") response = requests.post( - "{0}/job/cryptography-wheel-builder/build".format(JENKINS_ROOT), + "{0}/build".format(JENKINS_URL), params={ "token": token, "cause": "Building wheels for {0}".format(version) } ) response.raise_for_status() + wait_for_build_completed() -- cgit v1.2.3 From 7a2b358e6608c5ed76db6aa63dd28195aa42508f Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Thu, 20 Feb 2014 07:48:46 -0800 Subject: Download the windows wheels from jenkins --- tasks.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tasks.py') diff --git a/tasks.py b/tasks.py index 8f398aad..3de6d3c1 100644 --- a/tasks.py +++ b/tasks.py @@ -13,6 +13,7 @@ from __future__ import absolute_import, division, print_function import getpass +import os import time import invoke @@ -33,10 +34,42 @@ def wait_for_build_completed(): ) response.raise_for_status() if not response.json()["building"]: + assert response.json()["result"] == "SUCCESS" break time.sleep(0.1) +def download_artifacts(): + response = requests.get( + "{0}/lastBuild/api/json/".format(JENKINS_URL), + headers={ + "Accept": "application/json" + } + ) + response.raise_for_status() + assert not response.json()["building"] + assert response.json()["result"] == "SUCCESS" + for run in response.json()["runs"]: + response = requests.get( + run["url"] + "api/json/", + headers={ + "Accept": "application/json", + } + ) + response.raise_for_status() + for artifact in response.json()["artifacts"]: + response = requests.get( + "{}artifacts/{}".format(run["url"], artifact["relativePath"]) + ) + out_path = os.path.join( + os.path.dirname(__file__), + "dist", + artifact["fileName"], + ) + with open(out_path, "wb") as f: + f.write(response.content) + + @invoke.task def release(version): """ @@ -58,3 +91,4 @@ def release(version): ) response.raise_for_status() wait_for_build_completed() + download_artifacts() -- cgit v1.2.3 From 6ab3f46b6f615dda1cef5cf7d0531a1cc9ba2903 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Thu, 20 Feb 2014 09:07:53 -0800 Subject: Upload windows wheels --- tasks.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tasks.py') diff --git a/tasks.py b/tasks.py index 3de6d3c1..1021360a 100644 --- a/tasks.py +++ b/tasks.py @@ -49,6 +49,9 @@ def download_artifacts(): response.raise_for_status() assert not response.json()["building"] assert response.json()["result"] == "SUCCESS" + + paths = [] + for run in response.json()["runs"]: response = requests.get( run["url"] + "api/json/", @@ -68,6 +71,8 @@ def download_artifacts(): ) with open(out_path, "wb") as f: f.write(response.content) + paths.append(out_path) + return paths @invoke.task @@ -91,4 +96,5 @@ def release(version): ) response.raise_for_status() wait_for_build_completed() - download_artifacts() + paths = download_artifacts() + invoke.run("twine upload {0}".format(" ".join(paths))) -- cgit v1.2.3 From 6c77b34268954cf114fbe18df8e927b5f7146b85 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Thu, 20 Feb 2014 09:32:55 -0800 Subject: python 2.6 --- tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tasks.py') diff --git a/tasks.py b/tasks.py index 1021360a..8c7dc40a 100644 --- a/tasks.py +++ b/tasks.py @@ -62,7 +62,7 @@ def download_artifacts(): response.raise_for_status() for artifact in response.json()["artifacts"]: response = requests.get( - "{}artifacts/{}".format(run["url"], artifact["relativePath"]) + "{0}artifacts/{1}".format(run["url"], artifact["relativePath"]) ) out_path = os.path.join( os.path.dirname(__file__), -- cgit v1.2.3 From 6629fa5c3dbdde769f015d6cb942b052296eaa44 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Thu, 20 Feb 2014 16:10:53 -0800 Subject: A tiny formatting cleanup --- tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tasks.py') diff --git a/tasks.py b/tasks.py index 8c7dc40a..242f2536 100644 --- a/tasks.py +++ b/tasks.py @@ -86,7 +86,7 @@ def release(version): invoke.run("python setup.py sdist") invoke.run("twine upload -s dist/cryptography-{0}*".format(version)) - token = getpass.getpass("Input the Jenkins token") + token = getpass.getpass("Input the Jenkins token: ") response = requests.post( "{0}/build".format(JENKINS_URL), params={ -- cgit v1.2.3