Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add baseline tests #50

Merged
merged 8 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/pythontests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, '3.10']
python-version: [3.6, 3.7, 3.8, 3.9]
skip-is-error: [false]
include:
- python-version: '3.10'
skip-is-error: true

steps:
- name: Check out antsibull-docs
Expand Down Expand Up @@ -56,7 +60,7 @@ jobs:

- name: Test with pytest and upload coverage stats
run: |
./test-pytest.sh
./test-pytest.sh ${{ matrix.skip-is-error && '--error-for-skips' || '' }}
poetry run coverage xml -i
poetry run codecov
working-directory: antsibull-docs
4 changes: 4 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Files: changelogs/fragments/*
Copyright: Ansible Project
License: GPL-3.0-or-later

Files: tests/functional/baseline-*
Copyright: Ansible Project
License: GPL-3.0-or-later
2 changes: 2 additions & 0 deletions changelogs/fragments/50-ansible-version-fallback.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- "Use ``ansible --version`` to figure out ansible-core version when ansible-core is not installed for the same Python interpreter / venv that is used for antsibull-docs (https://github.com/ansible-community/antsibull-docs/pull/50)."
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ rstcheck = ">= 3.0.0, < 7.0.0"
sphinx = "*"

[tool.poetry.dev-dependencies]
ansible-core = {version = ">= 2.14.0b1", python = ">=3.9"}
asynctest = "*"
cryptography = "*"
codecov = "*"
Expand All @@ -54,6 +55,7 @@ pylint = "^2.12.0"
pytest = "*"
pytest-asyncio = ">= 0.12"
pytest-cov = "*"
pytest-error-for-skips = "*"
# Needed for TypedDict in rstcheck-core stubs
typing-extensions = {version = ">=3.7.4", python = "<3.8"}
types-docutils = "*"
Expand Down
27 changes: 22 additions & 5 deletions src/antsibull_docs/docs_parsing/ansible_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,28 @@ def get_collection_metadata(venv: t.Union['VenvRunner', 'FakeVenvRunner'],
def get_ansible_core_version(venv: t.Union['VenvRunner', 'FakeVenvRunner'],
env: t.Optional[t.Dict[str, str]] = None,
) -> PypiVer:
venv_python = venv.get_command('python')
ansible_version_cmd = venv_python(
'-c', 'import ansible.release; print(ansible.release.__version__)', _env=env)
output = ansible_version_cmd.stdout.decode('utf-8', errors='surrogateescape').strip()
return PypiVer(output)
try:
venv_python = venv.get_command('python')
ansible_version_cmd = venv_python(
'-c', 'import ansible.release; print(ansible.release.__version__)', _env=env)
output = ansible_version_cmd.stdout.decode('utf-8', errors='surrogateescape').strip()
return PypiVer(output)
except sh.ErrorReturnCode:
pass

try:
# Fallback: use `ansible --version`
venv_ansible = venv.get_command('ansible')
ansible_version_cmd = venv_ansible('--version', _env=env)
raw_result = ansible_version_cmd.stdout.decode('utf-8', errors='surrogateescape')
metadata = _extract_ansible_builtin_metadata(raw_result)
if metadata.version is None:
raise ValueError('Cannot retrieve ansible-core version from `ansible --version`')
return PypiVer(metadata.version)
except sh.ErrorReturnCode as exc:
raise ValueError(
f'Cannot retrieve ansible-core version from `ansible --version`: {exc}'
) from exc


async def get_ansible_plugin_info(venv: t.Union['VenvRunner', 'FakeVenvRunner'],
Expand Down
20 changes: 20 additions & 0 deletions tests/functional/baseline-default/collections/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

:orphan:

.. _list_of_collections:

Collection Index
================

These are the collections documented here.

* :ref:`ns.col1 <plugins_in_ns.col1>`
* :ref:`ns.col2 <plugins_in_ns.col2>`
* :ref:`ns2.col <plugins_in_ns2.col>`

.. toctree::
:maxdepth: 1
:hidden:

ns/index
ns2/index
13 changes: 13 additions & 0 deletions tests/functional/baseline-default/collections/index_become.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

:orphan:

.. _list_of_become_plugins:

Index of all Become Plugins
===========================

ns2.col
-------

* :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_become>` -- Use foo

13 changes: 13 additions & 0 deletions tests/functional/baseline-default/collections/index_cache.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

:orphan:

.. _list_of_cache_plugins:

Index of all Cache Plugins
==========================

ns2.col
-------

* :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_cache>` -- Foo files

13 changes: 13 additions & 0 deletions tests/functional/baseline-default/collections/index_callback.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

:orphan:

.. _list_of_callback_plugins:

Index of all Callback Plugins
=============================

ns2.col
-------

* :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_callback>` -- Foo output

13 changes: 13 additions & 0 deletions tests/functional/baseline-default/collections/index_cliconf.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

:orphan:

.. _list_of_cliconf_plugins:

Index of all Cliconf Plugins
============================

ns2.col
-------

* :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_cliconf>` -- Foo router CLI config

13 changes: 13 additions & 0 deletions tests/functional/baseline-default/collections/index_connection.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

:orphan:

.. _list_of_connection_plugins:

Index of all Connection Plugins
===============================

ns2.col
-------

* :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_connection>` -- Foo connection

13 changes: 13 additions & 0 deletions tests/functional/baseline-default/collections/index_filter.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

:orphan:

.. _list_of_filter_plugins:

Index of all Filter Plugins
===========================

ns2.col
-------

* :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_filter>` -- The foo filter

13 changes: 13 additions & 0 deletions tests/functional/baseline-default/collections/index_inventory.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

:orphan:

.. _list_of_inventory_plugins:

Index of all Inventory Plugins
==============================

ns2.col
-------

* :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_inventory>` -- The foo inventory

13 changes: 13 additions & 0 deletions tests/functional/baseline-default/collections/index_lookup.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

:orphan:

.. _list_of_lookup_plugins:

Index of all Lookup Plugins
===========================

ns2.col
-------

* :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_lookup>` -- Look up some foo

13 changes: 13 additions & 0 deletions tests/functional/baseline-default/collections/index_module.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

:orphan:

.. _list_of_module_plugins:

Index of all Modules
====================

ns2.col
-------

* :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_module>` -- Do some foo

13 changes: 13 additions & 0 deletions tests/functional/baseline-default/collections/index_shell.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

:orphan:

.. _list_of_shell_plugins:

Index of all Shell Plugins
==========================

ns2.col
-------

* :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_shell>` -- Foo shell

13 changes: 13 additions & 0 deletions tests/functional/baseline-default/collections/index_strategy.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

:orphan:

.. _list_of_strategy_plugins:

Index of all Strategy Plugins
=============================

ns2.col
-------

* :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_strategy>` -- Executes tasks in foo

13 changes: 13 additions & 0 deletions tests/functional/baseline-default/collections/index_test.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

:orphan:

.. _list_of_test_plugins:

Index of all Test Plugins
=========================

ns2.col
-------

* :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_test>` -- Is something a foo

13 changes: 13 additions & 0 deletions tests/functional/baseline-default/collections/index_vars.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

:orphan:

.. _list_of_vars_plugins:

Index of all Vars Plugins
=========================

ns2.col
-------

* :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_vars>` -- Load foo

46 changes: 46 additions & 0 deletions tests/functional/baseline-default/collections/ns/col1/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@



.. _plugins_in_ns.col1:

Ns.Col1
=======


.. contents::
:local:
:depth: 1

Description
-----------

A short description.

**Authors:**

* Ansible (https://github.com/ansible)
* Foo Bar (@ansible)
* Test <foo@example.com>




.. toctree::
:maxdepth: 1


Plugin Index
------------

There are no plugins in the ns.col1 collection with automatically generated documentation.



.. seealso::

List of :ref:`collections <list_of_collections>` with docs hosted here.

.. toctree::
:maxdepth: 1
:hidden:

44 changes: 44 additions & 0 deletions tests/functional/baseline-default/collections/ns/col2/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@



.. _plugins_in_ns.col2:

Ns.Col2
=======

Collection version 0.0.1

.. contents::
:local:
:depth: 1

Description
-----------


**Author:**

* Ansible (https://github.com/ansible)




.. toctree::
:maxdepth: 1


Plugin Index
------------

There are no plugins in the ns.col2 collection with automatically generated documentation.



.. seealso::

List of :ref:`collections <list_of_collections>` with docs hosted here.

.. toctree::
:maxdepth: 1
:hidden:

18 changes: 18 additions & 0 deletions tests/functional/baseline-default/collections/ns/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@


.. _list_of_collections_ns:

Collections in the Ns Namespace
===============================

These are the collections documented here in the **ns** namespace.

* :ref:`ns.col1 <plugins_in_ns.col1>`
* :ref:`ns.col2 <plugins_in_ns.col2>`

.. toctree::
:maxdepth: 1
:hidden:

col1/index
col2/index
Loading