Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc committed Feb 3, 2025
1 parent c247bcc commit f578122
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 13 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -75,16 +75,16 @@ 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'
#!/bin/sh
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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests_deb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
10 changes: 8 additions & 2 deletions test/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`
Expand All @@ -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()`
Expand Down
4 changes: 2 additions & 2 deletions test/tests/backends/iptables/test_iptables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)))
Expand Down
4 changes: 2 additions & 2 deletions test/tests/backends/nftables/test_nftables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)))
Expand Down
Empty file added test/tests/install/__init__.py
Empty file.
Empty file.
Empty file.
Empty file added test/tests/pkg/__init__.py
Empty file.

0 comments on commit f578122

Please sign in to comment.