Skip to content

Commit

Permalink
Merge branch 'main' into iquwarah-tmt-try-epel
Browse files Browse the repository at this point in the history
  • Loading branch information
falconizmi authored Jul 1, 2024
2 parents 83d190f + 76b5ff2 commit 35e9865
Show file tree
Hide file tree
Showing 51 changed files with 350 additions and 236 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ docs/plugins/test-checks.rst
docs/_build
docs/spec
docs/stories
docs/_static/tmt-small.png

# Python

Expand Down
23 changes: 21 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ repos:
- "docutils>=0.16" # 0.16 is the current one available for RHEL9
- "fmf>=1.3.0"
- "jinja2>=2.11.3" # 3.1.2 / 3.1.2
- "pint>=0.16.1,<0.20" # 0.16.1 / 0.19.x TODO: Pint 0.20 requires larger changes to tmt.hardware
- "pint>=0.16.1" # 0.16.1
- "pygments>=2.7.4" # 2.7.4 is the current one available for RHEL9
- "requests>=2.25.1" # 2.28.2 / 2.31.0
- "ruamel.yaml>=0.16.6" # 0.17.32 / 0.17.32
Expand Down Expand Up @@ -81,7 +81,7 @@ repos:
- "docutils>=0.16" # 0.16 is the current one available for RHEL9
- "fmf>=1.3.0"
- "jinja2>=2.11.3" # 3.1.2 / 3.1.2
- "pint>=0.16.1,<0.20" # 0.16.1 / 0.19.x TODO: Pint 0.20 requires larger changes to tmt.hardware
- "pint>=0.16.1" # 0.16.1 / 0.19.x TODO: Pint 0.20 requires larger changes to tmt.hardware
- "pygments>=2.7.4" # 2.7.4 is the current one available for RHEL9
- "requests>=2.25.1" # 2.28.2 / 2.31.0
- "ruamel.yaml>=0.16.6" # 0.17.32 / 0.17.32
Expand Down Expand Up @@ -161,3 +161,22 @@ repos:
- id: codespell
additional_dependencies:
- tomli # Required for python < 3.11

- repo: https://github.com/djlint/djLint
rev: v1.34.1
hooks:
- id: djlint
files: "\\.j2"
types_or: ['jinja']

- repo: https://github.com/aristanetworks/j2lint.git
rev: v1.1.0
hooks:
- id: j2lint
args:
# j2lint does not consume pyproject.toml
- "--ignore"
- jinja-statements-indentation
- jinja-variable-lower-case
- single-statement-per-line
- "--"
12 changes: 11 additions & 1 deletion containers/fedora/coreos/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,14 @@ RUN rpm-ostree install dnf5 \
# Remove diffutils as its used in many package manager tests, and tests
# are simpler if all environments lack the same package, we don't have
# to parametrize them even more.
&& dnf5 remove -y diffutils
# Do *NOT* use dnf5 to remove this package - it might create conflicts
# in /var/lib/dnf should the next command called be `debuginfo-install`
# or any other dnf4-ish command.
&& rpm-ostree uninstall diffutils \
# Removing diffutils, these need to be removed too.
containers-common-extra \
passt \
passt-selinux \
podman \
policycoreutils \
toolbox
12 changes: 11 additions & 1 deletion containers/fedora/coreos/ostree/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ RUN rpm-ostree install dnf5 \
# Remove diffutils as its used in many package manager tests, and tests
# are simpler if all environments lack the same package, we don't have
# to parametrize them even more.
&& dnf5 remove -y diffutils \
# Do *NOT* use dnf5 to remove this package - it might create conflicts
# in /var/lib/dnf should the next command called be `debuginfo-install`
# or any other dnf4-ish command.
&& rpm-ostree uninstall diffutils \
# Removing diffutils, these need to be removed too.
containers-common-extra \
passt \
passt-selinux \
podman \
policycoreutils \
toolbox \
# Simulate ostree-booted environment
&& touch /run/ostree-booted
12 changes: 10 additions & 2 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
.DEFAULT_GOAL := help
.PHONY: help generate-plugins plugins/*.rst generate-stories generate-template-filters generate-autodocs clean

LOGO_SRC = https://raw.githubusercontent.com/teemtee/docs/main/logo/tmt-small.png
LOGO_DST = _static/tmt-small.png

clean:
rm -rf _build stories spec code/autodocs/*.rst code/template-filters.rst
rm -rf _build stories spec code/autodocs/*.rst code/template-filters.rst $(LOGO_DST)
find plugins -name "*.rst" ! -name index.rst | xargs rm -f

##
Expand All @@ -18,7 +21,12 @@ TEMPLATESDIR = templates

PLUGINS_TEMPLATE := $(TEMPLATESDIR)/plugins.rst.j2

generate: spec stories generate-lint-checks generate-template-filters generate-plugins generate-stories generate-autodocs ## Refresh all generated documentation sources
generate: $(LOGO_DST) spec stories generate-lint-checks generate-template-filters generate-plugins generate-stories generate-autodocs ## Refresh all generated documentation sources

# We can ignore the error: later, during the build, if the logo is
# missing, Sphinx will complain.
$(LOGO_DST):
-curl -f $(LOGO_SRC) -o $(LOGO_DST)

spec:
mkdir -p spec
Expand Down
2 changes: 2 additions & 0 deletions docs/codespell.ignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Override the parent implementation - it would try to call `Tree.storys()`...
passt \
passt-selinux \
11 changes: 7 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import subprocess
import sys
from pathlib import Path
from typing import TYPE_CHECKING, Optional
from typing import TYPE_CHECKING, Any, Optional

if TYPE_CHECKING:
from sphinx.application import Sphinx
Expand Down Expand Up @@ -222,7 +222,7 @@ def _load_theme(
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
# html_favicon = None
html_favicon = '_static/tmt-small.png'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand Down Expand Up @@ -313,12 +313,15 @@ def _load_theme(
]


def generate_tmt_docs(app: Sphinx) -> None:
def generate_tmt_docs(app: Sphinx, config: Any) -> None:
""" Run `make generate` to populate the auto-generated sources """

conf_dir = Path(app.confdir)
subprocess.run(["make", "generate"], cwd=conf_dir)


def setup(app: Sphinx) -> None:
app.connect("builder-inited", generate_tmt_docs)
# Generate sources after loading configuration. That should build
# everything, including the logo, before Sphinx starts checking
# whether all input files exist.
app.connect("config-inited", generate_tmt_docs)
2 changes: 1 addition & 1 deletion docs/templates/lint-checks.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Below you can find the list of available checks. See the
- {{ linter.help }}

{% endfor %}
{% endmacro%}
{% endmacro %}

{{ emit_table('Test checks', TEST_LINTERS) }}
{{ emit_table('Plan checks', PLAN_LINTERS) }}
Expand Down
4 changes: 2 additions & 2 deletions docs/templates/plugins.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
.. _plugins/{{ STEP }}/{{ PLUGIN_ID | trim }}:

{{ PLUGIN_ID }}
{{ '-' * (PLUGIN_ID | length)}}
{{ '-' * (PLUGIN_ID | length) }}

{# Emit the warning only for plugins that have not been reviewed yet. #}
{% set plugin_full_id = STEP + "/" + PLUGIN_ID %}
Expand Down Expand Up @@ -65,7 +65,7 @@ Configuration
Default: *could not render default value correctly*
{% endif %}
{% endif %}
{%endmacro %}
{% endmacro %}

{% set ignored_fields = container_ignored_fields(PLUGIN_DATA_CLASS) %}
{% set inherited_fields = container_inherited_fields(PLUGIN_DATA_CLASS) | sort %}
Expand Down
2 changes: 1 addition & 1 deletion docs/templates/story.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@

{# Links pointing to websites #}
{% elif link.target | match('^https?://') %}
* {{ printable_relation(link) }} `{{ link.target}} <{{ link.target }}>`_
* {{ printable_relation(link) }} `{{ link.target }} <{{ link.target }}>`_

{# Links pointing to anything else #}
{% else %}
Expand Down
2 changes: 1 addition & 1 deletion docs/templates/template-filters.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ __ https://jinja.palletsprojects.com/en/3.1.x/templates/#filters
{% set filter_callable = TEMPLATES[filter_name] %}

{{ filter_name }}
{{ '-' * (filter_name | length)}}
{{ '-' * (filter_name | length) }}

{% if filter_callable.__doc__ %}
{{ filter_callable.__doc__ | dedent | trim }}
Expand Down
65 changes: 49 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies = [ # F39 / PyPI
"docutils>=0.16", # 0.16 is the current one available for RHEL9
"fmf>=1.3.0",
"jinja2>=2.11.3", # 3.1.2 / 3.1.2
"pint>=0.16.1,<0.20", # 0.16.1 / 0.19.x TODO: Pint 0.20 requires larger changes to tmt.hardware
"pint>=0.16.1", # 0.16.1
"pygments>=2.7.4", # 2.7.4 is the current one available for RHEL9
"requests>=2.25.1", # 2.28.2 / 2.31.0
"ruamel.yaml>=0.16.6", # 0.17.32 / 0.17.32
Expand Down Expand Up @@ -249,7 +249,8 @@ ignore = [
"tmt/convert.py",
"tmt/lint.py",
"tmt/queue.py",
"tmt/utils.py"
"tmt/utils.py",
"tmt/hardware.py", # pyright does not pick up pint's _typing.py or something :/
]

pythonVersion = "3.9"
Expand Down Expand Up @@ -281,45 +282,59 @@ src = ["tmt", "tests"]
target-version = "py39"
lint.select = [
"F", # pyflakes
"E", # pycodestyle
"W", # pycodestyle
"E", # pycodestyle error
"W", # pycodestyle warning
"I", # isort
"N", # pep8-naming
"D", # pydocstyle
"UP", # pyupgrade
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"YTT", # flake8-2020
"PT", # flake8-pytest-style
"RET", # flake8-return
"SIM", # flake8-simplify
"ASYNC", # flake8-async
"S", # flake8-bandit
"B", # flake8-bugbear
"A", # flake8-builtins
"COM", # flake8-commas
"C4", # flake8-comprehensions
"DTZ", # flake8-datetimez
"T10", # flake8-debugger
"EXE", # flake8-executable
"ISC", # flake8-implicit-str-concat
"ICN", # flake8-import-conventions
"LOG", # flake8-logging
"G", # flake8-logging-format
"PIE", # flake8-pie
"PYI", # flake8-pyi
"PT", # flake8-pytest-style
"Q003", # avoidable-escaped-quote
"Q004", # unnecessary-escaped-quote
"RSE", # flake8-raise
"RET", # flake8-return
"SIM", # flake8-simplify
"TID", # flake8-tidy-imports
"INT", # flake8-gettext
"PGH", # pygrep-hooks
"PLC", # pylint-convention
"PLE", # pylint-error
"PLR01", # pylint-refactor
"PLR02",
"PLR04",
"PLR1",
"PLR", # pylint-refactor
"RUF", # ruff
"D", # pydocstyle
]
lint.ignore = [
"B904", # Within an `except` clause, raise exceptions with `raise ... from err` or `raise ...
"COM812", # Trailing comma missing
# tmt codebase uses `warn` by default - disabling the check, switching to
# `warning` can be done in an extra patch.
"G010", # `warn` is deprecated in favor of `warning`
"G004", # Logging statement uses f-string
"PIE790", # Unnecessary `pass` statement
"PLC1901", # `{}` can be simplified to `{}` as an empty string is falsey
"PLE1205", # Too many arguments for `logging` format string
"PLR09", # Too many branches/statements/arguments/returns
"PLR2004", # Magic value used in comparison
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"RUF013", # PEP 484 prohibits implicit `Optional`
# flake8-bandit (S) https://docs.astral.sh/ruff/rules/#flake8-bandit-s
"S101", # Use of `assert` detected
"S603", # `subprocess` call: check for execution of untrusted input
"S607", # Starting a process with a partial executable path
"S105", # Possible hardcoded password assigned to: "PASS"

# pydocstyle
# TODO: the permanent list (drop this comment once the temporary list
Expand All @@ -345,6 +360,17 @@ lint.ignore = [
"D415", # First line should end with a period, question mark, or exclamation point
]

lint.logger-objects = ["tmt.log.Logger"]

[tool.ruff.lint.per-file-ignores]
# Less strict security checks in tests
"tests/unit*" = [
"S604", # Function call with shell=True parameter identified, security issue
"S605", # Starting a process with a shell: seems safe, but may be changed in the future
"S318", # Using xml to parse untrusted data is known to be vulnerable to XML attacks
"S108", # Probable insecure usage of temporary file or directory: "{}"
]

[tool.ruff.lint.flake8-bugbear]
extend-immutable-calls = ["tmt.utils.field"]

Expand All @@ -358,6 +384,9 @@ extend-immutable-calls = ["tmt.utils.field"]
convention = "pep257"
property-decorators = ["tmt.utils.cached_property"]

[tool.ruff.lint.flake8-builtins]
builtins-ignorelist = ["help", "format", "input", "filter", "copyright", "max"]

[tool.ruff.lint.isort]
known-first-party = ["tmt"]

Expand All @@ -371,3 +400,7 @@ markers = [
ignore-words = "docs/codespell.dic"
exclude-file = "docs/codespell.ignore"
skip = "tests/execute/weird/data/weird.txt,tests/lint/plan/data/invalid_attr.fmf,tests/lint/plan/test.sh"

[tool.djlint]
use_gitignore=true
ignore="H005,H030,H031"
7 changes: 3 additions & 4 deletions tests/integration/test_nitrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
import tmt.base
import tmt.cli
import tmt.log
from tests import CliRunner
from tmt.utils import ConvertError, Path

from .. import CliRunner

# Prepare path to examples
TEST_DIR = Path(__file__).parent

Expand All @@ -24,8 +23,8 @@ class Base(RequreTestCase):

def setUp(self):
super().setUp()
self.tmpdir = Path(tempfile.mktemp(prefix=str(TEST_DIR)))
shutil.copytree(self.EXAMPLES, self.tmpdir)
self.tmpdir = Path(tempfile.mkdtemp(prefix=str(TEST_DIR)))
shutil.copytree(self.EXAMPLES, self.tmpdir, dirs_exist_ok=True)
self.cwd = os.getcwd()
self.runner_output = None

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_polarion.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from fmf import Tree

import tmt.cli
from tests import CliRunner
from tmt.identifier import ID_KEY

from .. import CliRunner
from .test_nitrate import TEST_DIR, Base


Expand Down
6 changes: 6 additions & 0 deletions tests/pip/install.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ require:
- python3
- python3-devel
tier: null
adjust:
when: distro == fedora-rawhide
result: xfail
# 'mini' should start passing once https://github.com/hgrecco/pint/issues/1969 is resolved
# if/once that happens, the xfail should be moved to 'full' only
because: "Un-installable dependencies on Python 3.13"

/mini:
summary: Ensure the minimal pip install works
Expand Down
6 changes: 6 additions & 0 deletions tests/precommit/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ require:
- git-core
- tmt
tier: 4
adjust:
when: distro == fedora-rawhide
result: xfail
# Remove the xfail adjust once it starts passing.
# Dependent on https://github.com/crate-py/rpds/issues/72, PyO3 0.22
because: "Un-installable dependencies on Python 3.13"
Loading

0 comments on commit 35e9865

Please sign in to comment.