Skip to content

Commit

Permalink
Merge pull request #46 from sco1/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
sco1 authored Oct 8, 2024
2 parents 6b24f1e + d9cdbaa commit 80f1839
Show file tree
Hide file tree
Showing 13 changed files with 1,033 additions and 1,092 deletions.
35 changes: 7 additions & 28 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,35 +1,14 @@
[flake8]
max-line-length=100
docstring-convention=all
import-order-style=pycharm
application-import-names=pylox,tests
extend-ignore=
P102,B311,W503,E203,E226,S311,
# Missing Docstrings
D100,D104,D105,D107,
# Docstring Whitespace
D203,D212,D214,D215,
# Docstring Quotes
D301,D302,
# Docstring Content
D400,D401,D402,D404,D405,D406,D407,D408,D409,D410,D411,D412,D413,D414,D416,D417,
# Type Annotations
# pycodestyle
E203,E226,E701
# flake8-annotations
ANN002,ANN003,ANN101,ANN102,ANN204,ANN206,
# pep8-naming
N802,N806,N815,
exclude=
__pycache__,.cache,
venv,.venv,
extend-exclude=
.venv,
per-file-ignores =
pylox/protocols/*.py:D101 D102,
pylox/ast_printer.py:D102,
pylox/builtins/py_builtins.py:D101 D102,
pylox/callable.py: D101 D102,
pylox/error.py:D101,
pylox/grammar.py:D101 D102,
pylox/interpreter.py:D102,
pylox/lox.py:B008,
pylox/resolver.py:D101 D102,
tests/*/test_*.py:D103 E501,
tool/generate_ast.py:B008,
tool/generate_tests.py:B008 E501,
tests/*/test_*.py:E501,
tool/generate_tests.py:E501,
97 changes: 71 additions & 26 deletions .github/workflows/lint_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,82 +12,127 @@ jobs:
lint:
runs-on: ubuntu-latest

env:
UV_CACHE_DIR: /tmp/.uv-cache

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

- name: Set up uv
run: curl -LsSf https://astral.sh/uv/0.4.18/install.sh | sh

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"

- name: Restore uv cache
uses: actions/cache@v4
with:
python-version: '3.x'
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install dependencies
run: |
python -m pip install -U pip setuptools importlib-metadata
pip install poetry
poetry install
run: uv sync --all-extras --dev

- name: Run mypy
run: poetry run mypy .
run: uv run mypy .
if: always()

- name: Minimize uv cache
run: uv cache prune --ci

test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12", "3.13-dev"]
fail-fast: false

env:
UV_CACHE_DIR: /tmp/.uv-cache

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- uses: actions/checkout@v4

- name: Set up uv
run: curl -LsSf https://astral.sh/uv/0.4.18/install.sh | sh

- name: Set up (release) Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
if: "!endsWith(matrix.python-version, '-dev')"
with:
python-version: ${{ matrix.python-version }}

- name: Set up (deadsnakes) Python ${{ matrix.python-version }}
uses: deadsnakes/[email protected]
if: endsWith(matrix.python-version, '-dev')
with:
python-version: ${{ matrix.python-version }}

- name: Restore uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install dependencies
run: |
python -m pip install -U pip setuptools importlib-metadata
pip install tox-gh-actions
uv venv
uv pip install tox-gh-actions tox-uv
- name: Run tests w/tox
run: tox
run: uv run tox

- name: Cache coverage for ${{ matrix.python-version }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: cov_py${{ matrix.python-version }}
path: .coverage
if-no-files-found: error
include-hidden-files: true

- name: Minimize uv cache
run: uv cache prune --ci

combine-cov:
runs-on: ubuntu-latest
needs: test

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

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.x'
python-version-file: "pyproject.toml"

- name: Pull coverage workflow artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
path: cov_cache/

- name: Install cov & combine
run: |
pip install coverage
python -m pip install coverage
coverage combine ./cov_cache/**/.coverage
- name: Report coverage
run: |
echo '**Combined Coverage**' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
coverage report -m --skip-covered >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
coverage html
# Report a markdown version to the action summary
echo '**Combined Coverage**' >> $GITHUB_STEP_SUMMARY
coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
- name: Publish cov HTML
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
path: htmlcov/
name: cov_report_html
29 changes: 19 additions & 10 deletions .github/workflows/pypi_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,31 @@ jobs:
build:
name: Build dist & publish
runs-on: ubuntu-latest
permissions:
contents: write

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

- name: Set up uv
run: curl -LsSf https://astral.sh/uv/0.4.18/install.sh | sh

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.x'
python-version-file: "pyproject.toml"

- name: Install build dependencies & build
run: |
python -m pip install --upgrade pip
pip install poetry
poetry build
- name: Build package
run: uvx --from build pyproject-build --installer uv

- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1.4
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.9
with:
user: __token__
password: ${{ secrets.pypi_api_token }}

- name: Upload wheel to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run:
gh release upload ${{ github.event.release.tag_name }} ./dist/sco1_pylox-*.whl
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ci:
autoupdate_schedule: monthly
autoupdate_schedule: quarterly

repos:
- repo: https://github.com/psf/black
rev: 24.8.0
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
Expand All @@ -17,12 +17,8 @@ repos:
- id: flake8
additional_dependencies:
- flake8-annotations
- flake8-bugbear
- flake8-docstrings
- flake8-fixme
- pep8-naming
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-case-conflict
- id: check-json
Expand All @@ -38,3 +34,7 @@ repos:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-use-type-annotations
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
hooks:
- id: ruff
72 changes: 72 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
line-length = 100
fix = false
output-format = "grouped"

extend-exclude = [
"__pycache__",
".cache",
]

[lint]
select = [
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"D", # pydocstyle/flake8-docstrings
"F", # Pyflakes
"FIX", # flake8-fixme
"N", # pep8-naming
]

ignore = [
# pydocstyle
"D100",
"D104",
"D105",
"D107",
"D203",
"D212",
"D214",
"D215",
"D301",
"D400",
"D401",
"D402",
"D404",
"D405",
"D406",
"D407",
"D408",
"D409",
"D410",
"D411",
"D412",
"D413",
"D414",
"D416",
"D417",
# pep8-naming
"N802",
"N806",
"N815",
]

[lint.per-file-ignores]
"pylox/protocols/*.py" = ["D101", "D102",]
"pylox/ast_printer.py" = ["D102",]
"pylox/builtins/py_builtins.py" = ["D101", "D102",]
"pylox/callable.py" = ["D101", "D102"]
"pylox/error.py" = ["D101",]
"pylox/grammar.py" = ["D101", "D102",]
"pylox/interpreter.py" = ["D102",]
"pylox/lox.py" = ["B008",]
"pylox/resolver.py" = ["D101", "D102",]
"tests/*/test_*.py" = ["D101", "D103",]
"tool/generate_ast.py" = ["B008",]
"tool/generate_tests.py" = ["B008"]

[lint.flake8-bugbear]
extend-immutable-calls = [
# Typer CLI
"typer.Option",
"typer.Argument",
]
Loading

0 comments on commit 80f1839

Please sign in to comment.