Skip to content

Commit c8f674d

Browse files
authored
Add baseline tests (#50)
* Start with baseline tests. * Run baseline tests only with new enough Python and when ansible-core is installed in venv. * Improve ansible --version fallback. * Add changelog fragment for code change. * Add blanket license to baseline files. This is OK since they are generated by code from this repository from files inside this repository. * Extend baseline tests. * Make baseline build script nicer. * Make sure that at least for one Python version no tests are skipped.
1 parent 4af4844 commit c8f674d

File tree

169 files changed

+19713
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+19713
-7
lines changed

.github/workflows/pythontests.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ jobs:
2323
runs-on: ubuntu-latest
2424
strategy:
2525
matrix:
26-
python-version: [3.6, 3.7, 3.8, 3.9, '3.10']
26+
python-version: [3.6, 3.7, 3.8, 3.9]
27+
skip-is-error: [false]
28+
include:
29+
- python-version: '3.10'
30+
skip-is-error: true
2731

2832
steps:
2933
- name: Check out antsibull-docs
@@ -56,7 +60,7 @@ jobs:
5660

5761
- name: Test with pytest and upload coverage stats
5862
run: |
59-
./test-pytest.sh
63+
./test-pytest.sh ${{ matrix.skip-is-error && '--error-for-skips' || '' }}
6064
poetry run coverage xml -i
6165
poetry run codecov
6266
working-directory: antsibull-docs

.reuse/dep5

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
33
Files: changelogs/fragments/*
44
Copyright: Ansible Project
55
License: GPL-3.0-or-later
6+
7+
Files: tests/functional/baseline-*
8+
Copyright: Ansible Project
9+
License: GPL-3.0-or-later
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
minor_changes:
2+
- "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)."

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ rstcheck = ">= 3.0.0, < 7.0.0"
4343
sphinx = "*"
4444

4545
[tool.poetry.dev-dependencies]
46+
ansible-core = {version = ">= 2.14.0b1", python = ">=3.9"}
4647
asynctest = "*"
4748
cryptography = "*"
4849
codecov = "*"
@@ -54,6 +55,7 @@ pylint = "^2.12.0"
5455
pytest = "*"
5556
pytest-asyncio = ">= 0.12"
5657
pytest-cov = "*"
58+
pytest-error-for-skips = "*"
5759
# Needed for TypedDict in rstcheck-core stubs
5860
typing-extensions = {version = ">=3.7.4", python = "<3.8"}
5961
types-docutils = "*"

src/antsibull_docs/docs_parsing/ansible_doc.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,28 @@ def get_collection_metadata(venv: t.Union['VenvRunner', 'FakeVenvRunner'],
239239
def get_ansible_core_version(venv: t.Union['VenvRunner', 'FakeVenvRunner'],
240240
env: t.Optional[t.Dict[str, str]] = None,
241241
) -> PypiVer:
242-
venv_python = venv.get_command('python')
243-
ansible_version_cmd = venv_python(
244-
'-c', 'import ansible.release; print(ansible.release.__version__)', _env=env)
245-
output = ansible_version_cmd.stdout.decode('utf-8', errors='surrogateescape').strip()
246-
return PypiVer(output)
242+
try:
243+
venv_python = venv.get_command('python')
244+
ansible_version_cmd = venv_python(
245+
'-c', 'import ansible.release; print(ansible.release.__version__)', _env=env)
246+
output = ansible_version_cmd.stdout.decode('utf-8', errors='surrogateescape').strip()
247+
return PypiVer(output)
248+
except sh.ErrorReturnCode:
249+
pass
250+
251+
try:
252+
# Fallback: use `ansible --version`
253+
venv_ansible = venv.get_command('ansible')
254+
ansible_version_cmd = venv_ansible('--version', _env=env)
255+
raw_result = ansible_version_cmd.stdout.decode('utf-8', errors='surrogateescape')
256+
metadata = _extract_ansible_builtin_metadata(raw_result)
257+
if metadata.version is None:
258+
raise ValueError('Cannot retrieve ansible-core version from `ansible --version`')
259+
return PypiVer(metadata.version)
260+
except sh.ErrorReturnCode as exc:
261+
raise ValueError(
262+
f'Cannot retrieve ansible-core version from `ansible --version`: {exc}'
263+
) from exc
247264

248265

249266
async def get_ansible_plugin_info(venv: t.Union['VenvRunner', 'FakeVenvRunner'],
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
:orphan:
3+
4+
.. _list_of_collections:
5+
6+
Collection Index
7+
================
8+
9+
These are the collections documented here.
10+
11+
* :ref:`ns.col1 <plugins_in_ns.col1>`
12+
* :ref:`ns.col2 <plugins_in_ns.col2>`
13+
* :ref:`ns2.col <plugins_in_ns2.col>`
14+
15+
.. toctree::
16+
:maxdepth: 1
17+
:hidden:
18+
19+
ns/index
20+
ns2/index
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
:orphan:
3+
4+
.. _list_of_become_plugins:
5+
6+
Index of all Become Plugins
7+
===========================
8+
9+
ns2.col
10+
-------
11+
12+
* :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_become>` -- Use foo
13+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
:orphan:
3+
4+
.. _list_of_cache_plugins:
5+
6+
Index of all Cache Plugins
7+
==========================
8+
9+
ns2.col
10+
-------
11+
12+
* :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_cache>` -- Foo files
13+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
:orphan:
3+
4+
.. _list_of_callback_plugins:
5+
6+
Index of all Callback Plugins
7+
=============================
8+
9+
ns2.col
10+
-------
11+
12+
* :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_callback>` -- Foo output
13+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
:orphan:
3+
4+
.. _list_of_cliconf_plugins:
5+
6+
Index of all Cliconf Plugins
7+
============================
8+
9+
ns2.col
10+
-------
11+
12+
* :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_cliconf>` -- Foo router CLI config
13+

0 commit comments

Comments
 (0)