-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
164 lines (129 loc) · 6.5 KB
/
Copy pathMakefile
File metadata and controls
164 lines (129 loc) · 6.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
.DEFAULT_GOAL := help
.PHONY: help dev lint lint-fix format format-check fl lint-ci test test-integration build clean-dist version-upgrade version-upgrade-patch version-upgrade-minor version-upgrade-major require-posthog-key publish ci lock-upgrade lock-check scaffold-lock-upgrade scaffold-lock-check generate-skills update-skills check-skills workspace workspace-init
PYTHON_SOURCES := src tests tests_integration scripts
SCAFFOLD_DIR ?= src/dlthub_init/scaffolds/minimal_workspace
-include .make.env
export DLTHUB_INIT_POSTHOG_KEY
help: ## Show this help message
@echo "Available targets:"
@grep -E '^[a-zA-Z0-9_.-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-22s\033[0m %s\n", $$1, $$2}'
dev: ## Install dev dependencies
uv sync --extra dev
lint: ## Lint with ruff and type-check with mypy
uv run ruff check $(PYTHON_SOURCES)
uv run mypy $(PYTHON_SOURCES)
lint-fix: ## Lint and autofix with ruff, type-check with mypy
uv run ruff check --fix $(PYTHON_SOURCES)
uv run mypy $(PYTHON_SOURCES)
format: ## Format with ruff
uv run ruff format $(PYTHON_SOURCES)
format-check: ## Check formatting with ruff (no writes)
uv run ruff format --check $(PYTHON_SOURCES)
fl: format lint-fix ## Format and lint-fix in one shot
lint-ci: format-check lint ## CI lint workflow (format-check then lint)
test: ## Run unit tests (fast)
uv run python -m unittest discover -s tests -t .
test-integration: ## Run e2e integration tests (slow; invokes real CLI + uv sync)
uv run python -m unittest discover -s tests_integration -t .
#
# Manual test workspaces (under examples/, which is gitignored)
#
WORKSPACE_DIR ?= examples/my-workspace
workspace: dev ## Scaffold a fresh ./$(WORKSPACE_DIR) for eyeballing output (pre-deletes; pass ARGS="--no-sync")
@case "$(WORKSPACE_DIR)" in *..*|"") echo "invalid WORKSPACE_DIR: $(WORKSPACE_DIR)"; exit 1;; esac
rm -rf -- "$(WORKSPACE_DIR)"
uv run dlthub-init "$(WORKSPACE_DIR)" $(ARGS)
WORKSPACE_INIT_DIR ?= examples/init-workspace
workspace-init: dev ## Init in place: make empty ./$(WORKSPACE_INIT_DIR), cd in, run the CLI with no positional (pass ARGS="--no-sync")
@case "$(WORKSPACE_INIT_DIR)" in *..*|"") echo "invalid WORKSPACE_INIT_DIR: $(WORKSPACE_INIT_DIR)"; exit 1;; esac
rm -rf -- "$(WORKSPACE_INIT_DIR)"
mkdir -p -- "$(WORKSPACE_INIT_DIR)"
cd "$(WORKSPACE_INIT_DIR)" && "$(CURDIR)/.venv/bin/dlthub-init" $(ARGS)
build: dev ## Build the package wheel
uv build
clean-dist: ## Remove dist/ directory
-@rm -r dist/
version-upgrade: ## Bump version in pyproject.toml + uv.lock. Prompts when interactive, else pass LEVEL=major|minor|patch (or use version-upgrade-{patch,minor,major})
@level="$(LEVEL)"; \
if [ -z "$$level" ]; then \
if [ -t 0 ]; then \
echo "Current version: $$(uv version --short)"; \
printf "Bump which part? [major/minor/patch] "; \
read level; \
else \
echo "error: no TTY for the prompt — pass LEVEL=major|minor|patch or run 'make version-upgrade-patch'"; exit 1; \
fi; \
fi; \
case "$$level" in \
major|minor|patch) ;; \
*) echo "error: expected major, minor, or patch (got '$$level')"; exit 1;; \
esac; \
uv version --bump "$$level" --no-sync; \
echo "version-upgrade: updated pyproject.toml and uv.lock — review 'git diff pyproject.toml uv.lock' and commit."
version-upgrade-patch: ## Bump the patch version non-interactively (AI/CI-friendly)
@$(MAKE) version-upgrade LEVEL=patch
version-upgrade-minor: ## Bump the minor version non-interactively (AI/CI-friendly)
@$(MAKE) version-upgrade LEVEL=minor
version-upgrade-major: ## Bump the major version non-interactively (AI/CI-friendly)
@$(MAKE) version-upgrade LEVEL=major
require-posthog-key:
@case "$(DLTHUB_INIT_POSTHOG_KEY)" in \
phc_*) ;; \
*) echo "publish: DLTHUB_INIT_POSTHOG_KEY not set (or not a phc_ key) — add it to .make.env"; exit 1;; \
esac
publish: require-posthog-key clean-dist build ## Build and publish dlthub-init to PyPI
ls -l dist/
@bash -c 'read -s -p "Enter PyPI API token: " PYPI_API_TOKEN; echo; \
uv publish --token "$$PYPI_API_TOKEN"'
lock-upgrade: ## Upgrade the root uv.lock to the latest deps pyproject.toml allows (PKG=<name> to bump one); review the diff and commit
uv lock $(if $(PKG),--upgrade-package $(PKG),--upgrade)
lock-check: ## CI guard: fail if the root uv.lock is out of sync with pyproject.toml
@echo "lock-check: checking uv.lock against pyproject.toml…"; \
log="$$(mktemp)"; \
if uv lock --check >"$$log" 2>&1; then \
rm -f "$$log"; \
echo "lock-check: OK — uv.lock is in sync with pyproject.toml."; \
else \
echo "lock-check: FAILED — run 'make lock-upgrade' and commit. uv output:"; \
cat "$$log"; rm -f "$$log"; \
exit 1; \
fi
scaffold-lock-upgrade: ## Re-resolve the bundled workspace uv.lock (PKG=<name> to bump one); review the diff and commit
uv lock $(if $(PKG),--upgrade-package $(PKG),--upgrade) --project $(SCAFFOLD_DIR)
scaffold-lock-check: ## CI guard: fail if the bundled workspace uv.lock is out of sync with its pyproject
@echo "scaffold-lock-check: checking $(SCAFFOLD_DIR)/uv.lock against its pyproject.toml…"; \
log="$$(mktemp)"; \
if uv lock --check --project $(SCAFFOLD_DIR) >"$$log" 2>&1; then \
rm -f "$$log"; \
echo "scaffold-lock-check: OK — uv.lock is in sync with pyproject.toml."; \
else \
echo "scaffold-lock-check: FAILED — run 'make scaffold-lock-upgrade' and commit. uv output:"; \
cat "$$log"; rm -f "$$log"; \
exit 1; \
fi
#
# Skills (pulled from the dltHub AI workbench)
#
generate-skills: ## Populate skills/ from the dltHub AI workbench at the pinned WORKBENCH_REF
uv run python scripts/generate_skills.py
update-skills: ## Bump the workbench ref (REF=<sha>, or latest) and regenerate skills/
uv run python scripts/update_skills.py $(REF)
check-skills: ## CI guard: fail if skills/ differs from the generated output
@echo "check-skills: regenerating skills/ (output hidden unless it fails)…"; \
log="$$(mktemp)"; \
if ! uv run python scripts/generate_skills.py >"$$log" 2>&1; then \
echo "check-skills: generate-skills failed — its output:"; \
cat "$$log"; rm -f "$$log"; exit 1; \
fi; \
rm -f "$$log"; \
changed="$$(git status --porcelain -- skills)"; \
if [ -z "$$changed" ]; then \
echo "check-skills: OK — skills/ is up to date."; \
else \
echo "check-skills: FAILED — skills/ differs from 'make generate-skills'; regenerate and commit:"; \
printf '%s\n' "$$changed" | sed 's/^/ /'; \
git --no-pager diff -- skills; \
exit 1; \
fi
ci: lint-ci test test-integration lock-check scaffold-lock-check check-skills build ## Run all CI checks locally