diff --git a/.gitignore b/.gitignore index f6a674d..0df56aa 100644 --- a/.gitignore +++ b/.gitignore @@ -134,3 +134,6 @@ dmypy.json # Makefile touch target .uv-installed-* + +# Taskfile hashes +.task diff --git a/Makefile b/Makefile deleted file mode 100644 index 4b36f57..0000000 --- a/Makefile +++ /dev/null @@ -1,56 +0,0 @@ -# Author: Alex B -# Description: Makefile for setting up the development environment. Includes convenient aliases for common tasks. - -PY_VERSION := $(shell cat .python-version) - -.PHONY: uv venv pre-commit dev all test lint format scan scan-new-baseline \ - scan-without-baseline clean - -check: format lint test - -.uv-installed-$(PY_VERSION): .python-version - @if [ ! -f .python-version ]; then echo 'Please create a .python-version file with the desired Python version'; exit 1; fi - @if command -v uv > /dev/null; then echo 'Verified uv is installed'; else echo 'Please install uv by running `curl -LsSf https://astral.sh/uv/install.sh | sh` or visit https://docs.astral.sh/uv/ for more information'; exit 1; fi - @uv tool update-shell - @uv python install - @rm -f .uv-installed-* - @touch .uv-installed-$(PY_VERSION) - - -uv: .uv-installed-$(PY_VERSION) - -.venv: .uv-installed-$(PY_VERSION) - @uv venv .venv - -venv: .venv - -.git/hooks/pre-commit: .uv-installed-$(PY_VERSION) - @uv tool install pre-commit - @uv tool run pre-commit install - -pre-commit: .git/hooks/pre-commit - -dev: .venv .git/hooks/pre-commit - @uv sync --extra=dev --extra=duckdb - -clean: - @rm -rf .venv target demo_duckdb/target demo_sqlite/target - -lint: .uv-installed-$(PY_VERSION) - @uvx ruff check - -format: .uv-installed-$(PY_VERSION) - @uvx ruff check --fix --select I - @uvx ruff format --preview - -test: .uv-installed-$(PY_VERSION) - @uv run pytest tests/ - -scan: .uv-installed-$(PY_VERSION) - @uvx bandit -r src -b tests/bandit_baseline.json - -scan-new-baseline: .uv-installed-$(PY_VERSION) - @uvx bandit -r src -f json -o tests/bandit_baseline.json - -scan-without-baseline: .uv-installed-$(PY_VERSION) - @uvx bandit -r src diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..679e5d2 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,71 @@ +# See https://taskfile.dev/installation/ for installation +version: "3" + +env: + UV_PYTHON: + sh: cat .python-version + +tasks: + default: + desc: By default, run format, lint, test + cmds: + - task: format + - task: lint + - defer: { task: dev } + - task: test + + lint: + desc: Run ruff to check code for linting issues + cmds: + - uvx ruff check + + format: + desc: Auto-fix imports, then format code with ruff + cmds: + - uvx ruff check --fix --select I + - uvx ruff format --preview + + dev: + desc: Sets up dev environment (.venv + pre-commit), syncs dev extra + deps: [venv, pre-commit] + cmds: + - uv -q sync --extra=dev + + venv: + desc: Creates the virtual environment via uv + internal: true + sources: + - .python-version + generates: + - .venv/bin/python + cmds: + - uv venv .venv + + pre-commit: + desc: Installs pre-commit hooks in .git/hooks/pre-commit + internal: true + cmds: + - uv tool install pre-commit + - uv tool run pre-commit install + status: + - test -f .git/hooks/pre-commit + + test: + desc: Run tests against supported python and dbt versions + env: + UV_FROZEN: 1 + UV_NO_SYNC: 1 + UV_NO_PROGRESS: 1 + cmds: + - for: + matrix: + python_version: ["3.10", "3.11", "3.12"] + dbt_version: ["1.8.0", "1.9.0"] + cmd: | + echo -e "\033[32mtask: [test] uv run pytest (python=={{.ITEM.python_version}} and dbt~={{.ITEM.dbt_version}})\033[0m" + export UV_PYTHON={{.ITEM.python_version}} + uv -q sync --extra dev + uv -q pip install --reinstall dbt-core~={{.ITEM.dbt_version}} dbt-duckdb~={{.ITEM.dbt_version}} + uv run dbt parse --project-dir demo_duckdb --profiles-dir demo_duckdb -t test + uv run pytest + silent: true