From f67d09d315f0a9cb172e5e0f4e54390d7bb7a601 Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Fri, 4 Aug 2017 16:58:44 -0400 Subject: [PATCH] Create publish-openstack-python(-branch)-tarball jobs These 2 jobs will be used to copy release / branch tarballs to tarballs.o.o. Branch tarballs will only copy *.tar.gz, while release jobs will copy both *.tar.gz and *.whl files. Change-Id: Ic879302a2006b737ee4364cea067a00ebe198951 Depends-On: Ia79802dd386dbf1287af16a59985ce99a7dd4899 Depends-On: Ic7fc31a372de29a3a97ef84539faf3b0a1d6e181 Signed-off-by: Paul Belanger --- playbooks/python-branch-tarball/post.yaml | 22 +++++++++++++++++ playbooks/python-tarball/post.yaml | 30 +++++++++++++++++++++++ playbooks/python-tarball/pre.yaml | 9 +++++++ playbooks/python-tarball/run.yaml | 10 ++++++++ test-requirements.txt | 3 +++ tox.ini | 2 +- zuul.yaml | 16 ++++++++++++ 7 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 playbooks/python-branch-tarball/post.yaml create mode 100644 playbooks/python-tarball/post.yaml create mode 100644 playbooks/python-tarball/pre.yaml create mode 100644 playbooks/python-tarball/run.yaml diff --git a/playbooks/python-branch-tarball/post.yaml b/playbooks/python-branch-tarball/post.yaml new file mode 100644 index 00000000..eeb01297 --- /dev/null +++ b/playbooks/python-branch-tarball/post.yaml @@ -0,0 +1,22 @@ +- hosts: all + tasks: + # We only want to publish tar.gz file to tarballs.o.o. Find everything else + # and delete them. + - name: Find wheels in dist folder. + find: + file_type: file + paths: "src/{{ zuul.project.canonical_name }}/dist" + patterns: ^((?!tar\.gz).)*$ + use_regex: yes + register: result + + - name: Delete found files that don't match *.tar.gz. + file: + path: "{{ item.path }}" + state: absent + with_items: "{{ result.files }}" + + - name: Rename tarball to branch specific name. + shell: "mv *.tar.gz {{ zuul.project.short_name }}-{{ zuul.branch }}.tar.gz" + args: + chdir: "src/{{ zuul.project.canonical_name }}/dist" diff --git a/playbooks/python-tarball/post.yaml b/playbooks/python-tarball/post.yaml new file mode 100644 index 00000000..5251ce7b --- /dev/null +++ b/playbooks/python-tarball/post.yaml @@ -0,0 +1,30 @@ +- hosts: all + roles: + - fetch-tox-output + + post_tasks: + - name: Find tarballs and wheels in dist folder. + find: + file_type: file + paths: "src/{{ zuul.project.canonical_name }}/dist" + patterns: "*.tar.gz,*.whl" + register: result + + - name: Display stat for tarballs and wheels. + stat: + path: "{{ item.path }}" + with_items: "{{ result.files }}" + + - name: Ensure artifacts directory exists. + file: + path: "{{ zuul.executor.work_root }}/artifacts" + state: directory + delegate_to: localhost + + - name: Collect tarball artifacts. + synchronize: + dest: "{{ zuul.executor.work_root }}/artifacts/" + mode: pull + src: "{{ item.path }}" + verify_host: true + with_items: "{{ result.files }}" diff --git a/playbooks/python-tarball/pre.yaml b/playbooks/python-tarball/pre.yaml new file mode 100644 index 00000000..9a37b546 --- /dev/null +++ b/playbooks/python-tarball/pre.yaml @@ -0,0 +1,9 @@ +- hosts: all + roles: + - role: bindep + bindep_profile: test + bindep_dir: "src/{{ zuul.project.canonical_name }}" + # TODO(mordred) When we have site-local variables, these should go there + bindep_command: /usr/bindep-env/bin/bindep + bindep_fallback: /usr/local/jenkins/common_data/bindep-fallback.txt + - revoke-sudo diff --git a/playbooks/python-tarball/run.yaml b/playbooks/python-tarball/run.yaml new file mode 100644 index 00000000..9600c11a --- /dev/null +++ b/playbooks/python-tarball/run.yaml @@ -0,0 +1,10 @@ +- hosts: all + pre_tasks: + - name: Ensure tox is installed + shell: type tox || pip install --user tox + + roles: + - role: tox + tox_extra_args: -vv python setup.py sdist + - role: tox + tox_extra_args: -vv python setup.py bdist_wheel diff --git a/test-requirements.txt b/test-requirements.txt index 5d53074a..5b5efc35 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -8,3 +8,6 @@ ansible-lint bashate>=0.2 sphinx>=1.5.1,<1.6.0 # BSD oslosphinx>=4.7.0 # Apache-2.0 + +# zuul-jobs is required to supply the ansible roles for ansible-lint +-e git://git.openstack.org/openstack-infra/zuul-jobs#egg=zuul-jobs diff --git a/tox.ini b/tox.ini index ff95ae04..94f49ce2 100644 --- a/tox.ini +++ b/tox.ini @@ -23,7 +23,7 @@ commands = python setup.py build_sphinx [testenv:linters] setenv = - ANSIBLE_ROLES_PATH = {toxinidir}/roles + ANSIBLE_ROLES_PATH = {toxinidir}/roles:{envdir}/src/zuul-jobs/roles whitelist_externals = bash commands = flake8 {posargs} diff --git a/zuul.yaml b/zuul.yaml index faa9367a..ca103966 100644 --- a/zuul.yaml +++ b/zuul.yaml @@ -27,6 +27,22 @@ tox_environment: UPPER_CONSTRAINTS_FILE: "{{ ansible_user_dir }}/src/git.openstack.org/openstack/requirements/upper-constraints.txt" +- job: + name: publish-openstack-python-tarball + parent: publish-openstack-tarball + description: | + Publish the results of the tox-tarball job to tarballs.openstack.org. + pre-run: playbooks/python-tarball/pre + run: playbooks/python-tarball/run + post-run: playbooks/python-tarball/post + +- job: + name: publish-openstack-python-branch-tarball + parent: publish-openstack-python-tarball + description: | + Publish the results of the tox-tarball job to tarballs.openstack.org. + post-run: playbooks/python-branch-tarball/post + - project: name: openstack-infra/openstack-zuul-jobs check: