Skip to content

Commit

Permalink
feat: setup lint workflow
Browse files Browse the repository at this point in the history
Close #1
  • Loading branch information
AiroPi authored Jan 13, 2025
1 parent 91966d3 commit 895c5a3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 30 deletions.
42 changes: 14 additions & 28 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,26 @@
name: lint

on:
workflow_dispatch:
# push:
# pull_request:
# types: [ opened, reopened, synchronize ]
push:
pull_request:
types: [ opened, reopened, synchronize ]

jobs:
check:
name: check ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ '3.10', '3.x' ]

name: check ${{ matrix.python-version }}
defaults:
run:
working-directory: ./python
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up CPython ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
id: install-deps
run: |
pip install -U mypy flake8
pip install -U -r requirements.txt
- name: Run mypy
if: ${{ always() && steps.install-deps.outcome == 'success' }}
run: python3 -m mypy ./src/

- name: Run flake8
if: ${{ always() && steps.install-deps.outcome == 'success' }}
run: flake8 ./src/
- name: Install latest version of uv
uses: astral-sh/setup-uv@v5
- name: Install tox
run: uv sync --only-group tox --frozen --python 3.13
- name: Run tox for python ${{ matrix.python-version }}
run: uv run tox -e py${{ matrix.python-version }}
9 changes: 8 additions & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ dependencies = [
[project.optional-dependencies]
debug = ["markdown"]

# https://docs.astral.sh/uv/concepts/projects/dependencies/#development-dependencies
[dependency-groups]
dev = [{ include-group = "lint" }, { include-group = "tox" }]
lint = ["pyright", "ruff"]
tox = ["tox", "tox-uv"]


# https://docs.astral.sh/uv/concepts/projects/
[tool.uv]
dev-dependencies = [
Expand All @@ -35,7 +42,7 @@ typeCheckingMode = "strict"

# https://tox.wiki/en/latest/
[tool.tox]
envlist = ["py312"]
envlist = ["py313"]

[tool.tox.env_run_base]
runner = "uv-venv-lock-runner"
Expand Down
5 changes: 4 additions & 1 deletion python/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ def read_root():

@app.get("/readme.md")
def get_readme():
from markdown import markdown
try:
from markdown import markdown
except ImportError:
return "Markdown module not installed!"

with open("./README.out.md") as f:
markdown_text = f.read()
Expand Down

0 comments on commit 895c5a3

Please sign in to comment.