From aefec01562036038f0d3c312de2b2cc3e87d207d Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Fri, 26 Jan 2024 11:22:28 +0100 Subject: [PATCH 1/6] Modernize repository --- .coveragerc | 3 - .github/CODE_OF_CONDUCT.md | 3 + CONTRIBUTING.md => .github/CONTRIBUTING.md | 0 .github/dependabot.yml | 8 ++ .github/release.yml | 23 ++++++ .github/workflows/lint.yml | 34 -------- .github/workflows/publish.yml | 55 +++++++++++++ .github/workflows/test.yml | 73 ++++++----------- .gitignore | 3 +- .therapist.yml | 13 --- CHANGELOG.rst | 9 +-- MANIFEST.in | 5 -- Makefile | 61 ++++++-------- README.rst | 10 ++- dev-requirements.txt | 12 --- pyproject.toml | 94 ++++++++++++++++++---- requirements.in | 3 + requirements.txt | 13 +++ setup.cfg | 9 --- setup.py | 57 ------------- tox.ini | 9 --- 21 files changed, 240 insertions(+), 257 deletions(-) delete mode 100644 .coveragerc create mode 100644 .github/CODE_OF_CONDUCT.md rename CONTRIBUTING.md => .github/CONTRIBUTING.md (100%) create mode 100644 .github/release.yml delete mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/publish.yml delete mode 100644 .therapist.yml delete mode 100644 MANIFEST.in delete mode 100644 dev-requirements.txt create mode 100644 requirements.in delete mode 100644 setup.cfg delete mode 100644 setup.py delete mode 100644 tox.ini diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 61cdfe4..0000000 --- a/.coveragerc +++ /dev/null @@ -1,3 +0,0 @@ -[run] -omit = kinto_http/tests/* -relative_files = True diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..220b79c --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,3 @@ +# Code of conduct + +This repository is governed by Mozilla's code of conduct and etiquette guidelines. For more details please see the [Mozilla Community Participation Guidelines](https://www.mozilla.org/about/governance/policies/participation/) and [Developer Etiquette Guidelines](https://bugzilla.mozilla.org/page.cgi?id=etiquette.html). diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md diff --git a/.github/dependabot.yml b/.github/dependabot.yml index aef46be..332beb0 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,3 +8,11 @@ updates: groups: all-dependencies: update-types: ["major", "minor", "patch"] +- package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 99 + groups: + all-dependencies: + update-types: ["major", "minor", "patch"] diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..0019e50 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,23 @@ +changelog: + exclude: + authors: + - dependabot + categories: + - title: Breaking Changes + labels: + - "breaking-change" + - title: Bug Fixes + labels: + - "bug" + - title: New Features + labels: + - "enhancement" + - title: Documentation + labels: + - "documentation" + - title: Dependency Updates + labels: + - "dependencies" + - title: Other Changes + labels: + - "*" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 5f7c02a..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,34 +0,0 @@ -on: - push: - branches: - - main - pull_request: - -name: Lint -jobs: - chore: - name: Lint and check format - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-python@v2 - with: - python-version: "3.x" - - - name: Install virtualenv - run: | - pip install virtualenv - virtualenv --python=python3 .venv - - - name: Print environment - run: | - source .venv/bin/activate - python --version - pip --version - - - name: make lint - run: | - source .venv/bin/activate - make lint diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..035d687 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,55 @@ +name: Publish Python 🐍 distribution 📦 to PyPI + +on: + push: + tags: + - '*' + +jobs: + build: + name: Build distribution 📦 + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" + + - name: Print environment + run: | + python --version + + - name: Install pypa/build + run: python3 -m pip install build + + - name: Build a binary wheel and a source tarball + run: python3 -m build + + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + name: Publish Python 🐍 distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + environment: + name: release + url: https://pypi.org/p/kinto-http + permissions: + id-token: write + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e48f06c..c6053b2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,68 +1,41 @@ -on: - push: - branches: - - main - pull_request: +on: pull_request -name: Unit Testing jobs: - chore: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + + - name: Run linting and formatting checks + run: make lint + + unit-tests: name: Unit Tests + needs: lint runs-on: ubuntu-latest strategy: matrix: - toxenv: [py38, py39, py310, py311, py311-master] - include: - - toxenv: py38 - python-version: "3.8" - - toxenv: py39 - python-version: "3.9" - - toxenv: py310 - python-version: "3.10" - - toxenv: py311 - python-version: "3.11" - - toxenv: py311-master - python-version: "3.11" + python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - - name: Install virtualenv - run: | - pip install virtualenv - virtualenv --python=python3 .venv - - - name: Print environment - run: | - source .venv/bin/activate - python --version - pip --version + cache: pip - name: Install dependencies - run: | - source .venv/bin/activate - pip install tox - make install-dev + run: make install - - name: Use kinto @ master - if: matrix.toxenv == 'py39-master' - run: pip install --pre -U https://github.com/Kinto/kinto/tarball/master + - name: Run kinto + run: make run-kinto & sleep 5 - - name: Run server - run: | - make run-kinto & - sleep 5 # to give kinto migrate a chance to finish - - - name: Tox - run: | - source .venv/bin/activate - tox -e ${{ matrix.toxenv }} + - name: Run unit tests + run: make test - name: Coveralls - uses: AndreMiras/coveralls-python-action@develop - with: - github-token: ${{ secrets.GITHUB_TOKEN }} + uses: coverallsapp/github-action@v2 diff --git a/.gitignore b/.gitignore index aad476d..717626f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,7 @@ .cache *.pyc -kinto_http.egg-info/ +*.egg-info/ .coverage .venv/ -.tox .pytest_cache/ .vscode/ diff --git a/.therapist.yml b/.therapist.yml deleted file mode 100644 index d41b4c9..0000000 --- a/.therapist.yml +++ /dev/null @@ -1,13 +0,0 @@ -actions: - black: - run: black --check {files} - fix: black {files} - include: "*.py" - exclude: - - .venv/ - - flake8: - run: flake8 {files} - include: "*.py" - exclude: - - .venv/ diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 42969be..7c7e4fd 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,13 +4,10 @@ CHANGELOG This document describes changes between each past release. -11.0.2 (unreleased) -=================== - -**Internal Changes** +>= 11.0.2 +========= -- Drop support of Python 3.7 -- Update list of Python versions to run CI tests +Since version 11.0.2, we use `Github releases `_ and autogenerated changelogs. 11.0.1 (2023-04-05) diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 4a5c925..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,5 +0,0 @@ -include *.rst README.rst CHANGELOG.rst tox.ini Makefile .coveragerc -include *.txt -include LICENSE -include CONTRIBUTING.md -recursive-include kinto_http *.ini diff --git a/Makefile b/Makefile index 2a55231..83c2067 100644 --- a/Makefile +++ b/Makefile @@ -1,61 +1,48 @@ -VIRTUALENV = virtualenv --python=python3 VENV := $(shell echo $${VIRTUAL_ENV-.venv}) PYTHON = $(VENV)/bin/python -DEV_STAMP = $(VENV)/.dev_env_installed.stamp INSTALL_STAMP = $(VENV)/.install.stamp -TEMPDIR := $(shell mktemp -d) - -.IGNORE: clean distclean maintainer-clean -.PHONY: all install virtualenv tests tests-once - -OBJECTS = .venv .coverage +.PHONY: all all: install + install: $(INSTALL_STAMP) -$(INSTALL_STAMP): $(PYTHON) setup.py +$(INSTALL_STAMP): $(PYTHON) pyproject.toml requirements.txt $(VENV)/bin/pip install -U pip - $(VENV)/bin/pip install -Ue . + $(VENV)/bin/pip install -r requirements.txt + $(VENV)/bin/pip install -e ".[dev]" touch $(INSTALL_STAMP) -install-dev: $(INSTALL_STAMP) $(DEV_STAMP) -$(DEV_STAMP): $(PYTHON) dev-requirements.txt - $(VENV)/bin/pip install -Ur dev-requirements.txt - touch $(DEV_STAMP) - -virtualenv: $(PYTHON) $(PYTHON): - $(VIRTUALENV) $(VENV) + python3 -m venv $(VENV) need-kinto-running: @curl http://localhost:8888/v0/ 2>/dev/null 1>&2 || (echo "Run 'make run-kinto' before starting tests." && exit 1) -run-kinto: install-dev +run-kinto: install $(VENV)/bin/kinto migrate --ini kinto_http/tests/config/kinto.ini $(VENV)/bin/kinto start --ini kinto_http/tests/config/kinto.ini -tests-once: install-dev need-kinto-running +.PHONY: tests +test: tests +tests: install need-kinto-running $(VENV)/bin/pytest --cov-report term-missing --cov-fail-under 100 --cov kinto_http -functional: install-dev need-kinto-running +.PHONY: functional +functional: install need-kinto-running $(VENV)/bin/pytest -k "test_functional" -tests: install-dev need-kinto-running lint - $(VENV)/bin/pytest +.PHONY: lint +lint: install + $(VENV)/bin/ruff check kinto_http/ tests + $(VENV)/bin/ruff format --check kinto_http/ tests -format: install-dev - $(VENV)/bin/isort --profile=black --lines-after-imports=2 kinto_http - $(VENV)/bin/black kinto_http - $(VENV)/bin/flake8 kinto_http - -lint: install-dev - $(VENV)/bin/therapist run --use-tracked-files kinto_http +.PHONY: format +format: install + $(VENV)/bin/ruff check --fix kinto_http/ tests + $(VENV)/bin/ruff format kinto_http/ tests +.IGNORE: clean clean: - find . -name '*.pyc' -delete - find . -name '__pycache__' -type d | xargs rm -fr - -distclean: clean - rm -fr *.egg *.egg-info/ dist/ build/ - -maintainer-clean: distclean - rm -fr .venv/ .tox/ + find kinto_http -name '*.pyc' -delete + find kinto_http -name '__pycache__' -type d -exec rm -fr {} \; + rm -rf .venv .coverage *.egg-info .pytest_cache .ruff_cache build dist diff --git a/README.rst b/README.rst index cd6a472..75ac48c 100644 --- a/README.rst +++ b/README.rst @@ -508,8 +508,10 @@ In another, run the tests against it: $ make tests -(Optional) Install a git hook: - -:: +Releasing +========= - therapist install +1. Create a release on Github on https://github.com/Kinto/kinto-http.py/releases/new +2. Create a new tag `X.Y.Z` (*This tag will be created from the target when you publish this release.*) +3. Generate release notes +4. Publish release diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index fe508c1..0000000 --- a/dev-requirements.txt +++ /dev/null @@ -1,12 +0,0 @@ -black==24.1.0 -flake8==7.0.0 -isort==5.13.2 -kinto==16.3.0 -pytest==7.4.4 -pytest-asyncio==0.23.3 -pytest-cache==1.0 -pytest-cov==4.1.0 -pytest-mock==3.12.0 -pytest-xdist==3.5.0 -therapist==2.2.0 -Unidecode==1.3.8 diff --git a/pyproject.toml b/pyproject.toml index dcb8cac..ffedf44 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,17 +1,79 @@ -[tool.black] +[project] +dynamic = ["version", "dependencies"] +name = "kinto-http" +description = "Kinto client" +readme = "README.rst" +license = {file = "LICENSE"} +classifiers = [ + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Internet :: WWW/HTTP", + "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", + "License :: OSI Approved :: Apache Software License" +] +keywords = ["web services"] +authors = [ + {name = "Mozilla Services", email = "developers@kinto-storage.org"}, +] + +[project.urls] +Repository = "https://github.com/Kinto/kinto-http.py" + +[tool.setuptools_scm] +# can be empty if no extra settings are needed, presence enables setuptools_scm + +[tool.setuptools.dynamic] +dependencies = { file = ["requirements.in"] } + +[tool.setuptools.packages.find] +include = ["kinto_http"] + +[build-system] +requires = ["setuptools>=64", "setuptools_scm>=8"] +build-backend = "setuptools.build_meta" + +[project.optional-dependencies] +dev = [ + "kinto", + "ruff", + "pytest", + "pytest-asyncio", + "pytest-cache", + "pytest-cov", + "pytest-mock", + "pytest-xdist", +] + +[tool.pip-tools] +generate-hashes = true + +[tool.coverage.run] +omit = [ + "kinto_http/tests/*", +] +relative_files = true + +[tool.ruff] line-length = 99 -include = '\.pyi?$' -exclude = ''' -/( - \.git - | \.hg - | \.mypy_cache - | \.tox - | \.venv - | _build - | buck-out - | build - | dist - | __pycache__ -)/ -''' +extend-exclude = [ + "__pycache__", + ".venv/", +] + +[tool.ruff.lint] +select = [ + # pycodestyle + "E", "W", + # flake8 + "F", + # isort + "I", +] +ignore = [ + # `format` will wrap lines. + "E501", +] + +[tool.ruff.lint.isort] +lines-after-imports = 2 diff --git a/requirements.in b/requirements.in new file mode 100644 index 0000000..bda1c41 --- /dev/null +++ b/requirements.in @@ -0,0 +1,3 @@ +Unidecode +requests +backoff diff --git a/requirements.txt b/requirements.txt index 62c0699..c0e2576 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,17 @@ +# +# This file is autogenerated by pip-compile with Python 3.9 +# by the following command: +# +# pip-compile --generate-hashes +# backoff==2.2.1 \ --hash=sha256:03f829f5bb1923180821643f8753b0502c3b682293992485b0eef2807afa5cba \ --hash=sha256:63579f9a0628e06278f7e47b7d7d5b6ce20dc65c5e96a6f3ca99a6adca0396e8 + # via -r requirements.in certifi==2023.11.17 \ --hash=sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1 \ --hash=sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474 + # via requests charset-normalizer==3.3.2 \ --hash=sha256:06435b539f889b1f6f4ac1758871aae42dc3a8c0e24ac9e60c2384973ad73027 \ --hash=sha256:06a81e93cd441c56a9b65d8e1d043daeb97a3d0856d177d5c90ba85acb3db087 \ @@ -95,15 +103,20 @@ charset-normalizer==3.3.2 \ --hash=sha256:fb69256e180cb6c8a894fee62b3afebae785babc1ee98b81cdf68bbca1987f33 \ --hash=sha256:fd1abc0d89e30cc4e02e4064dc67fcc51bd941eb395c502aac3ec19fab46b519 \ --hash=sha256:ff8fa367d09b717b2a17a052544193ad76cd49979c805768879cb63d9ca50561 + # via requests idna==3.6 \ --hash=sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca \ --hash=sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f + # via requests requests==2.31.0 \ --hash=sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f \ --hash=sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1 + # via -r requirements.in unidecode==1.3.8 \ --hash=sha256:cfdb349d46ed3873ece4586b96aa75258726e2fa8ec21d6f00a591d98806c2f4 \ --hash=sha256:d130a61ce6696f8148a3bd8fe779c99adeb4b870584eeb9526584e9aa091fd39 + # via -r requirements.in urllib3==2.1.0 \ --hash=sha256:55901e917a5896a349ff771be919f8bd99aff50b79fe58fec595eb37bbc56bb3 \ --hash=sha256:df7aa8afb0148fa78488e7899b2c59b5f4ffcfa82e6c54ccb9dd37c1d7b52d54 + # via requests diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 60fe136..0000000 --- a/setup.cfg +++ /dev/null @@ -1,9 +0,0 @@ -[zest.releaser] -create-wheel = yes - -[flake8] -max_line_length = 99 -exclude = - .git - __pycache__ -ignore = W503,E203 diff --git a/setup.py b/setup.py deleted file mode 100644 index 55ec50c..0000000 --- a/setup.py +++ /dev/null @@ -1,57 +0,0 @@ -import codecs -import os -from setuptools import setup, find_packages - -here = os.path.abspath(os.path.dirname(__file__)) - - -def read_file(filename): - """Open a related file and return its content.""" - with codecs.open(os.path.join(here, filename), encoding="utf-8") as f: - content = f.read() - return content - - -README = read_file("README.rst") -CHANGELOG = read_file("CHANGELOG.rst") - -INSTALL_REQUIRES = [ - "requests", - "backoff", - "unidecode", -] - -TESTS_REQUIRE = [ - x.replace(" \\", "") - for x in read_file("./dev-requirements.txt").split("\n") - if not x.startswith(" ") -] - -setup( - name="kinto-http", - version="11.0.2.dev0", - description="Kinto client", - long_description=README + "\n\n" + CHANGELOG, - license="Apache License (2.0)", - classifiers=[ - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: Implementation :: CPython", - "Topic :: Internet :: WWW/HTTP", - "License :: OSI Approved :: Apache Software License", - ], - keywords="web services", - author="Mozilla Services", - author_email="storage@mozilla.com", - url="https://github.com/Kinto/kinto-http.py/", - packages=find_packages(), - include_package_data=True, - zip_safe=False, - install_requires=INSTALL_REQUIRES, - test_suite="kinto_http.tests", - tests_require=TESTS_REQUIRE, -) diff --git a/tox.ini b/tox.ini deleted file mode 100644 index de2bda3..0000000 --- a/tox.ini +++ /dev/null @@ -1,9 +0,0 @@ -[tox] -envlist = py38,py39,py310,py311,py311-master - -[testenv] -commands = - python --version - pytest --cov-report term-missing --cov-fail-under 100 --cov kinto_http {posargs} -deps = -rdev-requirements.txt -install_command = pip install {opts} {packages} From d2af34d337ad5b9a2ced39847701ef5d040495fe Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Fri, 26 Jan 2024 11:29:16 +0100 Subject: [PATCH 2/6] Move code to src/ and tests/ out of src/ --- Makefile | 16 ++++++++-------- pyproject.toml | 5 +---- {kinto_http => src/kinto_http}/__init__.py | 0 {kinto_http => src/kinto_http}/batch.py | 0 {kinto_http => src/kinto_http}/cli_utils.py | 0 {kinto_http => src/kinto_http}/client.py | 0 {kinto_http => src/kinto_http}/constants.py | 0 {kinto_http => src/kinto_http}/endpoints.py | 0 {kinto_http => src/kinto_http}/exceptions.py | 0 {kinto_http => src/kinto_http}/patch_type.py | 0 {kinto_http => src/kinto_http}/replication.py | 0 {kinto_http => src/kinto_http}/session.py | 0 {kinto_http => src/kinto_http}/utils.py | 0 {kinto_http/tests => tests}/__init__.py | 0 {kinto_http/tests => tests}/config/kinto.ini | 0 {kinto_http/tests => tests}/conftest.py | 0 {kinto_http/tests => tests}/support.py | 0 {kinto_http/tests => tests}/test_async_client.py | 0 {kinto_http/tests => tests}/test_batch.py | 0 {kinto_http/tests => tests}/test_cli_utils.py | 0 {kinto_http/tests => tests}/test_client.py | 0 {kinto_http/tests => tests}/test_endpoints.py | 0 {kinto_http/tests => tests}/test_exceptions.py | 0 {kinto_http/tests => tests}/test_functional.py | 0 .../tests => tests}/test_functional_async.py | 0 {kinto_http/tests => tests}/test_logging.py | 0 {kinto_http/tests => tests}/test_replication.py | 0 {kinto_http/tests => tests}/test_session.py | 0 {kinto_http/tests => tests}/test_utils.py | 0 29 files changed, 9 insertions(+), 12 deletions(-) rename {kinto_http => src/kinto_http}/__init__.py (100%) rename {kinto_http => src/kinto_http}/batch.py (100%) rename {kinto_http => src/kinto_http}/cli_utils.py (100%) rename {kinto_http => src/kinto_http}/client.py (100%) rename {kinto_http => src/kinto_http}/constants.py (100%) rename {kinto_http => src/kinto_http}/endpoints.py (100%) rename {kinto_http => src/kinto_http}/exceptions.py (100%) rename {kinto_http => src/kinto_http}/patch_type.py (100%) rename {kinto_http => src/kinto_http}/replication.py (100%) rename {kinto_http => src/kinto_http}/session.py (100%) rename {kinto_http => src/kinto_http}/utils.py (100%) rename {kinto_http/tests => tests}/__init__.py (100%) rename {kinto_http/tests => tests}/config/kinto.ini (100%) rename {kinto_http/tests => tests}/conftest.py (100%) rename {kinto_http/tests => tests}/support.py (100%) rename {kinto_http/tests => tests}/test_async_client.py (100%) rename {kinto_http/tests => tests}/test_batch.py (100%) rename {kinto_http/tests => tests}/test_cli_utils.py (100%) rename {kinto_http/tests => tests}/test_client.py (100%) rename {kinto_http/tests => tests}/test_endpoints.py (100%) rename {kinto_http/tests => tests}/test_exceptions.py (100%) rename {kinto_http/tests => tests}/test_functional.py (100%) rename {kinto_http/tests => tests}/test_functional_async.py (100%) rename {kinto_http/tests => tests}/test_logging.py (100%) rename {kinto_http/tests => tests}/test_replication.py (100%) rename {kinto_http/tests => tests}/test_session.py (100%) rename {kinto_http/tests => tests}/test_utils.py (100%) diff --git a/Makefile b/Makefile index 83c2067..f5e860f 100644 --- a/Makefile +++ b/Makefile @@ -19,8 +19,8 @@ need-kinto-running: @curl http://localhost:8888/v0/ 2>/dev/null 1>&2 || (echo "Run 'make run-kinto' before starting tests." && exit 1) run-kinto: install - $(VENV)/bin/kinto migrate --ini kinto_http/tests/config/kinto.ini - $(VENV)/bin/kinto start --ini kinto_http/tests/config/kinto.ini + $(VENV)/bin/kinto migrate --ini tests/config/kinto.ini + $(VENV)/bin/kinto start --ini tests/config/kinto.ini .PHONY: tests test: tests @@ -33,16 +33,16 @@ functional: install need-kinto-running .PHONY: lint lint: install - $(VENV)/bin/ruff check kinto_http/ tests - $(VENV)/bin/ruff format --check kinto_http/ tests + $(VENV)/bin/ruff check src tests + $(VENV)/bin/ruff format --check src tests .PHONY: format format: install - $(VENV)/bin/ruff check --fix kinto_http/ tests - $(VENV)/bin/ruff format kinto_http/ tests + $(VENV)/bin/ruff check --fix src tests + $(VENV)/bin/ruff format src tests .IGNORE: clean clean: - find kinto_http -name '*.pyc' -delete - find kinto_http -name '__pycache__' -type d -exec rm -fr {} \; + find src -name '__pycache__' -type d -exec rm -fr {} \; + find tests -name '__pycache__' -type d -exec rm -fr {} \; rm -rf .venv .coverage *.egg-info .pytest_cache .ruff_cache build dist diff --git a/pyproject.toml b/pyproject.toml index ffedf44..31308e4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,9 +26,6 @@ Repository = "https://github.com/Kinto/kinto-http.py" [tool.setuptools.dynamic] dependencies = { file = ["requirements.in"] } -[tool.setuptools.packages.find] -include = ["kinto_http"] - [build-system] requires = ["setuptools>=64", "setuptools_scm>=8"] build-backend = "setuptools.build_meta" @@ -50,7 +47,7 @@ generate-hashes = true [tool.coverage.run] omit = [ - "kinto_http/tests/*", + "tests/*", ] relative_files = true diff --git a/kinto_http/__init__.py b/src/kinto_http/__init__.py similarity index 100% rename from kinto_http/__init__.py rename to src/kinto_http/__init__.py diff --git a/kinto_http/batch.py b/src/kinto_http/batch.py similarity index 100% rename from kinto_http/batch.py rename to src/kinto_http/batch.py diff --git a/kinto_http/cli_utils.py b/src/kinto_http/cli_utils.py similarity index 100% rename from kinto_http/cli_utils.py rename to src/kinto_http/cli_utils.py diff --git a/kinto_http/client.py b/src/kinto_http/client.py similarity index 100% rename from kinto_http/client.py rename to src/kinto_http/client.py diff --git a/kinto_http/constants.py b/src/kinto_http/constants.py similarity index 100% rename from kinto_http/constants.py rename to src/kinto_http/constants.py diff --git a/kinto_http/endpoints.py b/src/kinto_http/endpoints.py similarity index 100% rename from kinto_http/endpoints.py rename to src/kinto_http/endpoints.py diff --git a/kinto_http/exceptions.py b/src/kinto_http/exceptions.py similarity index 100% rename from kinto_http/exceptions.py rename to src/kinto_http/exceptions.py diff --git a/kinto_http/patch_type.py b/src/kinto_http/patch_type.py similarity index 100% rename from kinto_http/patch_type.py rename to src/kinto_http/patch_type.py diff --git a/kinto_http/replication.py b/src/kinto_http/replication.py similarity index 100% rename from kinto_http/replication.py rename to src/kinto_http/replication.py diff --git a/kinto_http/session.py b/src/kinto_http/session.py similarity index 100% rename from kinto_http/session.py rename to src/kinto_http/session.py diff --git a/kinto_http/utils.py b/src/kinto_http/utils.py similarity index 100% rename from kinto_http/utils.py rename to src/kinto_http/utils.py diff --git a/kinto_http/tests/__init__.py b/tests/__init__.py similarity index 100% rename from kinto_http/tests/__init__.py rename to tests/__init__.py diff --git a/kinto_http/tests/config/kinto.ini b/tests/config/kinto.ini similarity index 100% rename from kinto_http/tests/config/kinto.ini rename to tests/config/kinto.ini diff --git a/kinto_http/tests/conftest.py b/tests/conftest.py similarity index 100% rename from kinto_http/tests/conftest.py rename to tests/conftest.py diff --git a/kinto_http/tests/support.py b/tests/support.py similarity index 100% rename from kinto_http/tests/support.py rename to tests/support.py diff --git a/kinto_http/tests/test_async_client.py b/tests/test_async_client.py similarity index 100% rename from kinto_http/tests/test_async_client.py rename to tests/test_async_client.py diff --git a/kinto_http/tests/test_batch.py b/tests/test_batch.py similarity index 100% rename from kinto_http/tests/test_batch.py rename to tests/test_batch.py diff --git a/kinto_http/tests/test_cli_utils.py b/tests/test_cli_utils.py similarity index 100% rename from kinto_http/tests/test_cli_utils.py rename to tests/test_cli_utils.py diff --git a/kinto_http/tests/test_client.py b/tests/test_client.py similarity index 100% rename from kinto_http/tests/test_client.py rename to tests/test_client.py diff --git a/kinto_http/tests/test_endpoints.py b/tests/test_endpoints.py similarity index 100% rename from kinto_http/tests/test_endpoints.py rename to tests/test_endpoints.py diff --git a/kinto_http/tests/test_exceptions.py b/tests/test_exceptions.py similarity index 100% rename from kinto_http/tests/test_exceptions.py rename to tests/test_exceptions.py diff --git a/kinto_http/tests/test_functional.py b/tests/test_functional.py similarity index 100% rename from kinto_http/tests/test_functional.py rename to tests/test_functional.py diff --git a/kinto_http/tests/test_functional_async.py b/tests/test_functional_async.py similarity index 100% rename from kinto_http/tests/test_functional_async.py rename to tests/test_functional_async.py diff --git a/kinto_http/tests/test_logging.py b/tests/test_logging.py similarity index 100% rename from kinto_http/tests/test_logging.py rename to tests/test_logging.py diff --git a/kinto_http/tests/test_replication.py b/tests/test_replication.py similarity index 100% rename from kinto_http/tests/test_replication.py rename to tests/test_replication.py diff --git a/kinto_http/tests/test_session.py b/tests/test_session.py similarity index 100% rename from kinto_http/tests/test_session.py rename to tests/test_session.py diff --git a/kinto_http/tests/test_utils.py b/tests/test_utils.py similarity index 100% rename from kinto_http/tests/test_utils.py rename to tests/test_utils.py From 458e0233aeea155ed4be0cb2c42b980dc8cbbc36 Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Fri, 26 Jan 2024 11:30:15 +0100 Subject: [PATCH 3/6] Run 'make format' --- src/kinto_http/cli_utils.py | 2 +- tests/conftest.py | 3 +-- tests/support.py | 1 - tests/test_async_client.py | 3 +-- tests/test_batch.py | 3 +-- tests/test_cli_utils.py | 3 +-- tests/test_client.py | 3 +-- tests/test_endpoints.py | 1 - tests/test_functional.py | 1 - tests/test_functional_async.py | 3 +-- tests/test_logging.py | 3 +-- tests/test_replication.py | 3 +-- tests/test_session.py | 11 +++++------ 13 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/kinto_http/cli_utils.py b/src/kinto_http/cli_utils.py index 81a4d31..aabd42e 100644 --- a/src/kinto_http/cli_utils.py +++ b/src/kinto_http/cli_utils.py @@ -59,7 +59,7 @@ def add_parser_options( default_collection=None, include_bucket=True, include_collection=True, - **kwargs + **kwargs, ): if parser is None: parser = argparse.ArgumentParser(**kwargs) diff --git a/tests/conftest.py b/tests/conftest.py index 3b9162e..b293175 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,13 +4,12 @@ import pytest import requests -from pytest_mock.plugin import MockerFixture - from kinto_http import AsyncClient, Client from kinto_http.constants import DEFAULT_AUTH, SERVER_URL, USER_AGENT from kinto_http.endpoints import Endpoints from kinto_http.exceptions import KintoException from kinto_http.session import Session +from pytest_mock.plugin import MockerFixture from .support import create_user, get_200, get_503, mock_response diff --git a/tests/support.py b/tests/support.py index 2054a0d..bb9e9a1 100644 --- a/tests/support.py +++ b/tests/support.py @@ -5,7 +5,6 @@ from urllib.parse import urljoin import requests - from kinto_http.constants import DEFAULT_AUTH from kinto_http.exceptions import KintoException diff --git a/tests/test_async_client.py b/tests/test_async_client.py index 01ce9b2..b5ab166 100644 --- a/tests/test_async_client.py +++ b/tests/test_async_client.py @@ -1,13 +1,12 @@ import re import pytest -from pytest_mock import MockerFixture - from kinto_http import AsyncClient as Client from kinto_http import BearerTokenAuth, BucketNotFound, KintoException from kinto_http.constants import DO_NOT_OVERWRITE, SERVER_URL from kinto_http.patch_type import JSONPatch, MergePatch from kinto_http.session import create_session +from pytest_mock import MockerFixture from .support import build_response, get_http_error, mock_response diff --git a/tests/test_batch.py b/tests/test_batch.py index 60af5cb..548c7f4 100644 --- a/tests/test_batch.py +++ b/tests/test_batch.py @@ -1,9 +1,8 @@ import pytest -from pytest_mock.plugin import MockerFixture - from kinto_http import Client from kinto_http.batch import BatchSession from kinto_http.exceptions import KintoException +from pytest_mock.plugin import MockerFixture def test_requests_are_stacked(batch_setup: Client, mocker: MockerFixture): diff --git a/tests/test_cli_utils.py b/tests/test_cli_utils.py index 9b6255d..0bb3348 100644 --- a/tests/test_cli_utils.py +++ b/tests/test_cli_utils.py @@ -1,9 +1,8 @@ import argparse -from pytest_mock import MockerFixture - from kinto_http import BearerTokenAuth, cli_utils from kinto_http.constants import ALL_PARAMETERS +from pytest_mock import MockerFixture from .support import assert_option_strings diff --git a/tests/test_client.py b/tests/test_client.py index 7298262..671a3fb 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -1,8 +1,6 @@ import re import pytest -from pytest_mock.plugin import MockerFixture - from kinto_http import ( BearerTokenAuth, BucketNotFound, @@ -13,6 +11,7 @@ ) from kinto_http.constants import DO_NOT_OVERWRITE, SERVER_URL from kinto_http.patch_type import JSONPatch, MergePatch +from pytest_mock.plugin import MockerFixture from .support import build_response, get_http_error, mock_response diff --git a/tests/test_endpoints.py b/tests/test_endpoints.py index 162d243..779c304 100644 --- a/tests/test_endpoints.py +++ b/tests/test_endpoints.py @@ -1,7 +1,6 @@ from typing import Dict, Tuple import pytest - from kinto_http import KintoException from kinto_http.endpoints import Endpoints diff --git a/tests/test_functional.py b/tests/test_functional.py index e0e59ce..e03ac49 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -2,7 +2,6 @@ from unittest import mock import pytest - from kinto_http import BucketNotFound, CollectionNotFound, KintoException, replication from kinto_http.patch_type import JSONPatch diff --git a/tests/test_functional_async.py b/tests/test_functional_async.py index 485a3ee..5b85499 100644 --- a/tests/test_functional_async.py +++ b/tests/test_functional_async.py @@ -1,8 +1,7 @@ import pytest -from pytest_mock import MockerFixture - from kinto_http import BucketNotFound, CollectionNotFound, KintoException from kinto_http.patch_type import JSONPatch +from pytest_mock import MockerFixture from .support import get_user_id diff --git a/tests/test_logging.py b/tests/test_logging.py index e223036..0182dce 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -1,6 +1,5 @@ -from pytest_mock.plugin import MockerFixture - from kinto_http import Client +from pytest_mock.plugin import MockerFixture def test_create_bucket_logs_info_message(client_setup: Client, mocker: MockerFixture): diff --git a/tests/test_replication.py b/tests/test_replication.py index 1af9108..61e35d9 100644 --- a/tests/test_replication.py +++ b/tests/test_replication.py @@ -1,7 +1,6 @@ -from pytest_mock import MockerFixture - from kinto_http import Client, exceptions from kinto_http.replication import replicate +from pytest_mock import MockerFixture from .support import mock_response diff --git a/tests/test_session.py b/tests/test_session.py index 3a20c5d..0aefb5c 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -5,14 +5,13 @@ from typing import Tuple from unittest.mock import MagicMock +import kinto_http import pkg_resources import pytest -from pytest_mock.plugin import MockerFixture - -import kinto_http from kinto_http.constants import USER_AGENT from kinto_http.exceptions import BackoffException, KintoException from kinto_http.session import Session, create_session +from pytest_mock.plugin import MockerFixture from .support import get_200, get_403, get_503, get_http_response @@ -162,7 +161,7 @@ def test_passed_data_is_encoded_to_json(session_setup: Tuple[MagicMock, Session] def test_passed_data_is_passed_as_is_when_files_are_posted( - session_setup: Tuple[MagicMock, Session] + session_setup: Tuple[MagicMock, Session], ): requests_mock, session = session_setup response = get_200() @@ -353,7 +352,7 @@ def test_passed_datetime_data_is_encoded_to_json(session_setup: Tuple[MagicMock, def test_passed_random_python_data_fails_to_be_encoded_to_json( - session_setup: Tuple[MagicMock, Session] + session_setup: Tuple[MagicMock, Session], ): _, session = session_setup with pytest.raises(TypeError) as exc: @@ -513,7 +512,7 @@ def test_forced_retry_after_overrides_value_of_header( def test_raises_exception_if_backoff_time_not_spent( - session_retry_setup: Tuple[MagicMock, Session] + session_retry_setup: Tuple[MagicMock, Session], ): requests_mock, session = session_retry_setup response = get_200() From 8db220dfb7b3f65888d33fef673fae0c3c26c165 Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Fri, 26 Jan 2024 11:29:40 +0100 Subject: [PATCH 4/6] Add blame ignore file --- .git-blame-ignore-revs | 4 ++++ README.rst | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000..5b87112 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,4 @@ +# Move code to src/ and tests/ out of src/ +d2af34d337ad5b9a2ced39847701ef5d040495fe +# Switch to ruff +458e0233aeea155ed4be0cb2c42b980dc8cbbc36 diff --git a/README.rst b/README.rst index 75ac48c..6723aff 100644 --- a/README.rst +++ b/README.rst @@ -492,8 +492,8 @@ The script now accepts basic options: -D, --debug Show all messages, including debug messages. -Run tests -========= +Development +=========== In one terminal, run a Kinto server: @@ -507,6 +507,13 @@ In another, run the tests against it: $ make tests +Optionally, configure `git` to use `.git-blame-ignore-revs` to remove noisy commits from `git blame` (e.g. running formatters or moving files): + +:: + + + git config blame.ignoreRevsFile .git-blame-ignore-revs + Releasing ========= From d04e1517da7f427c9c7e477e4cf6d1d519ac39d0 Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Fri, 26 Jan 2024 11:43:46 +0100 Subject: [PATCH 5/6] Force labels on pull-requests --- .github/workflows/labels.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/labels.yaml diff --git a/.github/workflows/labels.yaml b/.github/workflows/labels.yaml new file mode 100644 index 0000000..96a4efb --- /dev/null +++ b/.github/workflows/labels.yaml @@ -0,0 +1,14 @@ +name: Force pull-requests label(s) + +on: + pull_request: + types: [opened, labeled, unlabeled] +jobs: + pr-has-label: + name: Will be skipped if labelled + runs-on: ubuntu-latest + if: ${{ join(github.event.pull_request.labels.*.name, ', ') == '' }} + steps: + - run: | + echo 'Pull-request must have at least one label' + exit 1 From 014ee4670e224d14d6c4b6e43484682aca498c37 Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Fri, 26 Jan 2024 11:51:02 +0100 Subject: [PATCH 6/6] Try switching to parallel jobs for coveralls --- .github/workflows/test.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c6053b2..7e66395 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,5 +37,19 @@ jobs: - name: Run unit tests run: make test - - name: Coveralls + - name: Coveralls Parallel uses: coverallsapp/github-action@v2 + with: + flag-name: run-${{ join(matrix.*, '-') }} + parallel: true + + finish: + needs: unit-tests + if: ${{ always() }} + runs-on: ubuntu-latest + steps: + - name: Coveralls Finished + uses: coverallsapp/github-action@v2 + with: + parallel-finished: true + carryforward: "python-version-3.8,python-version-3.9,python-version-3.10,python-version-3.11"