diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef6a2ab..ff66d9b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,13 +13,15 @@ concurrency: cancel-in-progress: true jobs: - python: - if: ${{ (github.event_name == 'push' && startsWith(github.ref,'refs/heads/main')) || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && contains(github.event.pull_request.labels.*.name,'ready')) }} + linux: + name: linux (py=${{ matrix.python-version }}) runs-on: ubuntu-latest strategy: fail-fast: false matrix: - python-version: ['3.11','3.12'] + python-version: ["3.11","3.12"] + env: + PYTHONPATH: src steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -31,3 +33,21 @@ jobs: - run: black --check . - run: pytest -q - run: mypy . + + windows_optional: + name: windows (optional) + runs-on: windows-latest + continue-on-error: true + env: + PYTHONPATH: src + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + - run: python -m pip install -U pip + - run: pip install ruff black pytest mypy + - run: ruff check . + - run: black --check . + - run: pytest -q + - run: mypy . diff --git a/src/commit_guardian/__init__.py b/src/commit_guardian/__init__.py index 61d8083..18a159d 100644 --- a/src/commit_guardian/__init__.py +++ b/src/commit_guardian/__init__.py @@ -1,5 +1,6 @@ __all__ = ["ping", "__version__"] __version__ = "0.1.0" + def ping() -> str: return "pong" diff --git a/src/commit_guardian/cli.py b/src/commit_guardian/cli.py index 1841125..2e95176 100644 --- a/src/commit_guardian/cli.py +++ b/src/commit_guardian/cli.py @@ -1,8 +1,8 @@ from __future__ import annotations -import sys import click from . import __version__, ping + @click.command() @click.option("--version", is_flag=True, help="Show version and exit.") def main(version: bool) -> None: @@ -12,5 +12,6 @@ def main(version: bool) -> None: click.echo(ping()) raise SystemExit(0) + if __name__ == "__main__": main() diff --git a/tests/test_sanity.py b/tests/test_sanity.py index 3d243a5..1963bc1 100644 --- a/tests/test_sanity.py +++ b/tests/test_sanity.py @@ -1,4 +1,5 @@ import commit_guardian as cg + def test_ping() -> None: assert cg.ping() == "pong"