ci: lint + format + test on push
fix: ensure ci lints all source files chore: formatting
This commit is contained in:
parent
dc57ecd228
commit
3cb85ec3cb
9 changed files with 77 additions and 31 deletions
|
@ -6,26 +6,31 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-python@v2
|
- uses: https://github.com/actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: 3.12
|
python-version: 3.12
|
||||||
- run: |
|
- run: |
|
||||||
pip install -r ./requirements.txt
|
pip install -r ./requirements.txt
|
||||||
pip install -r ./requirements_sast.txt
|
pip install -r ./requirements_dev.txt
|
||||||
- name: Formatting
|
- name: Formatting
|
||||||
run: python -m black .
|
run: python -m black . --check
|
||||||
|
- name: Import sort
|
||||||
|
run: python -m isort .
|
||||||
- name: Linting
|
- name: Linting
|
||||||
run: python -m pylint .
|
run: python -m pylint **/*.py
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: Tests
|
name: Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-python@v2
|
with:
|
||||||
|
github-server-url: https://forge.karnov.club
|
||||||
|
- uses: https://github.com/actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: 3.12
|
python-version: 3.12
|
||||||
- run: |
|
- run: |
|
||||||
pip install -r ./requirements.txt
|
python -m pip install -r ./requirements.txt
|
||||||
pip install -r ./requirements_test.txt
|
python -m pip install -r ./requirements_test.txt
|
||||||
- name: Test suites
|
- name: Test suites
|
||||||
run: python -m pytest
|
run: python -m pytest
|
||||||
|
|
|
@ -13,7 +13,8 @@ dependencies = [
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
sast = [
|
sast = [
|
||||||
"black",
|
"black",
|
||||||
"pylint"
|
"pylint",
|
||||||
|
"isort"
|
||||||
]
|
]
|
||||||
test = [
|
test = [
|
||||||
"pytest"
|
"pytest"
|
||||||
|
@ -25,3 +26,16 @@ spud = "spud.cli:cli"
|
||||||
[tool.setuptools]
|
[tool.setuptools]
|
||||||
packages = ["spud"]
|
packages = ["spud"]
|
||||||
|
|
||||||
|
[tool.pylint.main]
|
||||||
|
ignore = ["spud.venv"]
|
||||||
|
ignore-paths = ["spud.venv"]
|
||||||
|
jobs = 0
|
||||||
|
disable = [
|
||||||
|
"missing-function-docstring",
|
||||||
|
"missing-module-docstring",
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.isort]
|
||||||
|
skip = [
|
||||||
|
"spud.venv",
|
||||||
|
]
|
||||||
|
|
|
@ -54,7 +54,9 @@ idna==3.7
|
||||||
iniconfig==2.0.0
|
iniconfig==2.0.0
|
||||||
# via pytest
|
# via pytest
|
||||||
isort==5.13.2
|
isort==5.13.2
|
||||||
# via pylint
|
# via
|
||||||
|
# pylint
|
||||||
|
# spud (pyproject.toml)
|
||||||
mccabe==0.7.0
|
mccabe==0.7.0
|
||||||
# via pylint
|
# via pylint
|
||||||
mypy-extensions==1.0.0
|
mypy-extensions==1.0.0
|
||||||
|
|
|
@ -52,7 +52,9 @@ idna==3.7
|
||||||
# anyio
|
# anyio
|
||||||
# httpx
|
# httpx
|
||||||
isort==5.13.2
|
isort==5.13.2
|
||||||
# via pylint
|
# via
|
||||||
|
# pylint
|
||||||
|
# spud (pyproject.toml)
|
||||||
mccabe==0.7.0
|
mccabe==0.7.0
|
||||||
# via pylint
|
# via pylint
|
||||||
mypy-extensions==1.0.0
|
mypy-extensions==1.0.0
|
||||||
|
|
|
@ -52,7 +52,9 @@ idna==3.7
|
||||||
# anyio
|
# anyio
|
||||||
# httpx
|
# httpx
|
||||||
isort==5.13.2
|
isort==5.13.2
|
||||||
# via pylint
|
# via
|
||||||
|
# pylint
|
||||||
|
# spud (pyproject.toml)
|
||||||
mccabe==0.7.0
|
mccabe==0.7.0
|
||||||
# via pylint
|
# via pylint
|
||||||
mypy-extensions==1.0.0
|
mypy-extensions==1.0.0
|
||||||
|
|
|
@ -28,6 +28,10 @@ python -m piptools compile \
|
||||||
python -m piptools compile \
|
python -m piptools compile \
|
||||||
-o requirements_test.txt \
|
-o requirements_test.txt \
|
||||||
--no-header \
|
--no-header \
|
||||||
--extra sast \
|
--extra tes# This is the commit message #2:
|
||||||
|
|
||||||
|
chore: formatting
|
||||||
|
|
||||||
|
t \
|
||||||
--constraint requirements.txt \
|
--constraint requirements.txt \
|
||||||
pyproject.toml
|
pyproject.toml
|
||||||
|
|
|
@ -3,8 +3,9 @@ Command-line application entry-point.
|
||||||
|
|
||||||
Logic for the command-line spud tooling.
|
Logic for the command-line spud tooling.
|
||||||
"""
|
"""
|
||||||
import pathlib
|
|
||||||
import json
|
import json
|
||||||
|
import pathlib
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
import pytest
|
|
||||||
import click.testing
|
import click.testing
|
||||||
import importlib
|
import pytest
|
||||||
|
|
||||||
import spud.cli
|
import spud.cli
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_default_config_path(monkeypatch, tmpdir):
|
def mock_default_config_path(monkeypatch, tmpdir):
|
||||||
monkeypatch.setattr(spud.cli, "DEFAULT_CONFIGURATION_PATH", tmpdir / ".config" / "spud" / "config.json")
|
monkeypatch.setattr(
|
||||||
|
spud.cli,
|
||||||
|
"DEFAULT_CONFIGURATION_PATH",
|
||||||
|
tmpdir / ".config" / "spud" / "config.json",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="invoke_cli")
|
@pytest.fixture(name="invoke_cli")
|
||||||
|
|
|
@ -1,40 +1,52 @@
|
||||||
import pytest
|
|
||||||
import click
|
|
||||||
|
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
def test_init_raises_if_config_file_exists_default_path(invoke_cli, tmpdir, monkeypatch):
|
|
||||||
|
def test_init_raises_if_config_file_exists_default_path(invoke_cli, tmpdir):
|
||||||
expected_default_path = tmpdir / ".config" / "spud" / "config.json"
|
expected_default_path = tmpdir / ".config" / "spud" / "config.json"
|
||||||
|
|
||||||
pathlib.Path(expected_default_path).parent.mkdir(parents=True)
|
pathlib.Path(expected_default_path).parent.mkdir(parents=True)
|
||||||
expected_default_path.write("{}")
|
expected_default_path.write("{}")
|
||||||
|
|
||||||
result = invoke_cli(["init"])
|
result = invoke_cli(["init"])
|
||||||
|
|
||||||
assert result.exit_code == 1
|
|
||||||
assert str(result.exception) == f"File already exists ({str(expected_default_path)}), cannot initialize."
|
|
||||||
|
|
||||||
def test_init_raises_if_config_file_exists_custom_path(invoke_cli, tmpdir, monkeypatch):
|
assert result.exit_code == 1
|
||||||
|
assert (
|
||||||
|
str(result.exception)
|
||||||
|
== f"File already exists ({str(expected_default_path)}), cannot initialize."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_init_raises_if_config_file_exists_custom_path(invoke_cli, tmpdir):
|
||||||
expected_default_path = tmpdir / "config.json"
|
expected_default_path = tmpdir / "config.json"
|
||||||
|
|
||||||
expected_default_path.write("{}")
|
expected_default_path.write("{}")
|
||||||
|
|
||||||
result = invoke_cli(["--config", str(expected_default_path), "init"])
|
result = invoke_cli(["--config", str(expected_default_path), "init"])
|
||||||
|
|
||||||
assert result.exit_code == 1
|
|
||||||
assert str(result.exception) == f"File already exists ({str(expected_default_path)}), cannot initialize."
|
|
||||||
|
|
||||||
def test_print_config_raises_if_no_config_file_default_path(invoke_cli, tmpdir, monkeypatch):
|
assert result.exit_code == 1
|
||||||
|
assert (
|
||||||
|
str(result.exception)
|
||||||
|
== f"File already exists ({str(expected_default_path)}), cannot initialize."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_print_config_raises_if_no_config_file_default_path(invoke_cli, tmpdir):
|
||||||
expected_default_path = tmpdir / ".config" / "spud" / "config.json"
|
expected_default_path = tmpdir / ".config" / "spud" / "config.json"
|
||||||
result = invoke_cli(["print-config"])
|
result = invoke_cli(["print-config"])
|
||||||
|
|
||||||
assert result.exit_code == 1
|
assert result.exit_code == 1
|
||||||
assert str(result.exception) == f"Configuration file not found at {str(expected_default_path)}."
|
assert (
|
||||||
|
str(result.exception)
|
||||||
|
== f"Configuration file not found at {str(expected_default_path)}."
|
||||||
|
)
|
||||||
|
|
||||||
def test_print_config_raises_if_no_config_file_custom_path(invoke_cli, tmpdir, monkeypatch):
|
|
||||||
|
def test_print_config_raises_if_no_config_file_custom_path(invoke_cli, tmpdir):
|
||||||
config_file = tmpdir / "config.json"
|
config_file = tmpdir / "config.json"
|
||||||
|
|
||||||
result = invoke_cli(["--config", str(config_file), "print-config"])
|
result = invoke_cli(["--config", str(config_file), "print-config"])
|
||||||
|
|
||||||
assert result.exit_code == 1
|
assert result.exit_code == 1
|
||||||
assert str(result.exception) == f"Configuration file not found at {str(config_file)}."
|
assert (
|
||||||
|
str(result.exception) == f"Configuration file not found at {str(config_file)}."
|
||||||
|
)
|
||||||
|
|
Reference in a new issue