-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
141 lines (116 loc) · 4.43 KB
/
Copy pathMakefile
File metadata and controls
141 lines (116 loc) · 4.43 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
.PHONY: version/get
version/get: ## Get version.
@jq -r '.metadata.library_version' griptape_nodes_library.json
.PHONY: version/set
version/set: ## Set version. Usage: make version/set v=1.2.3
@jq --arg v "$(v)" '.metadata.library_version = $$v' griptape_nodes_library.json > griptape_nodes_library.json.tmp
@mv griptape_nodes_library.json.tmp griptape_nodes_library.json
@make version/commit
.PHONY: version/patch
version/patch: ## Bump patch version.
@CURRENT=$$(make version/get); \
IFS='.' read -r major minor patch <<< "$$CURRENT"; \
NEW_VERSION="$${major}.$${minor}.$$((patch + 1))"; \
jq --arg v "$$NEW_VERSION" '.metadata.library_version = $$v' griptape_nodes_library.json > griptape_nodes_library.json.tmp; \
mv griptape_nodes_library.json.tmp griptape_nodes_library.json; \
echo "Bumped to $$NEW_VERSION"
@make version/commit
.PHONY: version/minor
version/minor: ## Bump minor version.
@CURRENT=$$(make version/get); \
IFS='.' read -r major minor patch <<< "$$CURRENT"; \
NEW_VERSION="$${major}.$$((minor + 1)).0"; \
jq --arg v "$$NEW_VERSION" '.metadata.library_version = $$v' griptape_nodes_library.json > griptape_nodes_library.json.tmp; \
mv griptape_nodes_library.json.tmp griptape_nodes_library.json; \
echo "Bumped to $$NEW_VERSION"
@make version/commit
.PHONY: version/major
version/major: ## Bump major version.
@CURRENT=$$(make version/get); \
IFS='.' read -r major minor patch <<< "$$CURRENT"; \
NEW_VERSION="$$((major + 1)).0.0"; \
jq --arg v "$$NEW_VERSION" '.metadata.library_version = $$v' griptape_nodes_library.json > griptape_nodes_library.json.tmp; \
mv griptape_nodes_library.json.tmp griptape_nodes_library.json; \
echo "Bumped to $$NEW_VERSION"
@make version/commit
.PHONY: version/commit
version/commit: ## Commit version.
@git add griptape_nodes_library.json
@git commit -m "chore: bump v$$(make version/get)"
.PHONY: version/publish
version/publish: ## Create and push git tags.
@git fetch --tags --force
@git tag "v$$(make version/get)"
@git tag stable -f
@git push origin "v$$(make version/get)"
@git push -f origin stable
.PHONY: deps/sync
deps/sync: ## Sync pip_dependencies in griptape_nodes_library.json from pyproject.toml.
@uv run python -c "\
import tomllib, json; \
pyproject = tomllib.load(open('pyproject.toml', 'rb')); \
deps = [d for d in pyproject['project']['dependencies'] if not d.startswith('griptape-nodes')]; \
lib = json.load(open('griptape_nodes_library.json')); \
lib['metadata'].setdefault('dependencies', {})['pip_dependencies'] = deps; \
open('griptape_nodes_library.json', 'w').write(json.dumps(lib, indent=2) + '\n'); \
print(f'Synced {len(deps)} dependencies to griptape_nodes_library.json')"
.PHONY: install
install: ## Install all dependencies.
@make install/all
.PHONY: install/core
install/core: deps/sync ## Install core dependencies.
@uv sync
.PHONY: install/all
install/all: deps/sync ## Install all dependencies.
@uv sync --all-groups --all-extras
.PHONY: install/dev
install/dev: ## Install dev dependencies.
@uv sync --group dev
.PHONY: lint
lint: ## Lint project.
@uv run ruff check --fix
.PHONY: format
format: ## Format project.
@uv run ruff format
.PHONY: fix
fix: ## Fix project.
@make format
@uv run ruff check --fix --unsafe-fixes
.PHONY: check
check: check/format check/lint check/types check/json ## Run all checks.
.PHONY: check/format
check/format:
@uv run ruff format --check
.PHONY: check/lint
check/lint:
@uv run ruff check .
.PHONY: check/types
check/types:
@uv run pyright .
.PHONY: check/json
check/json: ## Validate JSON files.
@echo "Checking JSON files..."
@find . -name "*.json" -type f \
! -path "./.venv/*" \
! -path "./node_modules/*" \
-exec sh -c 'jq empty "{}" > /dev/null 2>&1 || (echo "Invalid JSON: {}" && exit 1)' \;
.PHONY: test
test: ## Run all tests.
@uv run pytest tests/
.PHONY: test/unit
test/unit: ## Run unit tests.
@uv run pytest tests/unit
.PHONY: test/unit/coverage
test/unit/coverage: ## Run unit tests with coverage.
@uv run pytest --cov=griptape_nodes_library --cov-report=xml --cov-report=term tests/unit
.PHONY: test/workflows
test/workflows: ## Run workflow tests.
@uv run pytest -s tests/workflows
.DEFAULT_GOAL := help
.PHONY: help
help: ## Print Makefile help text.
@# Matches targets with a comment in the format <target>: ## <comment>
@# then formats help output using these values.
@grep -E '^[a-zA-Z_\/-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; \
{printf "\033[36m%-12s\033[0m%s\n", $$1, $$2}'