From 9f53a57f472ff208db2538274bea40dacded141d Mon Sep 17 00:00:00 2001 From: Mario Hernandez Date: Sat, 21 Dec 2024 23:34:25 -0300 Subject: [PATCH] CI/CD stuff --- .github/workflows/new_release.yml | 86 ++++++++++++++++++++++++++++ .github/workflows/tests_coverage.yml | 54 +++++++++++++++++ pyproject.toml | 34 ++++++++++- tests/test_core.py | 5 ++ 4 files changed, 176 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/new_release.yml create mode 100644 .github/workflows/tests_coverage.yml create mode 100644 tests/test_core.py diff --git a/.github/workflows/new_release.yml b/.github/workflows/new_release.yml new file mode 100644 index 0000000..f9bc655 --- /dev/null +++ b/.github/workflows/new_release.yml @@ -0,0 +1,86 @@ +name: New Release + +on: + release: + types: [published] + +permissions: + contents: write + +jobs: + crosscheck: + strategy: + fail-fast: false + matrix: + python-version: ["3.10"] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: Set up uv + uses: astral-sh/setup-uv@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install the project + run: uv sync --all-extras --dev + + - name: Tests + run: pytest -sv + + docs: + strategy: + fail-fast: false + matrix: + python-version: ["3.10"] + poetry-version: ["1.8.3"] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + needs: crosscheck + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Set Up Poetry + uses: abatilo/actions-poetry@v3 + with: + poetry-version: ${{ matrix.poetry-version }} + - name: Setup Latest Poetry + run: pipx install --suffix @main 'poetry @ git+https://github.com/python-poetry/poetry' + - name: Install django-payments-chile + run: poetry@main install --all-extras --all-groups + - name: Deploy Docs + run: poetry@main run mkdocs gh-deploy --force + + pypi-publish: + name: Build and Upload + strategy: + fail-fast: false + matrix: + python-version: ["3.10"] + poetry-version: ["1.8.3"] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + needs: crosscheck + environment: + name: pypi + url: https://pypi.org/p/khipu-tools + permissions: + id-token: write + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + - name: Set Up Poetry + uses: abatilo/actions-poetry@v3 + - name: Setup Latest Poetry + run: pipx install --suffix @main 'poetry @ git+https://github.com/python-poetry/poetry' + - name: Install khipu-tools + run: poetry@main install --all-extras --all-groups + - name: Build khipu-tools + run: poetry@main build + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/tests_coverage.yml b/.github/workflows/tests_coverage.yml new file mode 100644 index 0000000..d293110 --- /dev/null +++ b/.github/workflows/tests_coverage.yml @@ -0,0 +1,54 @@ +name: Tests & Coverage + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +jobs: + build: + name: build (Python ${{ matrix.python-version }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + max-parallel: 5 + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Get pip cache dir + id: pip-cache + run: | + echo "::set-output name=dir::$(pip cache dir)" + + - name: Cache + uses: actions/cache@v4 + with: + path: ${{ steps.pip-cache.outputs.dir }} + key: ${{ matrix.python-version }}-v1-${{ hashFiles('**/pyproject.toml') }} + restore-keys: | + ${{ matrix.python-version }}-v1- + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade tox tox-gh-actions .[dev] + + - name: Tests + run: pytest -sv + + - name: Coverage report (xml) + run: coverage xml + - name: Run codacy-coverage-reporter + uses: codacy/codacy-coverage-reporter-action@v1 + with: + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} + coverage-reports: "coverage.xml" + language: "python" diff --git a/pyproject.toml b/pyproject.toml index 17d3864..21297f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,19 +1,18 @@ [project] name = "khipu-tools" -version = "2024.12.1" +version = "2024.12.4" description = "Set de herramientas para operar con la APIv3 de Khipu" readme = "README.md" requires-python = ">=3.9" license = { text = "MIT" } authors = [{ name = "Mario Hernandez", email = "mariofix@proton.me" }] classifiers = [ - "Development Status :: 3 - Alpha", + "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", "Intended Audience :: Developers", "Intended Audience :: Information Technology", "Topic :: Software Development :: Libraries :: Python Modules", @@ -42,4 +41,33 @@ dev = [ "black>=24.10.0", "mkdocs-material>=9.5.49", "mkdocstrings[python]>=0.27.0", + "pytest>=8.3.4", + "coverage>=7.6.9", + "pytest>=8.3.4", + "pytest-cov>=6.0.0", ] + + +[tool.black] +line-length = 119 +target-version = ["py39"] + +[tool.isort] +profile = "black" +line_length = 119 +multi_line_output = 5 +py_version = 39 + + +[tool.coverage.report] +exclude_lines = ["if TYPE_CHECKING:", "# noqa", "# nosec"] + +[tool.pytest.ini_options] +addopts = [ + "--cov=khipu_tools", + "--cov-report=term-missing:skip-covered", + "--no-cov-on-fail", + "--color=yes", +] +testpaths = "tests" +pythonpath = "." diff --git a/tests/test_core.py b/tests/test_core.py new file mode 100644 index 0000000..dd722cf --- /dev/null +++ b/tests/test_core.py @@ -0,0 +1,5 @@ +from khipu_tools._version import VERSION + + +def test_version(): + assert VERSION == "2024.12.4"