From af13a56f37fc4b732e6d27daa0368d98ae597ac5 Mon Sep 17 00:00:00 2001 From: Tammo Ippen Date: Thu, 7 Nov 2024 10:00:56 +0100 Subject: [PATCH] change ci --- .github/workflows/CI.yml | 88 +++++++++++++++++++++++++++++++++++ .github/workflows/Publish.yml | 37 +++++++++++++++ Makefile | 13 ++++++ pyproject.toml | 46 ++++++++---------- setup.cfg | 12 +---- 5 files changed, 158 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/CI.yml create mode 100644 .github/workflows/Publish.yml create mode 100644 Makefile diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..46c3045 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,88 @@ +name: CI + +on: + push: + branches: + - "master" + pull_request: + branches: + - "master" + +jobs: + test: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ['pypy-3.9', 3.9, '3.10', 'pypy-3.10', '3.11', '3.12', '3.13'] + cython: ['yes', 'no'] + include: + - os: ubuntu-latest + path: ~/.cache/pip + - os: macos-latest + path: ~/Library/Caches/pip + - os: windows-latest + path: ~\AppData\Local\pip\Cache + exclude: + - os: macos-latest + python-version: 'pypy-3.9' + - os: macos-latest + python-version: 'pypy-3.10' + - os: windows-latest + python-version: 'pypy-3.9' + - os: windows-latest + python-version: 'pypy-3.10' + defaults: + run: + shell: bash + + runs-on: ${{ matrix.os }} + env: + PYTHONIOENCODING: UTF-8 + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Set Up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Cache Install + id: restore-cache + uses: actions/cache@v4 + with: + path: | + ${{ matrix.path }} + poetry.lock + key: ${{ matrix.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('tests/requirements.txt') }} + + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + version: '1.8.3' # ${{ startsWith(matrix.python-version, 'pypy') && '1.2.2' || '1.8.3' }} + virtualenvs-create: false + + - name: Install + run: poetry install + + - name: Build Cython file + run: | + poetry run pip install cython + poetry run cythonize -i geohash_hilbert/*.pyx + poetry show + python -c 'import geohash_hilbert as ghh; print(ghh._hilbert.CYTHON_AVAILABLE)' + + - name: Style + if: ${{ ! startsWith(matrix.python-version, 'pypy-') && startsWith(matrix.os, 'ubuntu') }} + run: make check + + - name: Tests + run: make test + + - uses: codecov/codecov-action@v4 + with: + file: coverage.xml + name: coverage-${{ matrix.os }}-${{ matrix.python-version }} + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true diff --git a/.github/workflows/Publish.yml b/.github/workflows/Publish.yml new file mode 100644 index 0000000..49953ce --- /dev/null +++ b/.github/workflows/Publish.yml @@ -0,0 +1,37 @@ +name: Publish + +on: + push: + tags: + - v* + workflow_dispatch: + +jobs: + publish: + runs-on: ubuntu-latest + environment: pypi + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Set Up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: 3.12 + + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + version: 1.8.3 + + - name: Build + run: poetry build -vvv -f sdist + + - name: Archive artifacts + uses: actions/upload-artifact@v4 + with: + path: dist/*.tar.gz + + - name: Publish + run: poetry publish -vvv -n -u __token__ -p ${{ secrets.PYPI_PASS }} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ffda91b --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +.PHONY: fmt check test + +fmt: + poetry run ruff format . + poetry run ruff check --fix . + +check: + poetry run ruff format --check . + poetry run ruff check . + # poetry run mypy geohash_hilbert + +test: + PYTHONDEVMODE=1 poetry run pytest -vvv -s diff --git a/pyproject.toml b/pyproject.toml index 43559fb..de9a99a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "geohash-hilbert" -version = "1.4.0" +version = "2.0.0" description = "Geohash a lng/lat coordinate using the hilbert curve." authors = ["Tammo Ippen "] license = "MIT" @@ -22,38 +22,30 @@ classifiers = [ # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers 'License :: OSI Approved :: MIT License', 'Programming Language :: Python', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', + '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', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy' ] [tool.poetry.dependencies] -python = "~2.7 || ^3.5" - -[tool.poetry.dev-dependencies] - -coveralls = "^1.5.1" -flake8 = "^3.5.0" -flake8-bugbear = { version = "^18.8.0", python = "^3.5" } -flake8-commas = "^2.0.0" -flake8-comprehensions = "^1.4.1" -flake8-import-order = "^0.18" -flake8-pep3101 = "^1.2.1" -flake8-polyfill = "^1.0.2" -flake8-quotes = "^1.0.0" -pep8-naming = "^0.7" -pytest = "^3.7.3" -pytest-benchmark = "^3.1.1" -pytest-cov = "^2.5.1" -pytest-flake8 = "^1.0.2" -pytest-mccabe = "^0.1" -pytest-pythonpath = "^0.7.3" -six = "^1.11.0" +python = "^3.9" + +[tool.poetry.group.dev.dependencies] + +ruff = "*" +coveralls = "*" +pytest = "*" +pytest-benchmark = "*" +pytest-cov = "*" +cython = { version = "*", optional = true } + +[tool.poetry.extras] +cython = ["cython"] [build-system] requires = ["poetry>=0.12"] diff --git a/setup.cfg b/setup.cfg index 76d183b..0a2ea9e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,15 +1,5 @@ -[flake8] -application_import_names = geohash_hilbert -max-line-length = 159 -max-complexity = 10 -import-order-style = google -exclude = - .venv/ - venv/ - [tool:pytest] -python_paths = . -addopts = --cov=geohash_hilbert --cov-report term-missing --cov-report html:cov_html --mccabe -v +addopts = --cov=geohash_hilbert --cov-branch --cov-report term-missing --cov-report html:cov_html --cov-report=xml:coverage.xml [bdist_wheel] universal = 0