diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index aee9ef0..5e7b4d2 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -55,8 +55,11 @@ jobs: - name: Setup Python and uv uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + - name: Setup just + uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4 + - name: Run checks - run: make check + run: just check test: name: Test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 93140bf..00fdd8c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -76,8 +76,11 @@ jobs: - name: Setup Python and uv uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + - name: Setup just + uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4 + - name: Build distributions - run: make build + run: just build - name: Upload distributions uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 41c9373..d273567 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,10 +3,10 @@ This guide reflects the repository's current local tooling and GitHub Actions checks. -By default, use `make` for routine development. Direct -[`uv`](https://docs.astral.sh/uv/), `ruff`, `pytest`, and -[`prek`](https://prek.j178.dev/) usage is still fine when you need a targeted -command. +By default, use `just` for routine development. Direct +[`uv`](https://docs.astral.sh/uv/), [`ruff`](https://docs.astral.sh/ruff/), +[`pytest`](https://docs.pytest.org/), and [`prek`](https://prek.j178.dev/) +usage is still fine when you need a targeted command. ## Development Setup @@ -14,7 +14,8 @@ command. - Python 3.12 or 3.13 - [`uv`](https://docs.astral.sh/uv/) -- `make` +- [`just`](https://just.systems/) +- [`fd`](https://github.com/sharkdp/fd) - `git` Python 3.14 is currently unsupported because `unstructured`, which is used by @@ -23,24 +24,25 @@ the document extraction node, currently declares `Requires-Python: <3.14`. ### Bootstrap ```bash -make dev +just dev # optional for interactive work source .venv/bin/activate ``` -`make dev` will: +`just dev` will: - run `uv sync` - install [`prek`](https://prek.j178.dev/) Git hooks The repository uses [`uv`](https://docs.astral.sh/uv/) for dependency and virtual environment management. The default development environment includes -`ruff`, `pytest`, `pytest-xdist`, `pytest-cov`, `pytest-mock`, and +[`ruff`](https://docs.astral.sh/ruff/), [`pytest`](https://docs.pytest.org/), +`pytest-xdist`, `pytest-cov`, `pytest-mock`, and [`prek`](https://prek.j178.dev/). ### Git Hooks -`make dev` installs [`prek`](https://prek.j178.dev/) hooks from +`just dev` installs [`prek`](https://prek.j178.dev/) hooks from [`prek.toml`](prek.toml). The current hook set includes: @@ -49,7 +51,7 @@ The current hook set includes: - BOM cleanup and line ending normalization - TOML and YAML validation - shebang executable checks -- local `make tc` (which runs `format`, `lint`, and `ty check` in sequence) +- local `just tc` (which runs `format`, `lint`, and `ty check` in sequence) Useful direct commands: @@ -57,10 +59,10 @@ Useful direct commands: uv run prek install uv run prek run -a uv run prek list -uv run prek validate-config +uv run prek validate-config prek.toml ``` -Use `make` by default. For targeted work, direct tool usage is still fine: +Use `just` by default. For targeted work, direct tool usage is still fine: ```bash uv run ruff check src/graphon/path.py @@ -72,48 +74,49 @@ uv run prek run -a Use these commands for normal development: -- `make format`: run `uv run ruff format` -- `make lint`: run `make format`, then `uv run ruff check --fix` -- `make tc`: run `make lint`, then `uv run ty check` -- `make check`: run `uv lock --check && uv run ruff format --check && uv run ruff check && uv run ty check` -- `make test`: run `make tc`, then `uv run pytest` -- `make build`: build the package distributions -- `make clean`: remove build artifacts and caches +- `just`: list available recipes +- `just format`: run `uv run ruff format` +- `just lint`: run `just format`, then `uv run ruff check --fix` +- `just tc`: run `just lint`, then `uv run ty check` +- `just check`: run `uv run prek validate-config prek.toml && uv lock --check && uv run ruff format --check && uv run ruff check && uv run ty check` +- `just test`: run `just tc`, then `uv run pytest` +- `just build`: build the package distributions +- `just clean`: remove build artifacts and caches Notes: -- `make lint` is mutating. It may rewrite files. -- `make tc` is the local type-check entrypoint used by Git hooks. It includes +- `just lint` is mutating. It may rewrite files. +- `just tc` is the local type-check entrypoint used by Git hooks. It includes formatting and lint fixes first. -- `make test` is the progressive local full-chain target. It formats, applies +- `just test` is the progressive local full-chain target. It formats, applies lint fixes, runs `ty check`, and then runs the test suite. -- `make check` aggregates the same non-mutating lockfile, lint, and type-check +- `just check` aggregates the same non-mutating lockfile, lint, and type-check commands used by CI. -- `pytest` is configured with `-n auto` and `testpaths = ['tests']`, so the - test suite runs in parallel by default. +- [`pytest`](https://docs.pytest.org/) is configured with `-n auto` and + `testpaths = ['tests']`, so the test suite runs in parallel by default. - If you change dependencies, refresh and commit `uv.lock` before opening a pull request. For most changes, a good local sequence is: ```bash -make test -make check +just test +just check ``` -`make test` applies local fixes, runs `ty check`, and then runs the test suite. -`make check` then confirms the non-mutating CI check job will pass. +`just test` applies local fixes, runs `ty check`, and then runs the test suite. +`just check` then confirms the non-mutating CI check job will pass. ### CI Checks Pull requests targeting `main` currently run three kinds of checks: 1. PR title validation with `amannn/action-semantic-pull-request` -2. `make check` including `uv.lock` freshness validation +2. `just check` including `uv.lock` freshness validation 3. `uv run pytest` on Python 3.12 and 3.13 -Keep local workflow aligned with those checks. A green local `make test` plus -`make check` is useful, but it is not a complete substitute for the exact CI +Keep local workflow aligned with those checks. A green local `just test` plus +`just check` is useful, but it is not a complete substitute for the exact CI flow because CI also validates PR titles and a Python version matrix. ## Git Commits @@ -177,7 +180,7 @@ Before you open a pull request: - search existing pull requests again to confirm there is no duplicate review in progress - make sure the change stays focused and reviewable -- run `make test` before pushing and keep `make check` green locally when +- run `just test` before pushing and keep `just check` green locally when possible When you open a pull request: diff --git a/Makefile b/Makefile deleted file mode 100644 index 29bf04c..0000000 --- a/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -.PHONY: dev -dev: - uv sync - uv run prek install - -.PHONY: format -format: - uv run ruff format - -.PHONY: lint -lint: format - uv run ruff check --fix - -.PHONY: tc -tc: lint - uv run ty check - -.PHONY: test -test: tc - uv run pytest - -.PHONY: check -check: - uv lock --check - uv run ruff format --check - uv run ruff check - uv run ty check - -.PHONY: build -build: - uv build --no-create-gitignore --no-sources - -.PHONY: clean -clean: - find . -type d -name '__pycache__' -prune -exec rm -rf {} + - rm -rf dist/ .pytest_cache/ - uv run ruff clean diff --git a/README.md b/README.md index 1efb1f0..0b6a849 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,8 @@ Graphon is currently easiest to evaluate from a source checkout. - Python 3.12 or 3.13 - [`uv`](https://docs.astral.sh/uv/) -- `make` +- [`just`](https://just.systems/) +- [`fd`](https://github.com/sharkdp/fd) Python 3.14 is currently unsupported because `unstructured`, which backs part of the document extraction stack, currently declares `Requires-Python: <3.14`. @@ -38,15 +39,15 @@ of the document extraction stack, currently declares `Requires-Python: <3.14`. ### Set up the repository ```bash -make dev +just dev source .venv/bin/activate -make test +just test ``` -`make dev` installs the project, syncs development dependencies, and sets up -[`prek`](https://prek.j178.dev/) Git hooks. `make test` is the progressive +`just dev` installs the project, syncs development dependencies, and sets up +[`prek`](https://prek.j178.dev/) Git hooks. `just test` is the progressive local validation entrypoint: it formats, applies lint fixes, runs `ty check`, -and then runs `pytest`. +and then runs [`pytest`](https://docs.pytest.org/). ## Run the Example Workflows @@ -62,7 +63,7 @@ start -> llm -> answer To run it: ```bash -make dev +just dev source .venv/bin/activate cd examples/slim_llm cp credentials.example.json credentials.json @@ -158,7 +159,7 @@ planned as a separate follow-up. Contributor setup, tooling details, CLA notes, and commit/PR conventions live in [CONTRIBUTING.md](CONTRIBUTING.md). -CI currently validates pull request titles, runs `make check` including +CI currently validates pull request titles, runs `just check` including `uv.lock` freshness validation, and runs `uv run pytest` on Python 3.12 and 3.13. Python 3.14 is currently excluded because `unstructured` does not yet support it. diff --git a/justfile b/justfile new file mode 100644 index 0000000..671348a --- /dev/null +++ b/justfile @@ -0,0 +1,33 @@ +default: + @just --list + +dev: + uv sync + uv run prek install + +format: + uv run ruff format + +lint: format + uv run ruff check --fix + +tc: lint + uv run ty check + +test: tc + uv run pytest + +check: + uv run prek validate-config prek.toml + uv lock --check + uv run ruff format --check + uv run ruff check + uv run ty check + +build: + uv build --no-create-gitignore --no-sources + +clean: + fd -H -t d '^__pycache__$' -x rm -rf + rm -rf dist/ .pytest_cache/ .ruff_cache/ + uv run ruff clean diff --git a/prek.toml b/prek.toml index 8a88d69..b1a9735 100644 --- a/prek.toml +++ b/prek.toml @@ -1,5 +1,3 @@ -minimum_prek_version = "0.3.8" - [[repos]] repo = 'builtin' hooks = [ @@ -11,6 +9,7 @@ hooks = [ {id = 'fix-byte-order-marker'}, {id = 'check-json'}, {id = 'check-json5'}, + {id = 'pretty-format-json'}, {id = 'check-toml'}, {id = 'check-vcs-permalinks'}, {id = 'check-yaml'}, @@ -20,6 +19,7 @@ hooks = [ {id = 'destroyed-symlinks'}, {id = 'check-merge-conflict'}, {id = 'detect-private-key'}, + {id = 'no-commit-to-branch'}, {id = 'check-executables-have-shebangs'}, {id = 'check-shebang-scripts-are-executable'}, ] @@ -28,9 +28,17 @@ hooks = [ repo = 'local' [[repos.hooks]] -id = 'make-tc' -name = 'make tc' -entry = 'make tc' +id = 'prek-validate-config' +name = 'prek validate-config' +entry = 'uv run prek validate-config prek.toml' +language = 'system' +always_run = true +pass_filenames = false + +[[repos.hooks]] +id = 'just-tc' +name = 'just tc' +entry = 'just tc' language = 'system' always_run = true pass_filenames = false