diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5fb1fa33..dcfa8c3b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -43,7 +43,7 @@ jobs: with: version: 0.5.24 enable-cache: true - cache-dependency-glob: "uv.lock" + cache-dependency-glob: "test/uv.lock" - name: "Set up Python" uses: actions/setup-python@v5 @@ -75,8 +75,8 @@ jobs: # - deb/rpm (on their own workflows) uv run pytest # these need root - uv run sudo -E pytest ./backends - uv run sudo -E pytest ./install/no_crowdsec + sudo -E $(which uv) run pytest ./tests/backends + sudo -E $(which uv) run pytest ./tests/install/no_crowdsec # these need a running crowdsec docker run -d --name crowdsec -e CI_TESTING=true -e DISABLE_ONLINE_API=true -ti crowdsecurity/crowdsec install -m 0755 /dev/stdin /usr/local/bin/cscli <<'EOT' @@ -84,7 +84,7 @@ jobs: docker exec crowdsec cscli "$@" EOT sleep 5 - uv run sudo -E pytest ./install/with_crowdsec + sudo -E $(which uv) run pytest ./tests/install/with_crowdsec - name: Lint working-directory: ./test diff --git a/.github/workflows/tests_deb.yml b/.github/workflows/tests_deb.yml index 9cb11e16..790dcb5d 100644 --- a/.github/workflows/tests_deb.yml +++ b/.github/workflows/tests_deb.yml @@ -31,7 +31,7 @@ jobs: with: version: 0.5.24 enable-cache: true - cache-dependency-glob: "uv.lock" + cache-dependency-glob: "test/uv.lock" - name: "Set up Python" uses: actions/setup-python@v5 @@ -57,5 +57,5 @@ jobs: PYTEST_ADDOPTS: --durations=0 -vv --color=yes working-directory: ./test run: | - uv run pytest ./pkg/test_build_deb.py - uv run sudo -E pytest -m deb ./install/no_crowdsec + uv run pytest ./tests/pkg/test_build_deb.py + sudo -E $(which uv) run pytest -m deb ./tests/install/no_crowdsec diff --git a/test/pyproject.toml b/test/pyproject.toml index 3e19d5ab..b77e0969 100644 --- a/test/pyproject.toml +++ b/test/pyproject.toml @@ -50,12 +50,17 @@ ignore = [ "D104", # Missing docstring in public package #"D105", # Missing docstring in magic method #"D107", # Missing docstring in __init__ + "D202", # No blank lines allowed after function docstring (found 1) #"D203", # incorrect-blank-line-before-class + "D212", # Multi-line docstring summary should start at the first line #"D213", # multi-line-summary-second-line + "D212", # Multi-line docstring summary should start at the first line + "D400", # First line should end with a period + "D415", # First line should end with a period, question mark, or exclamation point #"EM101", # Exception must not use a string literal, assign to variable first #"EM102", # Exception must not use an f-string literal, assign to variable first "ERA001", # Found commented-out code - #"FIX002", # Line contains TODO, consider resolving the issue + "FIX002", # Line contains TODO, consider resolving the issue "FIX003", # Line contains XXX, consider resolving the issue #"N801", # Class name `log_waiters` should use CapWords convention #"PLW0603", # Using the global statement to update `...` is discouraged @@ -64,7 +69,7 @@ ignore = [ "S101", # Use of 'assert' detected #"S113", # Probable use of `requests` call without timeout "S603", # `subprocess` call: check for execution of untrusted input - #"S607", # Starting a process with a partial executable path + "S607", # Starting a process with a partial executable path #"SIM105", # Use `contextlib.suppress(FileNotFoundError)` instead of `try`-`except`-`pass` #"T201", # `print` found "TD001", # Invalid TODO tag: `XXX` @@ -76,6 +81,7 @@ ignore = [ #"TRY003", # Avoid specifying long messages outside the exception class "PLR2004", # Magic value used in comparison, consider replacing `...` with a constant variable "PTH107", # `os.remove()` should be replaced by `Path.unlink()` + "PTH108", # `os.unlink()` should be replaced by `Path.unlink()` "PTH110", # `os.path.exists()` should be replaced by `Path.exists()` "PTH116", # `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` "PTH123", # `open()` should be replaced by `Path.open()` diff --git a/test/tests/backends/iptables/test_iptables.py b/test/tests/backends/iptables/test_iptables.py index bb269137..320260fa 100644 --- a/test/tests/backends/iptables/test_iptables.py +++ b/test/tests/backends/iptables/test_iptables.py @@ -6,8 +6,8 @@ from pathlib import Path from time import sleep -from tests.backends.mock_lapi import MockLAPI -from tests.backends.utils import generate_n_decisions, run_cmd, new_decision +from ..mock_lapi import MockLAPI +from ..utils import generate_n_decisions, run_cmd, new_decision SCRIPT_DIR = Path(os.path.dirname(os.path.realpath(__file__))) diff --git a/test/tests/backends/nftables/test_nftables.py b/test/tests/backends/nftables/test_nftables.py index 5e719049..331fd528 100644 --- a/test/tests/backends/nftables/test_nftables.py +++ b/test/tests/backends/nftables/test_nftables.py @@ -6,8 +6,8 @@ from pathlib import Path from time import sleep -from tests.backends.mock_lapi import MockLAPI -from tests.backends.utils import generate_n_decisions, run_cmd +from ..mock_lapi import MockLAPI +from ..utils import generate_n_decisions, run_cmd SCRIPT_DIR = Path(os.path.dirname(os.path.realpath(__file__))) diff --git a/test/tests/install/__init__.py b/test/tests/install/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/test/tests/install/no_crowdsec/__init__.py b/test/tests/install/no_crowdsec/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/test/tests/install/with_crowdsec/__init__.py b/test/tests/install/with_crowdsec/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/test/tests/pkg/__init__.py b/test/tests/pkg/__init__.py new file mode 100644 index 00000000..e69de29b