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

Update CI and instructions for antsibull-fileutils; add explicit dependency on antsibull-fileutils #322

Merged
merged 4 commits into from
Sep 9, 2024
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
39 changes: 36 additions & 3 deletions .github/workflows/antsibull-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:
- main
antsibull_docutils_ref:
- main
antsibull_fileutils_ref:
- main
include:
- options: '--use-current --use-html-blobs --no-breadcrumbs community.crypto community.docker --extra-conf antsibull_ext_color_scheme=none'
python: '3.9'
Expand Down Expand Up @@ -80,6 +82,13 @@ jobs:
path: antsibull-docutils
ref: ${{ matrix.antsibull_docutils_ref }}

- name: Check out dependent project antsibull-fileutils
uses: actions/checkout@v4
with:
repository: ansible-community/antsibull-fileutils
path: antsibull-fileutils
ref: ${{ matrix.antsibull_fileutils_ref }}

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
Expand All @@ -88,7 +97,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[coverage] ../antsibull-core ../antsibull-docs-parser
pip install -e .[coverage] ../antsibull-core ../antsibull-changelog ../antsibull-docs-parser ../antsibull-docutils ../antsibull-fileutils
working-directory: antsibull-docs

- name: Use antsibull-docs sphinx-init
Expand Down Expand Up @@ -192,6 +201,18 @@ jobs:
repository: ansible-community/antsibull-changelog
path: antsibull-changelog

- name: Check out dependent project antsibull-docutils
uses: actions/checkout@v4
with:
repository: ansible-community/antsibull-docutils
path: antsibull-docutils

- name: Check out dependent project antsibull-fileutils
uses: actions/checkout@v4
with:
repository: ansible-community/antsibull-fileutils
path: antsibull-fileutils

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
Expand All @@ -200,7 +221,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[coverage] ../antsibull-core ../antsibull-docs-parser
pip install -e .[coverage] ../antsibull-core ../antsibull-changelog ../antsibull-docs-parser ../antsibull-docutils ../antsibull-fileutils
working-directory: antsibull-docs

- name: Get hold of deps file
Expand Down Expand Up @@ -256,6 +277,18 @@ jobs:
repository: ansible-community/antsibull-changelog
path: antsibull-changelog

- name: Check out dependent project antsibull-docutils
uses: actions/checkout@v4
with:
repository: ansible-community/antsibull-docutils
path: antsibull-docutils

- name: Check out dependent project antsibull-fileutils
uses: actions/checkout@v4
with:
repository: ansible-community/antsibull-fileutils
path: antsibull-fileutils

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
Expand All @@ -264,7 +297,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[coverage] ../antsibull-core ../antsibull-docs-parser
pip install -e .[coverage] ../antsibull-core ../antsibull-changelog ../antsibull-docs-parser ../antsibull-docutils ../antsibull-fileutils
working-directory: antsibull-docs

- name: Get hold of ansible.in file
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/nox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ jobs:
with:
repository: ansible-community/antsibull-docutils
path: antsibull-docutils
- name: Check out dependent project antsibull-fileutils
uses: actions/checkout@v4
with:
repository: ansible-community/antsibull-fileutils
path: antsibull-fileutils
- name: Install extra packages
if: "matrix.packages != ''"
run: |
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,20 @@ and install the requirements needed to run the tests there.

---

antsibull-docs depends on the sister antsibull-changelog, antsibull-core, and
antsibull-docs-parser projects.
antsibull-docs depends on the sister antsibull-changelog, antsibull-core,
antsibull-docs-parser, antsibull-docutils, and antsibull-fileutils projects.
By default, `nox` will install a development version of these projects from Github.
If you're hacking on antsibull-changelog, antsibull-core, antsibull-docs-parser, and/or
antsibull-docutils alongside antsibull-docs, nox will automatically install the projects
from `../antsibull-changelog`, `../antsibull-core`, `../antsibull-docs-parser`, and
`../antsibull-docutils` when running tests if those paths exist.
If you're hacking on antsibull-changelog, antsibull-core, antsibull-docs-parser,
antsibull-docutils, and/or antsibull-fileutils alongside antsibull-docs,
nox will automatically install the projects from `../antsibull-changelog`,
`../antsibull-core`, `../antsibull-docs-parser`, `../antsibull-docutils`,
and `../antsibull-fileutils` when running tests if those paths exist.
You can change this behavior through the `OTHER_ANTSIBULL_MODE` env var:

- `OTHER_ANTSIBULL_MODE=auto` — the default behavior described above
- `OTHER_ANTSIBULL_MODE=local` — install the projects from `../antsibull-changelog`,
`../antsibull-core`, `../antsibull-docs-parser`, and `../antsibull-docutils`.
`../antsibull-core`, `../antsibull-docs-parser`, `../antsibull-docutils`, and
`../antsibull-fileutils`.
Fail if those paths don't exist.
- `OTHER_ANTSIBULL_MODE=git` — install the projects from the Github main branch
- `OTHER_ANTSIBULL_MODE=pypi` — install the latest versions from PyPI
Expand Down
3 changes: 3 additions & 0 deletions changelogs/fragments/322-antsibull-fileutils.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
minor_changes:
- "Add dependency on antsibull-fileutils. Some functionality from antsibull-core is moving there, so we can use it from there directly
(https://github.com/ansible-community/antsibull-docs/pull/322)."
1 change: 1 addition & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def other_antsibull(
"antsibull-core",
"antsibull-docs-parser",
"antsibull-docutils",
"antsibull-fileutils",
)
for project in args:
path = Path("../", project)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies = [
"antsibull-changelog >= 0.24.0",
"antsibull-core >= 2.1.0, < 4.0.0",
"antsibull-docs-parser >= 1.1.0, < 2.0.0",
"antsibull-fileutils >= 1.0.0, < 2.0.0",
"asyncio-pool",
"docutils",
"jinja2 >= 3.0",
Expand Down
2 changes: 1 addition & 1 deletion src/antsibull_docs/collection_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import asyncio_pool # type: ignore[import]
from antsibull_core import app_context
from antsibull_core.logging import log
from antsibull_core.yaml import load_yaml_file
from antsibull_fileutils.yaml import load_yaml_file

from antsibull_docs._pydantic_compat import v1

Expand Down
2 changes: 1 addition & 1 deletion src/antsibull_docs/collection_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import asyncio_pool # type: ignore[import]
from antsibull_core import app_context
from antsibull_core.logging import log
from antsibull_core.yaml import load_yaml_file
from antsibull_fileutils.yaml import load_yaml_file

from antsibull_docs._pydantic_compat import v1

Expand Down
3 changes: 2 additions & 1 deletion src/antsibull_docs/docs_parsing/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
from collections.abc import Mapping, MutableMapping, Sequence

import asyncio_pool # type: ignore[import]
from antsibull_core import app_context, yaml
from antsibull_core import app_context
from antsibull_core.utils.collections import compare_all_but
from antsibull_fileutils import yaml

from ..constants import DOCUMENTABLE_PLUGINS
from ..utils.get_pkg_data import get_antsibull_data
Expand Down
2 changes: 1 addition & 1 deletion src/antsibull_docs/env_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import typing as t
from collections.abc import Generator, Mapping

from antsibull_core import yaml
from antsibull_fileutils import yaml

from .docs_parsing import AnsibleCollectionMetadata

Expand Down
4 changes: 2 additions & 2 deletions src/antsibull_docs/extra_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import asyncio_pool # type: ignore[import]
from antsibull_core import app_context
from antsibull_core.logging import log
from antsibull_core.utils.io import read_file
from antsibull_core.yaml import load_yaml_file
from antsibull_fileutils.io import read_file
from antsibull_fileutils.yaml import load_yaml_file

mlog = log.fields(mod=__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/antsibull_docs/lint_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import os.path
import typing as t

from antsibull_core.yaml import load_yaml_file
from antsibull_fileutils.yaml import load_yaml_file


def load_collection_info(path_to_collection: str) -> dict[str, t.Any]:
Expand Down
2 changes: 1 addition & 1 deletion src/antsibull_docs/schemas/docs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def handle_renamed_attribute(cls, values):
import typing as t
from collections.abc import Mapping

from antsibull_core.yaml import load_yaml_bytes
from antsibull_fileutils.yaml import load_yaml_bytes

from antsibull_docs._pydantic_compat import v1 as p
from antsibull_docs.vendored.ansible import ( # type: ignore[import]
Expand Down
17 changes: 13 additions & 4 deletions src/antsibull_docs/write_docs/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
from collections import defaultdict
from threading import Lock

from antsibull_core import app_context
from antsibull_core.logging import log
from antsibull_core.utils.io import copy_file as _copy_file
from antsibull_core.utils.io import write_file as _write_file
from antsibull_fileutils.io import copy_file as _copy_file
from antsibull_fileutils.io import write_file as _write_file

if t.TYPE_CHECKING:
from _typeshed import StrOrBytesPath
Expand Down Expand Up @@ -51,7 +52,8 @@ async def write_file(self, filename: StrOrBytesPath, /, content: str) -> None:
Write the given text content to a file (relative to our root).
"""
path = os.path.join(self.root, filename) # type: ignore
await _write_file(path, content)
lib_ctx = app_context.lib_ctx.get()
await _write_file(path, content, file_check_content=lib_ctx.file_check_content)

async def copy_file(
self,
Expand All @@ -66,7 +68,14 @@ async def copy_file(
(relative to our root).
"""
src_path = os.path.join(self.root, dest_path) # type: ignore
await _copy_file(source_path, src_path, check_content=check_content)
lib_ctx = app_context.lib_ctx.get()
await _copy_file(
source_path,
src_path,
check_content=check_content,
file_check_content=lib_ctx.file_check_content,
chunksize=lib_ctx.chunksize,
)


class TrackingOutput(Output):
Expand Down
2 changes: 1 addition & 1 deletion src/sphinx_antsibull_ext/directive_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import abc
import typing as t

from antsibull_core.yaml import load_yaml_bytes
from antsibull_fileutils.yaml import load_yaml_bytes
from docutils import nodes
from docutils.parsers.rst import Directive

Expand Down