Skip to content

Commit

Permalink
Merge pull request #7 from wagtail/chore/tooling-tidy-ups
Browse files Browse the repository at this point in the history
Tidy ups
  • Loading branch information
tomusher authored Nov 6, 2023
2 parents e1ffce3 + 5471277 commit ab80803
Show file tree
Hide file tree
Showing 11 changed files with 173 additions and 122 deletions.
14 changes: 11 additions & 3 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
[run]
branch = True
include = wagtail_vector_index/*
parallel = true

source = wagtail_vector_index
omit = */migrations/*,*/tests/*

[paths]
source = src, .tox/py*/**/site-packages

[report]
show_missing = true
ignore_errors = true
skip_empty = true
skip_covered = true

# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
Expand All @@ -20,5 +30,3 @@ exclude_lines =
# Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.:

ignore_errors = True
39 changes: 27 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# See https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
# for a detailed guide
name: Publish to PyPI

on:
release:
types: [published]

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
build_and_publish:
build:
runs-on: ubuntu-latest
permissions:
contents: read # to fetch code (actions/checkout)
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -22,6 +19,12 @@ jobs:
with:
python-version: "3.11"

- uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: "pip"
cache-dependency-path: "**/pyproject.toml"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -31,9 +34,21 @@ jobs:
- name: Build
run: python -m flit build

- name: Publish to PyPI
env:
FLIT_USERNAME: "__token__"
FLIT_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
FLIT_INDEX_URL: https://upload.pypi.org/legacy/
run: python -m flit publish
# https://docs.pypi.org/trusted-publishers/using-a-publisher/
pypi-publish:
needs: build
environment: 'publish'

name: Upload release to PyPI
runs-on: ubuntu-latest
permissions:
# Mandatory for trusted publishing
id-token: write
steps:
- uses: actions/download-artifact@v3

- name: 🚀 Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: artifact/
print-hash: true
101 changes: 68 additions & 33 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
branches:
- main
- 'stable/**'
- 'fix-actions'

pull_request:

Expand All @@ -16,6 +15,13 @@ concurrency:
permissions:
contents: read # to fetch code (actions/checkout)

env:
FORCE_COLOR: "1" # Make tools pretty.
TOX_TESTENV_PASSENV: FORCE_COLOR
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_NO_PYTHON_VERSION_WARNING: "1"
PYTHON_LATEST: "3.12"

jobs:
lint:
runs-on: ubuntu-latest
Expand All @@ -28,57 +34,44 @@ jobs:
with:
python-version: '3.11'
- uses: pre-commit/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}

test-sqlite:
runs-on: ubuntu-latest
needs: lint
strategy:
matrix:
python: ['3.8', '3.9']
django: ['3.2']
wagtail: ['4.1', '4.2']
include:
- python: '3.10'
django: '4.2'
wagtail: '5.1'
- python: '3.11'
django: '4.2'
wagtail: '5.1'

python: ["3.11", "3.12"]
db: ["sqlite"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install Tox
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade tox
python -m pip install --upgrade tox tox-gh-actions
- name: Test
run: |
tox
run: tox
env:
TOXENV: python${{ matrix.python }}-django${{ matrix.django }}-wagtail${{ matrix.wagtail }}-sqlite
DB: sqlite

- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: coverage-data
path: .coverage.*
if-no-files-found: ignore
retention-days: 1

test-postgres:
runs-on: ubuntu-latest
needs: lint
strategy:
matrix:
python: ['3.8', '3.9']
django: ['3.2']
wagtail: ['4.1', '4.2']
experimental: [false]
include:
- python: '3.10'
django: '4.2'
wagtail: '5.1'
- python: '3.11'
django: '4.2'
wagtail: '5.1'
python: ["3.11", "3.12"]
db: ["postgres"]

services:
postgres:
Expand All @@ -100,8 +93,50 @@ jobs:
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade tox
- name: Test
run: |
tox
run: tox
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/wagtail_vector_index
TOXENV: python${{ matrix.python }}-django${{ matrix.django }}-wagtail${{ matrix.wagtail }}-postgres
DB: postgres
- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: coverage-data
path: .coverage.*
if-no-files-found: ignore
retention-days: 1

coverage:
runs-on: ubuntu-latest
needs:
- test-sqlite
- test-postgres

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
# Use latest Python, so it understands all syntax.
python-version: ${{env.PYTHON_LATEST}}

- run: python -Im pip install --upgrade coverage

- name: Download coverage data
uses: actions/download-artifact@v3
with:
name: coverage-data

- name: Combine coverage
run: |
python -Im coverage combine
python -Im coverage html --skip-covered --skip-empty
python -Im coverage report
echo "## Coverage summary" >> $GITHUB_STEP_SUMMARY
python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
- name: Upload HTML report if check failed.
uses: actions/upload-artifact@v3
with:
name: html-report
path: htmlcov
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ __pycache__/
/.coverage
/htmlcov
/.tox
/.venv
/venv
/.vscode
/site
Expand All @@ -19,3 +20,4 @@ __pycache__/
devenv.lock
devenv.nix
.env
.ruff_cache
11 changes: 4 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ default_language_version:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -21,19 +21,16 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.1
rev: 23.10.1
hooks:
- id: black
language_version: python3
args: ["--target-version", "py37"]
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black==23.9.1]
additional_dependencies: [black==23.10.1]
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.291
rev: v0.1.3
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ This provides the backbone for features including:

## Supported Versions

* Wagtail 4.0, 4.1, 4.2, 5.0, 5.1
* Wagtail 5.2
* Django 4.2
* Python 3.11, 3.12

## Contributing

Expand Down
38 changes: 16 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,22 @@ classifiers = [
"Operating System :: OS Independent",
"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 :: 3.12",
"Framework :: Django",
"Framework :: Django :: 3.0",
"Framework :: Django :: 3.1",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: Wagtail",
"Framework :: Wagtail :: 4",
"Framework :: Wagtail :: 5",
]
dynamic = ["version"]
requires-python = ">=3.8"
requires-python = ">=3.11"
dependencies = [
"Django>=3.0",
"Wagtail>=4.0",
"Django>=4.2",
"Wagtail>=5.2",
"tiktoken>=0.3.3",
"langchain>=0.0.311",
"every-ai>=1.1.1"
"every-ai>=1.1.1",
"aiohttp>=3.9.0b0; python_version >= '3.12'",
]
[project.optional-dependencies]
numpy = [
Expand All @@ -55,7 +48,8 @@ testing = [
"pytest>=7.4.2",
"pytest-django>=4.5.2",
"wagtail-factories>=4.1.0",
"factory-boy>=3.3.0"
"factory-boy>=3.3.0",
"coverage>=7.0,<8.0",
]
docs = [
"mkdocs>=1.5.3",
Expand All @@ -66,17 +60,9 @@ docs = [
[project.urls]
Home = "https://github.com/tomusher/wagtail-vector-index"

[tool.ruff]
select = ["F", "E", "C90", "I", "B", "DJ", "RUF", "TRY", "C4"]
ignore = ["TRY003", "E501", "RUF012"]

[tool.flit.module]
name = "wagtail_vector_index"

[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "testapp.settings"
pythonpath = ["./", "./tests"]

[tool.flit.sdist]
include = [
"wagtail_vector_index/static"
Expand All @@ -93,3 +79,11 @@ exclude = [
"*.ini",
"*.yml"
]

[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "testapp.settings"
pythonpath = ["./", "./tests"]

[tool.ruff]
select = ["F", "E", "C90", "I", "B", "DJ", "RUF", "TRY", "C4"]
ignore = ["TRY003", "E501", "RUF012"]
14 changes: 0 additions & 14 deletions setup.cfg

This file was deleted.

2 changes: 1 addition & 1 deletion src/wagtail_vector_index/backends/numpy/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import numpy as np

from wagtail_vector_index import Document
from wagtail_vector_index.backends import Backend, Index, SearchResponseDocument
from wagtail_vector_index.base import Document
from wagtail_vector_index.index import get_vector_indexes

logger = logging.Logger(__name__)
Expand Down
Loading

0 comments on commit ab80803

Please sign in to comment.