-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tox, configure GHA, pre-commit, ruff
- Loading branch information
Showing
10 changed files
with
437 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[run] | ||
branch = True | ||
concurrency = multiprocessing, thread | ||
parallel = True | ||
source_pkgs = wagtail_bynder | ||
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_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 settings.DEBUG | ||
|
||
# Don't complain if tests don't hit defensive assertion code: | ||
raise AssertionError | ||
raise NotImplementedError | ||
|
||
# Don't complain if non-runnable code isn't run: | ||
if 0: | ||
if __name__ == .__main__.: | ||
|
||
# Nor complain about type checking | ||
"if TYPE_CHECKING:", | ||
class .*\bProtocol\): | ||
@(abc\.)?abstractmethod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# http://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
charset = utf-8 | ||
end_of_line = lf | ||
|
||
[*.{yaml,yml,json,md}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Publish to PyPI | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read # to fetch code (actions/checkout) | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
cache: "pip" | ||
cache-dependency-path: "**/pyproject.toml" | ||
|
||
- name: ⬇️ Install build dependencies | ||
run: | | ||
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 package distributions to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
packages-dir: artifact/ | ||
print-hash: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Ruff | ||
|
||
on: | ||
push: | ||
branches: | ||
- 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_bynder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
name: Wagtail Bynder CI | ||
|
||
on: | ||
push: | ||
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. | ||
TOX_TESTENV_PASSENV: FORCE_COLOR | ||
PIP_DISABLE_PIP_VERSION_CHECK: '1' | ||
PIP_NO_PYTHON_VERSION_WARNING: '1' | ||
PYTHON_LATEST: '3.11' | ||
|
||
jobs: | ||
test-sqlite: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.11"] | ||
django: ["4.2"] | ||
wagtail: ["5.2"] | ||
db: ["sqlite"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
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: | ||
TOXENV: py${{ matrix.python-version }}-django${{ matrix.django }}-wagtail${{ matrix.wagtail }}-sqlite | ||
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 | ||
strategy: | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
db: ["postgres"] | ||
|
||
services: | ||
postgres: | ||
image: postgres:15 | ||
env: | ||
POSTGRES_PASSWORD: postgres | ||
ports: | ||
- 5432:5432 | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
ci: | ||
autofix_prs: false | ||
|
||
default_language_version: | ||
python: python3.11 | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: check-added-large-files | ||
- id: check-case-conflict | ||
- id: check-json | ||
- id: check-merge-conflict | ||
- id: check-symlinks | ||
- id: check-toml | ||
- id: check-yaml | ||
args: ["--unsafe"] | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: 'v0.1.14' | ||
hooks: | ||
- id: ruff | ||
args: [--fix, --exit-non-zero-on-fix] | ||
- id: ruff-format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Wagtail Bynder Changelog |
Oops, something went wrong.