diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 1deccef..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: test - -on: - push: - branches: [main, master] - pull_request: - branches: [main, master] - -concurrency: - group: test-${{ github.head_ref }} - cancel-in-progress: true - -env: - PYTHONUNBUFFERED: "1" - FORCE_COLOR: "1" - -jobs: - run: - name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install Hatch - run: pip install --upgrade hatch - - - name: Run tests - run: hatch run cov diff --git a/.github/workflows/type-check.yml b/.github/workflows/type-check.yml new file mode 100644 index 0000000..c93c350 --- /dev/null +++ b/.github/workflows/type-check.yml @@ -0,0 +1,30 @@ +name: Check static types + +on: + push: + branches: + - "**" + pull_request: + branches: + - "**" + +jobs: + run: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Install packages + run: | + pip install --upgrade pip + pip install -e '.[tests]' + pip install --upgrade mypy + + - name: Run mypy + run: mypy --show-traceback src/ diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml new file mode 100644 index 0000000..cb32518 --- /dev/null +++ b/.github/workflows/unit-test.yml @@ -0,0 +1,50 @@ +name: Run unit tests + +on: + push: + branches: + - "**" + pull_request: + branches: + - "**" + +concurrency: + group: unit-test-${{ github.head_ref }} + cancel-in-progress: true + +env: + PYTHONUNBUFFERED: "1" + FORCE_COLOR: "1" + +jobs: + run: + name: Python ${{ matrix.python-version }} on Linux + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python-version: ["3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install packages + run: | + pip install --upgrade pip + pip install -e '.[tests]' + pip list + + - name: Run tests + run: pytest -vv --cov --cov-report=xml + + # - name: Upload coverage to Codecov + # uses: codecov/codecov-action@v4 + # with: + # fail_ci_if_error: true + # verbose: true diff --git a/README.md b/README.md index 5e36820..a198da8 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ [![PyPI - Version](https://img.shields.io/pypi/v/nextline-alert.svg)](https://pypi.org/project/nextline-alert) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/nextline-alert.svg)](https://pypi.org/project/nextline-alert) +[![Test Status](https://github.com/simonsobs/nextline-alert/actions/workflows/unit-test.yml/badge.svg)](https://github.com/simonsobs/nextline-alert/actions/workflows/unit-test.yml) +[![Test Status](https://github.com/simonsobs/nextline-alert/actions/workflows/type-check.yml/badge.svg)](https://github.com/simonsobs/nextline-alert/actions/workflows/type-check.yml) A plugin for [nextline-graphql](https://github.com/simonsobs/nextline-graphql). Emit alerts to [Campana](https://github.com/simonsobs/campana) diff --git a/pyproject.toml b/pyproject.toml index ec24a1b..02979fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", ] -dependencies = ["httpx>=0.26"] +dependencies = ["nextline-graphql>=0.7.3", "httpx>=0.26"] dynamic = ["version"] [project.optional-dependencies] @@ -46,91 +46,10 @@ source = "regex_commit" path = "src/nextline_alert/__about__.py" tag_sign = false -[tool.hatch.envs.default] -dependencies = ["coverage[toml]>=6.5", "pytest"] -[tool.hatch.envs.default.scripts] -test = "pytest {args:tests}" -test-cov = "coverage run -m pytest {args:tests}" -cov-report = ["- coverage combine", "coverage report"] -cov = ["test-cov", "cov-report"] - -[[tool.hatch.envs.all.matrix]] -python = ["3.10", "3.11", "3.12"] - -[tool.hatch.envs.lint] -detached = true -dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"] -[tool.hatch.envs.lint.scripts] -typing = "mypy --install-types --non-interactive {args:src/nextline_alert tests}" -style = ["ruff {args:.}", "black --check --diff {args:.}"] -fmt = ["black {args:.}", "ruff --fix {args:.}", "style"] -all = ["style", "typing"] - [tool.black] skip-string-normalization = true target_version = ['py310', 'py311', 'py312'] -[tool.ruff] -target-version = "py37" -line-length = 120 -select = [ - "A", - "ARG", - "B", - "C", - "DTZ", - "E", - "EM", - "F", - "FBT", - "I", - "ICN", - "ISC", - "N", - "PLC", - "PLE", - "PLR", - "PLW", - "Q", - "RUF", - "S", - "T", - "TID", - "UP", - "W", - "YTT", -] -ignore = [ - # Allow non-abstract empty methods in abstract base classes - "B027", - # Allow boolean positional values in function calls, like `dict.get(... True)` - "FBT003", - # Ignore checks for possible passwords - "S105", - "S106", - "S107", - # Ignore complexity - "C901", - "PLR0911", - "PLR0912", - "PLR0913", - "PLR0915", -] -unfixable = [ - # Don't touch unused imports - "F401", -] - -[tool.ruff.isort] -known-first-party = ["nextline_alert"] - -[tool.ruff.flake8-tidy-imports] -ban-relative-imports = "all" - -[tool.ruff.per-file-ignores] -# Tests can use magic values, assertions, and relative imports -"tests/**/*" = ["PLR2004", "S101", "TID252"] - [tool.coverage.run] source_pkgs = ["nextline_alert", "tests"] branch = true @@ -144,7 +63,6 @@ tests = ["tests", "*/nextline-alert/tests"] [tool.coverage.report] exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"] - [tool.isort] profile = "black"