From 0d59816c64c5d789977f221e33280f5d9b124f12 Mon Sep 17 00:00:00 2001 From: Tony Breeds Date: Sat, 2 Mar 2019 15:31:01 +1100 Subject: [PATCH] Use a template to generate the 'whereto' testing data As we add more branches and tags we don't want to manually add tests for them (and we'd need to or the docs build will fail with an 'Untested Rule'. Use the redirections data that we use to generate the htaccess file to also generate the tests. Also I removed the debug output as it it's assertion is incorrect we can actually get the .htaccess file from the docs job \o/ Change-Id: Ib5d35169e68cd92b666a35705d8e36942bd28b89 --- doc/source/_exts/deliverables.py | 16 ++++++++++++---- doc/source/_templates/redirect-tests | 5 +++++ doc/test/redirect-tests.txt | 12 ------------ tox.ini | 2 +- 4 files changed, 18 insertions(+), 17 deletions(-) create mode 100644 doc/source/_templates/redirect-tests delete mode 100644 doc/test/redirect-tests.txt diff --git a/doc/source/_exts/deliverables.py b/doc/source/_exts/deliverables.py index a7b830aff5..089f1f20d9 100644 --- a/doc/source/_exts/deliverables.py +++ b/doc/source/_exts/deliverables.py @@ -472,17 +472,25 @@ def build_finished(app, exception): if exception is not None: return + redirections = generate_constraints_redirections(_deliverables) rendered_output = app.builder.templates.render( 'htaccess', - dict(redirections=generate_constraints_redirections(_deliverables)) + dict(redirections=redirections) ) output_full_name = os.path.join(app.builder.outdir, '.htaccess') with open(output_full_name, "w") as f: f.write(rendered_output) LOG.info('Wrote Redirections to %s' % (output_full_name)) - # NOTE(tonyb): We want to output this here because we won't be able to - # get to it via http{,s} so this helps debugging. - LOG.debug(rendered_output) + + rendered_output = app.builder.templates.render( + 'redirect-tests', + dict(redirections=redirections) + ) + output_full_name = os.path.join(app.builder.outdir, + '..', + 'redirect-tests.txt') + with open(output_full_name, "w") as f: + f.write(rendered_output) def setup(app): diff --git a/doc/source/_templates/redirect-tests b/doc/source/_templates/redirect-tests new file mode 100644 index 0000000000..f7203cc4a8 --- /dev/null +++ b/doc/source/_templates/redirect-tests @@ -0,0 +1,5 @@ +/teams/shade.html 301 /teams/openstacksdk.html +/constraints/upper/master 301 http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=master +{%- for redirection in redirections %} +/constraints/upper/{{ redirection.src }} {{ redirection.code }} http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h={{ redirection.dst }} +{%- endfor %} diff --git a/doc/test/redirect-tests.txt b/doc/test/redirect-tests.txt deleted file mode 100644 index 38822ec821..0000000000 --- a/doc/test/redirect-tests.txt +++ /dev/null @@ -1,12 +0,0 @@ -/teams/shade.html 301 /teams/openstacksdk.html -/constraints/upper/master 301 http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=master -/constraints/upper/stein 301 http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=master -/constraints/upper/rocky 301 http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/rocky -/constraints/upper/queens 301 http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/queens -/constraints/upper/pike 301 http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/pike -/constraints/upper/ocata 301 http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/ocata -/constraints/upper/newton 301 http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/newton -/constraints/upper/mitaka 301 http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=mitaka-eol -/constraints/upper/liberty 301 http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=liberty-eol -/constraints/upper/kilo 301 http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=kilo-eol -/constraints/upper/juno 301 http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=juno-eol diff --git a/tox.ini b/tox.ini index 4541b61f6f..2ee4607343 100644 --- a/tox.ini +++ b/tox.ini @@ -74,7 +74,7 @@ deps = -r{toxinidir}/doc/requirements.txt commands = sphinx-build -v -a -E -W -d doc/build/doctrees -b html doc/source doc/build/html - whereto {toxinidir}/doc/build/html/.htaccess {toxinidir}/doc/test/redirect-tests.txt + whereto {toxinidir}/doc/build/html/.htaccess {toxinidir}/doc/build/redirect-tests.txt [flake8] # E123, E125 skipped as they are invalid PEP-8.