diff --git a/.github/workflows/docs-lint.yaml b/.github/workflows/docs-lint.yaml index 096a70cb..996eb2ce 100644 --- a/.github/workflows/docs-lint.yaml +++ b/.github/workflows/docs-lint.yaml @@ -7,7 +7,7 @@ on: - '**.md' - '.markdownlint-cli2.jsonc' - '.mise.toml' - - 'Makefile' + - 'justfile' - '.github/workflows/docs-lint.yaml' permissions: @@ -19,7 +19,7 @@ jobs: steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # v4.0.1 - - run: make docs/lint + - run: just docs lint build: runs-on: ubuntu-latest @@ -33,4 +33,4 @@ jobs: enable-cache: true - run: | uv sync --group dev - make docs/build + just docs build diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index d88432f9..2439aaf8 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -30,9 +30,12 @@ jobs: with: python-version: ${{ matrix.python-version }} enable-cache: true + - uses: taiki-e/install-action@7a79fe8c3a13344501c80d99cae481c1c9085912 # v2.81.10 + with: + tool: just - run: | uv sync --group dev - make docs/build + just docs build - name: Upload artifact uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0 with: diff --git a/.github/workflows/test-suite.yaml b/.github/workflows/test-suite.yaml index d31792e8..a14d2087 100644 --- a/.github/workflows/test-suite.yaml +++ b/.github/workflows/test-suite.yaml @@ -39,8 +39,11 @@ jobs: with: python-version: ${{ matrix.python-version }} if: matrix.python-version == '3.13' || matrix.python-version == '3.14' + - uses: taiki-e/install-action@7a79fe8c3a13344501c80d99cae481c1c9085912 # v2.81.10 + with: + tool: just - run: | - make tool + just tool - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v6.0.0 @@ -51,4 +54,4 @@ jobs: - name: Test run: | - make tox + just tox diff --git a/.mise.toml b/.mise.toml index ae31d74e..25a01704 100644 --- a/.mise.toml +++ b/.mise.toml @@ -1,3 +1,4 @@ [tools] python = "3.12" +just = "latest" "npm:markdownlint-cli2" = "0.18.1" diff --git a/CLAUDE.md b/CLAUDE.md index d2521479..67a5fc53 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -20,17 +20,17 @@ PyAthena is a Python DB API 2.0 (PEP 249) compliant client for Amazon Athena. Se ### Code Quality — Always Run Before Committing ```bash -make format # Auto-fix formatting and imports -make lint # Lint + format check + mypy +just format # Auto-fix formatting and imports +just lint # Lint + format check + mypy ``` ### Testing ```bash -# ALWAYS run `make lint` first — tests will fail if lint doesn't pass -make test/pyathena # Unit tests (runs lint first) -make test/sqla # SQLAlchemy dialect tests -make test/sqla-async # SQLAlchemy async dialect tests +# ALWAYS run `just lint` first — tests will fail if lint doesn't pass +just test pyathena # Unit tests (runs lint first) +just test sqla # SQLAlchemy dialect tests +just test sqla-async # SQLAlchemy async dialect tests ``` Tests require AWS environment variables. Use a `.env` file (gitignored): @@ -48,7 +48,7 @@ export $(cat .env | xargs) && uv run pytest tests/pyathena/test_file.py -v - Tests mirror source structure under `tests/pyathena/` - Use pytest fixtures from `conftest.py` -- New features require tests; changes to SQLAlchemy dialects must pass `make test-sqla` +- New features require tests; changes to SQLAlchemy dialects must pass `just test sqla` #### Test Conventions @@ -74,9 +74,9 @@ export $(cat .env | xargs) && uv run pytest tests/pyathena/test_file.py -v ```bash mise install # one-time: installs markdownlint-cli2 -make docs/lint # check -make docs/format # auto-fix what's possible -make docs/build # build the Sphinx site under docs/_build/html +just docs lint # check +just docs format # auto-fix what's possible +just docs build # build the Sphinx site under docs/_build/html ``` ## Architecture — Key Design Decisions diff --git a/Makefile b/Makefile deleted file mode 100644 index c529ede1..00000000 --- a/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -RUFF_VERSION := 0.14.14 -TOX_VERSION := 4.34.1 - -.PHONY: format -format: - # TODO: https://github.com/astral-sh/uv/issues/5903 - uvx ruff@$(RUFF_VERSION) check --select I --fix . - uvx ruff@$(RUFF_VERSION) format . - -.PHONY: lint -lint: - uvx ruff@$(RUFF_VERSION) check . - uvx ruff@$(RUFF_VERSION) format --check . - uv run mypy . - -.PHONY: test/pyathena -test/pyathena: lint - uv run pytest -n 8 --cov pyathena --cov-report html --cov-report term tests/pyathena/ - -.PHONY: test/sqla -test/sqla: - uv run pytest -n 8 --cov pyathena --cov-report html --cov-report term tests/sqlalchemy/ - -.PHONY: test/sqla-async -test/sqla-async: - uv run pytest -n 8 --cov pyathena --cov-report html --cov-report term tests/sqlalchemy/ --dburi async - -.PHONY: tox -tox: - uvx tox@$(TOX_VERSION) -c pyproject.toml run - -.PHONY: docs/build -docs/build: - uv run sphinx-multiversion docs docs/_build/html - echo '' > docs/_build/html/index.html - echo 'pyathena.dev' > docs/_build/html/CNAME - touch docs/_build/html/.nojekyll - -.PHONY: docs/lint -docs/lint: - mise exec -- markdownlint-cli2 - -.PHONY: docs/format -docs/format: - mise exec -- markdownlint-cli2 --fix - -.PHONY: tool -tool: - uv tool install ruff@$(RUFF_VERSION) - uv tool install tox@$(TOX_VERSION) --with tox-uv --with tox-gh-actions diff --git a/docs/testing.md b/docs/testing.md index e68cc74f..e46b1eda 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -31,18 +31,20 @@ $ export AWS_ATHENA_MANAGED_WORKGROUP=pyathena-managed ## Run test +The task runner uses [just](https://github.com/casey/just). Install it with `mise use -g just`, `brew install just`, or `cargo install just`. + ```bash $ pip install uv or pipx install uv or brew install uv or mise install uv -$ make test/pyathena -$ make test/sqla -$ make test/sqla-async +$ just test pyathena +$ just test sqla +$ just test sqla-async ``` ## Run test multiple Python versions ```bash $ pip install uv or pipx install uv or brew install uv or mise install uv -$ make tox +$ just tox ``` ## Code formatting @@ -52,13 +54,13 @@ The code formatting uses [ruff](https://github.com/astral-sh/ruff). ### Appy format ```bash -$ make format +$ just format ``` ### Lint and check format ```bash -$ make lint +$ just lint ``` ## GitHub Actions diff --git a/justfile b/justfile new file mode 100644 index 00000000..0f89c043 --- /dev/null +++ b/justfile @@ -0,0 +1,72 @@ +RUFF_VERSION := "0.14.14" +TOX_VERSION := "4.34.1" + +# List available recipes +default: + @just --list + +# Auto-fix formatting and imports +format: + # TODO: https://github.com/astral-sh/uv/issues/5903 + uvx ruff@{{RUFF_VERSION}} check --select I --fix . + uvx ruff@{{RUFF_VERSION}} format . + +# Lint + format check + mypy +lint: + uvx ruff@{{RUFF_VERSION}} check . + uvx ruff@{{RUFF_VERSION}} format --check . + uv run mypy . + +# Run tests: just test (pyathena|sqla|sqla-async) +test target="help": + @just _test-{{ if target =~ "^-" { "help" } else { target } }} + +_test-help: + @echo "Usage: just test " + @echo "" + @echo "Targets:" + @echo " pyathena Run unit tests (runs lint first)" + @echo " sqla Run SQLAlchemy dialect tests" + @echo " sqla-async Run SQLAlchemy async dialect tests" + +_test-pyathena: lint + uv run pytest -n 8 --cov pyathena --cov-report html --cov-report term tests/pyathena/ + +_test-sqla: + uv run pytest -n 8 --cov pyathena --cov-report html --cov-report term tests/sqlalchemy/ + +_test-sqla-async: + uv run pytest -n 8 --cov pyathena --cov-report html --cov-report term tests/sqlalchemy/ --dburi async + +# Run tests across multiple Python versions with tox +tox: + uvx tox@{{TOX_VERSION}} -c pyproject.toml run + +# Docs: just docs (build|lint|format) +docs target="help": + @just _docs-{{ if target =~ "^-" { "help" } else { target } }} + +_docs-help: + @echo "Usage: just docs " + @echo "" + @echo "Targets:" + @echo " build Build the Sphinx documentation site (docs/_build/html)" + @echo " lint Lint Markdown with markdownlint-cli2" + @echo " format Auto-fix Markdown with markdownlint-cli2" + +_docs-build: + uv run sphinx-multiversion docs docs/_build/html + echo '' > docs/_build/html/index.html + echo 'pyathena.dev' > docs/_build/html/CNAME + touch docs/_build/html/.nojekyll + +_docs-lint: + mise exec -- markdownlint-cli2 + +_docs-format: + mise exec -- markdownlint-cli2 --fix + +# Install development tools +tool: + uv tool install ruff@{{RUFF_VERSION}} + uv tool install tox@{{TOX_VERSION}} --with tox-uv --with tox-gh-actions diff --git a/pyproject.toml b/pyproject.toml index c6ca8f1b..c60ce590 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -223,12 +223,12 @@ TEST_TYPE = allowlist_externals = uv uvx - make + just commands = uv sync --group dev - pyathena: make test/pyathena - sqla: make test/sqla - sqla_async: make test/sqla-async + pyathena: just test pyathena + sqla: just test sqla + sqla_async: just test sqla-async passenv = TOXENV AWS_*