Skip to content

Commit

Permalink
chore: rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Oct 15, 2024
1 parent 5261c03 commit 2f5616f
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 149 deletions.
107 changes: 54 additions & 53 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,39 @@ on: [push, pull_request]

jobs:
test:

runs-on: ubuntu-latest
strategy:
matrix:
python_version: ['3.11', '3.12', '3.13']
python_version: ["3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v2
- name: Install uv
uses: yezz123/setup-uv@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatch
hatch env create
- name: Lint and typecheck
run: |
hatch run lint-check
- name: Test
run: |
hatch run test-cov-xml
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v2
- name: Install uv
uses: yezz123/setup-uv@v4
- name: Install dependencies
run: |
uv sync --all-extras
- name: Lint and typecheck
run: |
uv run ruff check .
uv run ruff format --check .
uv run mypy mknodes/
- name: Test
run: |
pytest --cov-report=xml
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true

release:
runs-on: ubuntu-latest
Expand All @@ -48,27 +47,29 @@ jobs:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
pip install hatch
- name: Build and publish on PyPI
env:
HATCH_INDEX_USER: ${{ secrets.HATCH_INDEX_USER }}
HATCH_INDEX_AUTH: ${{ secrets.HATCH_INDEX_AUTH }}
run: |
hatch build
hatch publish
- name: Create release
uses: ncipollo/release-action@v1
with:
draft: true
body: ${{ github.event.head_commit.message }}
artifacts: dist/*.whl,dist/*.tar.gz
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
uses: yezz123/setup-uv@v4
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
pip install hatch
- name: Build and publish on PyPI
env:
HATCH_INDEX_USER: ${{ secrets.HATCH_INDEX_USER }}
HATCH_INDEX_AUTH: ${{ secrets.HATCH_INDEX_AUTH }}
run: |
hatch build
hatch publish
- name: Create release
uses: ncipollo/release-action@v1
with:
draft: true
body: ${{ github.event.head_commit.message }}
artifacts: dist/*.whl,dist/*.tar.gz
token: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
uses: yezz123/setup-uv@v4
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v2
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatch
hatch env create
uv sync --all-extras
- name: Run benchmarks
uses: CodSpeedHQ/action@v3
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: "hatch run pytest benchmarks/ --codspeed"
run: "uv run pytest benchmarks/ --codspeed"
39 changes: 18 additions & 21 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,27 @@ defaults:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v2
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatch
hatch env create
- name: Build
run: hatch run mkdocs build -v
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./site
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v2
- name: Install dependencies
run: |
uv sync --all-extras
- name: Build
run: uv run mkdocs build -v
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./site

deploy:
environment:
Expand Down
86 changes: 43 additions & 43 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
default_language_version:
python: python3.12
python: python3.12
default_stages: [pre-commit]
repos:
- repo: local
hooks:
- id: pytest-check
name: pytest-check
entry: hatch run test
language: system
# stages: [push]
types: [python]
pass_filenames: false
always_run: true
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
# - id: trailing-whitespace
# - id: check-ast
- id: check-case-conflict
- id: check-docstring-first
- id: check-merge-conflict
# - id: check-yaml
- id: check-toml
- id: check-json
- id: detect-private-key
- id: forbid-new-submodules
# - id: check-added-large-files
# https://pre-commit.com/hooks.html
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
hooks:
- id: mypy
# args: [--ignore-missing-imports]
additional_dependencies: []
- repo: local
hooks:
- id: pytest-check
name: pytest-check
entry: uv run pytest
language: system
# stages: [push]
types: [python]
pass_filenames: false
always_run: true
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
# - id: trailing-whitespace
# - id: check-ast
- id: check-case-conflict
- id: check-docstring-first
- id: check-merge-conflict
# - id: check-yaml
- id: check-toml
- id: check-json
- id: detect-private-key
- id: forbid-new-submodules
# - id: check-added-large-files
# https://pre-commit.com/hooks.html
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
hooks:
- id: mypy
# args: [--ignore-missing-imports]
additional_dependencies: []

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.6.9
hooks:
- id: ruff
- id: ruff-format
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.6.9
hooks:
- id: ruff
- id: ruff-format

- repo: https://github.com/commitizen-tools/commitizen
rev: v3.29.1
hooks:
- id: commitizen
stages: [commit-msg]
additional_dependencies: [typing-extensions]
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.29.1
hooks:
- id: commitizen
stages: [commit-msg]
additional_dependencies: [typing-extensions]
43 changes: 15 additions & 28 deletions duties.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
from __future__ import annotations

import json

from duty import duty


ENV_PREFIX = "hatch run "

PARAMS = ["--disable-pip-version-check", "--outdated", "--format=json"]
UPDATE_CMD = f"""{ENV_PREFIX}python -m pip list {" ".join(PARAMS)}"""


@duty(capture=False)
def build(ctx, *args: str):
"""Build a MkNodes page."""
args_str = " " + " ".join(args) if args else ""
ctx.run(f"{ENV_PREFIX}mknodes build{args_str}")
ctx.run(f"uv run mknodes build{args_str}")


@duty(capture=False)
def serve(ctx, *args: str):
"""Serve a MkNodes page."""
args_str = " " + " ".join(args) if args else ""
ctx.run(f"{ENV_PREFIX}mknodes serve{args_str}")
ctx.run(f"uv run mknodes serve{args_str}")


@duty(capture=False)
def test(ctx, *args: str):
"""Serve a MkNodes page."""
args_str = " " + " ".join(args) if args else ""
ctx.run(f"{ENV_PREFIX}pytest{args_str}")
ctx.run(f"uv run pytest{args_str}")


@duty(capture=False)
Expand All @@ -38,38 +30,33 @@ def clean(ctx):
ctx.run("git clean -dfX")


@duty
def update(ctx, *args: str):
@duty(capture=False)
def update(ctx):
"""Update all environment packages using pip directly."""
args_str = " " + " ".join(args) if args else ""
reqs = ctx.run(UPDATE_CMD + args_str)
packages = [x["name"] for x in json.loads(reqs)]
if packages:
pkgs = " ".join(packages)
print(f"Packages to update: {pkgs}")
ctx.run(f"{ENV_PREFIX}python -m pip install -U {pkgs}{args_str}", capture=False)
else:
print("No packages to update!")
ctx.run(f"{ENV_PREFIX}python -m pip install -e .", capture=False)
ctx.run("uv sync --all-extras")


@duty(capture=False)
def lint(ctx):
"""Update all environment packages using pip directly."""
ctx.run(f"{ENV_PREFIX}lint")
"""Lint and fix the code."""
ctx.run("uv run ruff check --fix .")
ctx.run("uv run ruff format .")
ctx.run("uv run mypy mknodes/")


@duty(capture=False)
def lint_check(ctx):
"""Update all environment packages using pip directly."""
ctx.run(f"{ENV_PREFIX}lint-check")
"""Lint the code."""
ctx.run("uv run ruff check .")
ctx.run("uv run ruff format --check .")
ctx.run("uv run mypy mknodes/")


@duty(capture=False)
def profile(ctx, *args: str):
"""Run generating the docs using pyinstrument."""
args_str = " " + " ".join(args) if args else ""
ctx.run(f"{ENV_PREFIX}pyinstrument mknodes/manual/root.py{args_str}")
ctx.run(f"uv run pyinstrument mknodes/manual/root.py{args_str}")


@duty(capture=False)
Expand Down

0 comments on commit 2f5616f

Please sign in to comment.