Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy up tooling #30

Merged
merged 10 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 0 additions & 60 deletions .circleci/config.yml

This file was deleted.

8 changes: 0 additions & 8 deletions .circleci/trigger-nightly-build.sh

This file was deleted.

23 changes: 18 additions & 5 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
[run]
branch = True
include = wagtail_localize_git/*
omit = */migrations/*,*/tests/*
concurrency = multiprocessing, thread
parallel = True
source_pkgs = wagtail_localize_git
omit = **/migrations/*,tests/*

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

[report]
show_missing = True
ignore_errors = True
skip_covered = True

# Regexes for lines to exclude from consideration
exclude_lines =
exclude_also =
# Have to re-enable the standard pragma
pragma: no cover

# Don't complain about missing debug-only code:
def __repr__
if self\.debug
if self.debug
if settings.DEBUG

# Don't complain if tests don't hit defensive assertion code:
raise AssertionError
Expand All @@ -21,4 +31,7 @@ exclude_lines =
if 0:
if __name__ == .__main__.:

ignore_errors = True
# Nor complain about type checking
"if TYPE_CHECKING:",
class .*\bProtocol\):
@(abc\.)?abstractmethod
51 changes: 34 additions & 17 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,50 @@ name: Publish to PyPI

on:
release:
types: [released, prereleased]

permissions:
contents: read # to fetch code (actions/checkout)
types: [published]

jobs:
build_and_publish:
build:
runs-on: ubuntu-latest
permissions:
contents: read # to fetch code (actions/checkout)
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: Install dependencies
- name: ⬇️ Install build dependencies
run: |
python -m pip install --upgrade pip
python -m pip install wheel
- name: Build
run: python setup.py sdist bdist_wheel
python -m pip install flit

- name: 🏗️ Build
run: python -m flit build

- uses: actions/upload-artifact@v3
with:
path: ./dist

# 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 to PyPI
- name: 🚀 Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: '__token__'
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: artifact/
print-hash: true
21 changes: 21 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Ruff

on:
push:
- main
- 'stable/**'
pull_request:
branches: [main]

jobs:
ruff:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- run: python -Im pip install --user ruff

- name: Run ruff
working-directory: ./src
run: ruff --output-format=github wagtail_localize_git
98 changes: 73 additions & 25 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ on:
branches:
- main
- 'stable/**'

pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

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

env:
FORCE_COLOR: '1' # Make tools pretty.
Expand All @@ -20,47 +23,47 @@ env:
PIP_NO_PYTHON_VERSION_WARNING: '1'
PYTHON_LATEST: '3.11'


jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_LATEST }}
- uses: pre-commit/[email protected]

test-sqlite:
runs-on: ubuntu-latest
needs: lint
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
db: ["sqlite"]
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade tox tox-py tox-venv
python -Im pip install --upgrade pip
python -Im pip install flit tox tox-gh-actions
python -Im flit install --symlink

- name: 🏗️ Build wheel
run: python -Im flit build --format wheel

- name: Test
run: |
tox --py current
run: tox --installpkg ./dist/*.whl

- 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-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
db: ["sqlite"]

services:
postgres:
Expand All @@ -74,15 +77,60 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade tox tox-py tox-venv
- name: Run tox targets for Python ${{ matrix.python-version }}
run: |
tox --py current
python -Im pip install --upgrade pip
python -Im pip install flit tox tox-gh-actions
python -Im flit install --symlink

- name: 🏗️ Build wheel
run: python -Im flit build --format wheel

- name: Test
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/wagtail_localize_git
run: tox --installpkg ./dist/*.whl

- 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
- uses: actions/setup-python@v5
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
uses: actions/upload-artifact@v3
with:
name: html-report
path: htmlcov
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
/build
/dist
/wagtail_localize_git.egg-info
/.coverage
.coverage
.coverage.*
/htmlcov
/.tox
/venv
Expand Down
Loading