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

ci: Switch to UV and update workflow #46

Merged
merged 5 commits into from
Oct 8, 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
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ indent_size = 4
[*.py]
max_line_length = 119

[*.rst]
indent_size = 2

[*.yml]
indent_size = 2
74 changes: 44 additions & 30 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,67 +13,81 @@ concurrency:
jobs:
tests:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04

strategy:
matrix:
python-version:
- 3.8
- 3.9
- '3.10'
- '3.11'
- 3.8
- 3.9
- '3.10'
- '3.11'
- '3.12'
- '3.13'

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: 'requirements/*.txt'
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade tox tox-py
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: tests/requirements/*.txt

- name: Run tox targets for ${{ matrix.python-version }}
run: tox --py current
- name: Install dependencies
run: uv pip install --system tox tox-uv

- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: coverage-data
path: '.coverage.*'
- name: Run tox targets for ${{ matrix.python-version }}
run: tox run -f py$(echo ${{ matrix.python-version }} | tr -d .)

- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-data-${{ matrix.python-version }}
path: '${{ github.workspace }}/.coverage.*'
include-hidden-files: true
if-no-files-found: error

coverage:
name: Coverage
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
needs: tests
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.12'

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Install dependencies
run: python -m pip install --upgrade coverage[toml]
run: uv pip install --system coverage[toml]

- name: Download data
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: coverage-data
path: ${{ github.workspace }}
pattern: coverage-data-*
merge-multiple: true

- name: Combine coverage
- name: Combine coverage and fail if it's <96%
run: |
python -m coverage combine
python -m coverage html --skip-covered --skip-empty
python -m coverage report
python -m coverage report --fail-under=96
echo "## Coverage summary" >> $GITHUB_STEP_SUMMARY
python -m coverage report --format=markdown >> $GITHUB_STEP_SUMMARY

- name: Upload HTML report
if: ${{ failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: html-report
path: htmlcov
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-live-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.12'

- name: Install pypa/build
run: >-
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.12'

- name: Install pypa/build
run: >-
Expand Down
76 changes: 59 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,63 @@ ci:
autoupdate_commit_msg: 'ci: pre-commit autoupdate'
autoupdate_schedule: monthly

repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.16.0
hooks:
- id: pyupgrade
args: ["--py38-plus"]

- repo: https://github.com/adamchainz/django-upgrade
rev: '1.19.0'
hooks:
- id: django-upgrade
args: [--target-version, "3.2"]
default_language_version:
python: python3.12

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.5.0"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.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: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 2.2.1
hooks:
- id: pyproject-fmt
- repo: https://github.com/tox-dev/tox-ini-fmt
rev: 1.3.1
hooks:
- id: tox-ini-fmt
- repo: https://github.com/rstcheck/rstcheck
rev: v6.2.4
hooks:
- id: rstcheck
additional_dependencies:
- tomli==2.0.1
- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/adamchainz/django-upgrade
rev: 1.20.0
hooks:
- id: django-upgrade
args: [--target-version, '3.2']
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.18.0
hooks:
- id: blacken-docs
additional_dependencies:
- black==23.1.0
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
hooks:
- id: mypy
additional_dependencies:
- django-stubs==5.0.4
1 change: 0 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ History
------------------

* Initial release.

47 changes: 0 additions & 47 deletions README.md

This file was deleted.

61 changes: 61 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
django-sys-indicator
====================

.. image:: https://results.pre-commit.ci/badge/github/marksweb/django-sys-indicator/main.svg
:target: https://results.pre-commit.ci/latest/github/marksweb/django-sys-indicator/main
:alt: pre-commit.ci status

.. image:: https://img.shields.io/github/license/marksweb/django-sys-indicator
:target: https://github.com/marksweb/django-sys-indicator/blob/main/LICENSE

.. image:: https://img.shields.io/github/issues/marksweb/django-sys-indicator
:target: https://github.com/marksweb/django-sys-indicator/issues


A visual indicator of what environment/system you're using in django.

.. image:: https://django-sys-indicator.s3.eu-west-2.amazonaws.com/screenshots/django-sys-indicator.jpg
:alt: system indicator examples


To install:

* Add ``"django_sys_indicator.apps.DjangoSysIndicatorConfig"`` to your ``INSTALLED_APPS``

* Add ``"django_sys_indicator.middleware.SystemIndicatorMiddleware"`` to your ``MIDDLEWARE``


Configuration settings and their defaults

.. code-block::

SYSTEM_INDICATOR_ENABLED = False
SYSTEM_INDICATOR_LABEL = "localhost"
SYSTEM_INDICATOR_COLORS = {
# Format here is colour, border colour
"red": ("#c50000", "#daa"),
"blue": ("#006fc4", "#aad"),
"green": ("#009e00", "#ada"),
"purple": ("#800080", "#dad"),
"orange": ("#ff7700", "#ffb57d"),
}

SYSTEM_INDICATOR_COLOR = "red"

SYSTEM_INDICATOR_EXCLUSIONS = []


To exclude paths, include regex in ``SYSTEM_INDICATOR_EXCLUSIONS``

.. code-block::

import re

SYSTEM_INDICATOR_EXCLUSIONS = [
re.compile("^/[^/]+/admin/.\*$"),
]

Example of a localhost indicator in admin;

.. image:: https://django-sys-indicator.s3.eu-west-2.amazonaws.com/screenshots/indicator-admin-header.png
:alt: system indicator admin example
Loading
Loading