From 5c77008c3da82b09d1e6d5856b90bce3957ca8a6 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Thu, 16 Nov 2017 17:19:18 -0600 Subject: [PATCH] Split reno installation into a role Similar to ensure-tox, split installing reno in to its own role. Change-Id: I8ac7c40f1fe8b590c4184437bf50a7c03cf2b45f --- playbooks/releasenotes/run.yaml | 1 + roles/build-releasenotes/tasks/main.yaml | 43 ------------------------ roles/ensure-reno/README.rst | 10 ++++++ roles/ensure-reno/defaults/main.yaml | 1 + roles/ensure-reno/tasks/main.yaml | 42 +++++++++++++++++++++++ 5 files changed, 54 insertions(+), 43 deletions(-) create mode 100644 roles/ensure-reno/README.rst create mode 100644 roles/ensure-reno/defaults/main.yaml create mode 100644 roles/ensure-reno/tasks/main.yaml diff --git a/playbooks/releasenotes/run.yaml b/playbooks/releasenotes/run.yaml index 116c6888..a2839d4a 100644 --- a/playbooks/releasenotes/run.yaml +++ b/playbooks/releasenotes/run.yaml @@ -1,3 +1,4 @@ - hosts: all roles: + - ensure-reno - build-releasenotes diff --git a/roles/build-releasenotes/tasks/main.yaml b/roles/build-releasenotes/tasks/main.yaml index 7b0e6e35..6abbac61 100644 --- a/roles/build-releasenotes/tasks/main.yaml +++ b/roles/build-releasenotes/tasks/main.yaml @@ -1,52 +1,9 @@ -- name: Install gettext package - package: - name: gettext - state: present - become: yes - # TODO(mordred) Put the translations logic into a sphinx plugin? - name: Check if translations exist for release notes stat: path: "{{ zuul_work_dir }}/releasenotes/source/locale" register: translations -- name: Check to see if the constraints file exists - stat: - path: "{{ constraints_file|default('missing') }}" - get_checksum: false - get_mime: false - get_md5: false - register: stat_results - when: constraints_file is defined - -- name: Record file location - set_fact: - upper_constraints: "-c {{ constraints_file }}" - when: not stat_results|skipped and stat_results.stat.exists - -- name: Setup venv - shell: - chdir: '{{ zuul_work_dir }}' - executable: /bin/bash - cmd: | - set -e - set -x - - UPPER_CONSTRAINTS="{{ upper_constraints }}" - python -m virtualenv .venv - VENV=.venv/bin - $VENV/pip install sphinx $UPPER_CONSTRAINTS - $VENV/pip install openstackdocstheme $UPPER_CONSTRAINTS - $VENV/pip install reno $UPPER_CONSTRAINTS - # Optionally, install local requirements - if [ -e releasenotes/requirements.txt ] ; then - $VENV/pip install -r releasenotes/requirements.txt $UPPER_CONSTRAINTS - fi - # TODO(jaegerandi): Remove once all repos are fixed. - # Try installing current repo in case it needs to be available for - # example for version number calculation. Ignore any failures here. - $VENV/pip install . || true - - name: Prepare release note translations shell: chdir: '{{ zuul_work_dir }}' diff --git a/roles/ensure-reno/README.rst b/roles/ensure-reno/README.rst new file mode 100644 index 00000000..a5fa64d6 --- /dev/null +++ b/roles/ensure-reno/README.rst @@ -0,0 +1,10 @@ +Ensure reno is installed + +**Role Variables** + +.. zuul:rolevar:: zuul_work_dir + :default: {{ zuul.project.src_dir }} + + Directory to operate in. Needed only for a little while until we have + projects migrated to not need to be installed just to generate + release notes. diff --git a/roles/ensure-reno/defaults/main.yaml b/roles/ensure-reno/defaults/main.yaml new file mode 100644 index 00000000..9739eb17 --- /dev/null +++ b/roles/ensure-reno/defaults/main.yaml @@ -0,0 +1 @@ +zuul_work_dir: "{{ zuul.project.src_dir }}" diff --git a/roles/ensure-reno/tasks/main.yaml b/roles/ensure-reno/tasks/main.yaml new file mode 100644 index 00000000..4f477eb1 --- /dev/null +++ b/roles/ensure-reno/tasks/main.yaml @@ -0,0 +1,42 @@ +- name: Install gettext package + package: + name: gettext + state: present + become: yes + +- name: Check to see if the constraints file exists + stat: + path: "{{ constraints_file|default('missing') }}" + get_checksum: false + get_mime: false + get_md5: false + register: stat_results + when: constraints_file is defined + +- name: Record file location + set_fact: + upper_constraints: "-c {{ constraints_file }}" + when: not stat_results|skipped and stat_results.stat.exists + +- name: Setup venv + shell: + chdir: '{{ zuul_work_dir }}' + executable: /bin/bash + cmd: | + set -e + set -x + + UPPER_CONSTRAINTS="{{ upper_constraints }}" + python -m virtualenv .venv + VENV=.venv/bin + $VENV/pip install sphinx $UPPER_CONSTRAINTS + $VENV/pip install openstackdocstheme $UPPER_CONSTRAINTS + $VENV/pip install reno $UPPER_CONSTRAINTS + # Optionally, install local requirements + if [ -e releasenotes/requirements.txt ] ; then + $VENV/pip install -r releasenotes/requirements.txt $UPPER_CONSTRAINTS + fi + # TODO(jaegerandi): Remove once all repos are fixed. + # Try installing current repo in case it needs to be available for + # example for version number calculation. Ignore any failures here. + $VENV/pip install . || true