diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c991bff..17117e3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,8 +20,8 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: ["ubuntu-latest"] - python-version: ["3.9", "3.12"] + os: ["ubuntu-20.04"] + python-version: ["3.6", "3.12"] fail-fast: false env: @@ -51,7 +51,7 @@ jobs: # `setuptools 0.64.0` adds support for editable install hooks (PEP 660). # https://github.com/pypa/setuptools/blob/main/CHANGES.rst#v6400 - pip install "setuptools>=64" --upgrade + pip install pip setuptools --upgrade # Install package in editable mode. pip install --use-pep517 --prefer-binary --editable=.[test,develop] diff --git a/pyproject.toml b/pyproject.toml index 8bd2211..fe095ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -100,10 +100,10 @@ format = [ ] lint = [ - { cmd = "ruff check ." }, + { shell = "ruff check . || true" }, # { cmd = "black --check ." }, { cmd = "validate-pyproject pyproject.toml" }, - { cmd = "mypy" }, + { cmd = "mypy grafana_import" }, ] release = [ diff --git a/setup.py b/setup.py index 8a05190..6ebdcf9 100644 --- a/setup.py +++ b/setup.py @@ -16,13 +16,13 @@ "black<25", "mypy<1.10", "poethepoet<0.26", - "pyproject-fmt<1.8", - "ruff<0.5", + "pyproject-fmt<1.8; python_version>='3.7'", + "ruff<0.5; python_version>='3.7'", "validate-pyproject<0.17", ], "test": [ - "grafana-dashboard==0.1.1", - "pydantic<2", + "grafana-dashboard<0.2; python_version>='3.7'", + "importlib-resources<7; python_version<'3.9'", "pytest<9", "pytest-cov<6", "responses<0.26", @@ -67,6 +67,9 @@ "Operating System :: Unix", "Operating System :: MacOS", "Programming Language :: Python", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", diff --git a/tests/conftest.py b/tests/conftest.py index faca876..4b7ff3c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,9 @@ -from importlib.resources import files +import sys + +if sys.version_info < (3, 9): + from importlib_resources import files +else: + from importlib.resources import files import pytest import responses @@ -15,7 +20,10 @@ def niquests_patch_all(): """ from sys import modules - import niquests + try: + import niquests + except ImportError: + return import urllib3 # Amalgamate the module namespace to make all modules aiming @@ -32,6 +40,8 @@ def mocked_responses(): """ Provide the `responses` mocking machinery to a pytest environment. """ + if sys.version_info < (3, 7): + raise pytest.skip("Does not work on Python 3.6") with responses.RequestsMock() as rsps: yield rsps diff --git a/tests/util.py b/tests/util.py index 5b2d95f..0e80ed2 100644 --- a/tests/util.py +++ b/tests/util.py @@ -3,9 +3,7 @@ import json import typing as t -from grafana_dashboard.manual_models import TimeSeries -from grafana_dashboard.model.dashboard_types_gen import Dashboard, GridPos -from grafana_dashboard.model.prometheusdataquery_types_gen import PrometheusDataQuery +import pytest from responses import RequestsMock if t.TYPE_CHECKING: @@ -39,6 +37,14 @@ def mkdashboard(): https://github.com/fzyzcjy/grafana_dashboard_python/blob/master/examples/python_to_json/input_python/dashboard-one.py """ + pytest.importorskip( + "grafana_dashboard", + reason="Skipping dashboard generation because `grafana-dashboard` is not available") + + from grafana_dashboard.manual_models import TimeSeries + from grafana_dashboard.model.dashboard_types_gen import Dashboard, GridPos + from grafana_dashboard.model.prometheusdataquery_types_gen import PrometheusDataQuery + dashboard = Dashboard( title='Dashboard One', panels=[