diff --git a/.github/workflows/integrationtest.yml b/.github/workflows/integrationtest.yml index 05aefd17..00138098 100644 --- a/.github/workflows/integrationtest.yml +++ b/.github/workflows/integrationtest.yml @@ -15,7 +15,7 @@ jobs: permissions: read-all strategy: matrix: - python-version: [ '3.10' ] + python-version: [ "3.12" ] steps: - uses: actions/checkout@v6 @@ -25,10 +25,12 @@ jobs: with: python-version: ${{ matrix.python-version }} architecture: x64 - cache: 'pip' - - name: Install the requirements - run: pip install -r requirements.txt + - name: Install uv + uses: astral-sh/setup-uv@v2 + + - name: Install the project with dev dependencies + run: uv sync --extra dev - name: Execute the integrationtests (http1.1) run: python3 -m unittest discover tests/integrationtest diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 2fab319e..4d4edf21 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.x'] + python-version: ["3.12"] steps: - name: Checkout the repository and the branch @@ -21,17 +21,12 @@ jobs: with: python-version: ${{ matrix.python-version }} architecture: x64 - cache: 'pip' - - name: Install the requirements - run: pip install -r requirements.txt && pip install setuptools~=65.5.1 mkdocs mkdocs-material + - name: Install uv + uses: astral-sh/setup-uv@v2 - - name: Install pypa/build - run: >- - python -m - pip install - build - --user + - name: Install build tools and documentation dependencies + run: uv sync --extra dev --extra docs - name: Build a binary wheel and a source tarball run: >- @@ -47,7 +42,7 @@ jobs: git config --local user.name "github-actions[bot]" - name: Update the GitHub pages documentation - run: cd docs && mkdocs gh-deploy --force && cd .. + run: cd docs && uv run mkdocs gh-deploy --force && cd .. - name: Publish distribution package to PyPI if: startsWith(github.ref, 'refs/tags') diff --git a/.github/workflows/pull-request-checks.yml b/.github/workflows/pull-request-checks.yml index 817bf4ea..e323dd88 100644 --- a/.github/workflows/pull-request-checks.yml +++ b/.github/workflows/pull-request-checks.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.10' ] + python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14" ] steps: - uses: actions/checkout@v6 @@ -20,10 +20,12 @@ jobs: with: python-version: ${{ matrix.python-version }} architecture: x64 - cache: 'pip' - - name: Install the requirements - run: pip install -r requirements.txt + - name: Install uv + uses: astral-sh/setup-uv@v2 + + - name: Install the project with dev dependencies + run: uv sync --extra dev - name: Execute the unittests run: python3 -m unittest discover tests/unittests @@ -33,7 +35,7 @@ jobs: permissions: write-all strategy: matrix: - python-version: [ '3.10' ] + python-version: [ "3.12" ] steps: - uses: actions/checkout@v6 @@ -43,21 +45,22 @@ jobs: with: python-version: ${{ matrix.python-version }} architecture: x64 - cache: 'pip' - - name: Execute the linting checks - uses: reviewdog/action-flake8@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - flake8_args: --config=.flake8 - fail_on_error: true + - name: Install uv + uses: astral-sh/setup-uv@v2 + + - name: Install ruff + run: uv sync --extra dev + + - name: Execute the linting checks with ruff + run: ruff check . pr-coverage: runs-on: ubuntu-latest permissions: write-all strategy: matrix: - python-version: [ '3.10' ] + python-version: [ "3.12" ] steps: - uses: actions/checkout@v6 @@ -70,10 +73,12 @@ jobs: with: python-version: ${{ matrix.python-version }} architecture: x64 - cache: 'pip' - - name: Install the requirements - run: pip install -r requirements.txt && pip install pytest-cov coverage-badge + - name: Install uv + uses: astral-sh/setup-uv@v2 + + - name: Install the project and coverage tools + run: uv sync --extra dev - name: Generate the coverage report run: export PYTHONPATH=$PWD && pytest --junitxml=pytest.xml --cov=. tests/unittests | tee pytest-coverage.txt @@ -117,7 +122,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.9' ] + python-version: [ "3.12" ] steps: - uses: actions/checkout@v6 @@ -130,10 +135,12 @@ jobs: with: python-version: ${{ matrix.python-version }} architecture: x64 - cache: 'pip' - - name: Install the requirements - run: pip install pydoc-markdown==4.6.3 mkdocs mkdocs-material + - name: Install uv + uses: astral-sh/setup-uv@v2 + + - name: Install documentation tools + run: uv sync --extra docs - name: Generate documentation run: pydoc-markdown --render-toc && rm -rf docs/content && mv build/docs/* docs diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..566dceed --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,65 @@ +[build-system] +requires = ["setuptools>=65.0.0", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "grafana-api-sdk" +version = "0.9.0" +description = "A Grafana API SDK" +readme = "README.md" +requires-python = ">=3.8" +license = { text = "Apache-2.0 License" } +authors = [ + { name = "Pascal Zimmermann", email = "info@theiotstudio.com" } +] +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved", + "Operating System :: OS Independent", +] +dependencies = ["httpx"] + +[project.optional-dependencies] +http2 = ["httpx[http2]"] +docs = ["pyyaml>=6.0.3", "pydoc-markdown", "mkdocs", "mkdocs-material"] +dev = ["build", "setuptools>=65.0.0", "wheel", "ruff>=0.5.0", "pytest", "pytest-httpx", "pytest-cov", "coverage-badge", "httpx[http2]", "setuptools>=65.0.0", "wheel"] + +[project.urls] +Source = "https://github.com/ZPascal/grafana_api_sdk" +"Bug Tracker" = "https://github.com/ZPascal/grafana_api_sdk/issues" +Documentation = "https://zpascal.github.io/grafana_api_sdk/" + +[tool.setuptools] +packages = ["grafana_api"] + +[tool.ruff] +line-length = 120 +target-version = "py38" + +[tool.ruff.lint] +select = ["B", "C", "D", "E", "F", "W", "T4", "B902", "B950"] +ignore = ["E203", "E266", "E501", "W503"] +exclude = [".venv", "venv", ".git"] + +[tool.ruff.lint.pylint] +max-args = 10 + +[tool.ruff.lint.mccabe] +max-complexity = 20 + +[tool.coverage.run] +branch = true +omit = ["*/setup.py"] +source = ["."] + +[tool.coverage.report] +fail_under = 80 +show_missing = true +skip_covered = false +exclude_lines = [ + "pragma: no cover", + "raise AssertionError", + "raise NotImplementedError", + "if __name__ == .__main__.:", +] + diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 52890642..00000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -httpx[http2] -pytest -pytest-httpx \ No newline at end of file