Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
187 lines (134 loc) · 7.35 KB
/
Copy pathMakefile
File metadata and controls
187 lines (134 loc) · 7.35 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
.DEFAULT_GOAL:=help
.PHONY: help install format-java check-java build-java generate-protocol-tests generate-codegen-output-py api-snapshot aio-check ci lint-py check-py lint-rust check-rust third-party-licenses test-py test-protocols typecheck-protocols static-analysis test-unit test-functional test-integration benchmark build-py clean
help: ## Show this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-25s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
# CI runs this target on 3.12 only; see typecheck-protocols.
static-analysis: ## Runs check-py, typecheck-protocols, and api-snapshot.
$(MAKE) check-py
$(MAKE) typecheck-protocols
$(MAKE) api-snapshot
# TODO: enable once aws-sdk-signers passes the aio naming rules.
# $(MAKE) aio-check
test-unit: ## Runs the python unit tests.
uv run pytest packages/*/tests/unit
# The packages/*/tests/integration suites drive generated clients against
# in-process servers, so they are functional, not live-service, tests.
test-functional: ## Runs the python functional tests and test-protocols.
$(MAKE) test-protocols
uv pip install h2 trustme -e "packages/smithy-http[awscrt]"
uv run pytest packages/*/tests/functional packages/*/tests/integration --no-cov
test-integration: ## Builds and tests the Java codegen and asserts the regenerated snapshots match.
$(MAKE) build-java
$(MAKE) generate-protocol-tests
$(MAKE) generate-codegen-output-py
ci: ## Runs the full CI sequence locally.
$(MAKE) static-analysis
$(MAKE) check-rust
$(MAKE) test-unit
$(MAKE) test-functional
$(MAKE) build-py
$(MAKE) test-integration
########################## Granular targets below ##########################
install: ## Sets up workspace (* you should run this first! *)
uv sync --all-packages --all-extras
cd codegen && ./gradlew
@printf "\n\nWorkspace initialized, please run:\n\033[36msource .venv/bin/activate\033[0m"
format-java: ## Formats the Java code generation packages.
cd codegen && ./gradlew spotlessApply
check-java: ## Checks Java and Gradle formatting without modifying source.
cd codegen && ./gradlew spotlessCheck
build-java: ## Builds and tests the Java code generation packages without modifying source.
cd codegen && ./gradlew clean build
generate-protocol-tests: ## Generates protocol-test clients, copies them to ./codegen-output, and asserts no git diff.
cd codegen && ./gradlew :protocol-test:clean :protocol-test:build
rm -rf codegen-output
mkdir -p codegen-output
@set -e; for projection_dir in codegen/protocol-test/build/smithyprojections/protocol-test/*/python-client-codegen; do \
projection=$$(basename $$(dirname "$$projection_dir")); \
echo "Copying $$projection -> codegen-output/$$projection"; \
cp -r "$$projection_dir" "codegen-output/$$projection"; \
echo "Formatting codegen-output/$$projection"; \
uv run ruff check --fix "codegen-output/$$projection"; \
uv run ruff format "codegen-output/$$projection"; \
done
@if ! git diff --quiet --exit-code -- codegen-output || [ -n "$$(git ls-files --others --exclude-standard -- codegen-output)" ]; then \
echo "ERROR: generated codegen-output differs from the committed snapshot."; \
echo "Review the diff and commit it if the change is intended:"; \
git --no-pager status --short -- codegen-output; \
git --no-pager diff -- codegen-output; \
exit 1; \
fi
@echo "codegen-output is up to date."
generate-codegen-output-py: ## Generates Python output and asserts no snapshot diff.
rm -rf codegen-output-py
uv run python scripts/codegen-output-py/generate.py
@if ! git diff --quiet --exit-code -- codegen-output-py || [ -n "$$(git ls-files --others --exclude-standard -- codegen-output-py)" ]; then \
echo "ERROR: generated codegen-output-py differs from the committed snapshot."; \
echo "Review the diff and commit it if the change is intended:"; \
git --no-pager status --short -- codegen-output-py; \
git --no-pager diff -- codegen-output-py; \
exit 1; \
fi
@echo "codegen-output-py is up to date."
api-snapshot: ## Records the public API surface of each package and asserts no git diff.
uv run python scripts/api-snapshot/api_snapshot.py
aio-check: ## Enforces aio naming and separation in package sources.
uv run python scripts/aio-naming/aio_naming.py
lint-py: ## Runs linters and formatters on the python packages.
uv run ruff check packages --fix --config pyproject.toml
uv run ruff format packages --config pyproject.toml
check-py: ## Runs checks (formatting, lints, type-checking) on the python packages.
uv run ruff check packages --config pyproject.toml
uv run ruff format --check --config pyproject.toml
uv run pyright packages
# Packages with a native extension, each built from a Cargo.toml in the package root.
RUST_MANIFESTS := $(wildcard packages/*/Cargo.toml)
lint-rust: ## Formats and fixes lints in the Rust extensions.
@set -e; for manifest in $(RUST_MANIFESTS); do \
cargo fmt --manifest-path "$$manifest"; \
cargo clippy --manifest-path "$$manifest" --all-targets --fix --allow-dirty --allow-staged; \
done
check-rust: ## Checks formatting, lints, dependencies, and license attribution of the Rust extensions.
@set -e; for manifest in $(RUST_MANIFESTS); do \
dir=$$(dirname "$$manifest"); \
cargo fmt --manifest-path "$$manifest" --check; \
cargo clippy --manifest-path "$$manifest" --all-targets --locked -- -D warnings; \
cargo deny --manifest-path "$$manifest" check; \
cargo about generate --manifest-path "$$manifest" \
--output-file "$$dir/LICENSE-THIRD-PARTY.expected" "$$dir/about.hbs"; \
if ! diff -u "$$dir/LICENSE-THIRD-PARTY" "$$dir/LICENSE-THIRD-PARTY.expected"; then \
rm "$$dir/LICENSE-THIRD-PARTY.expected"; \
echo "$$dir/LICENSE-THIRD-PARTY is out of date. Run 'make third-party-licenses'."; \
exit 1; \
fi; \
rm "$$dir/LICENSE-THIRD-PARTY.expected"; \
done
third-party-licenses: ## Regenerates the third-party license file of each Rust extension from its Cargo.lock.
@set -e; for manifest in $(RUST_MANIFESTS); do \
dir=$$(dirname "$$manifest"); \
cargo about generate --manifest-path "$$manifest" \
--output-file "$$dir/LICENSE-THIRD-PARTY" "$$dir/about.hbs"; \
done
test-py: ## Runs tests for the python packages.
uv run pytest packages
test-protocols: ## Runs the generated protocol-test clients in ./codegen-output; run generate-protocol-tests first after codegen changes.
uv pip install -e packages/smithy-test
@set -e; for projection_dir in codegen-output/*/; do \
uv pip install "$$projection_dir"; \
uv run pytest "$$projection_dir" --no-cov; \
done
# pyright's wrapper imports typing_extensions, which fails to import on 3.15
# (removed typing.no_type_check_decorator); run the stub type-check on 3.12 only.
typecheck-protocols: ## Type-checks the generated protocol-test stub fixtures in ./codegen-output with pyright.
@set -e; for projection_dir in codegen-output/*/; do \
uv pip install "$$projection_dir"; \
uv run pyright "$$projection_dir/tests/_typecheck.py"; \
done
benchmark: ## Runs ser/deser throughput benchmarks (coverage disabled; not part of CI or the default test run).
uv run pytest packages/*/tests/benchmark --no-cov -s -q
build-py: ## Builds the python packages.
uv build --all-packages
clean: ## Clean up workspace, generated code, and other artifacts.
uv run virtualenv --clear .venv
rm -r dist .pytest_cache .ruff_cache || true
cd codegen && ./gradlew clean