-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathMakefile
More file actions
116 lines (92 loc) · 4.48 KB
/
Makefile
File metadata and controls
116 lines (92 loc) · 4.48 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
# Default value for environment variable. Can be overridden by setting the
# environment variable.
SAM_CLI_TELEMETRY ?= 0
.PHONY: schema init-nightly init-latest-release setup-pytest
# Initialize environment specifically for Github action tests using uv
init:
@if [ "$$GITHUB_ACTIONS" = "true" ]; then \
command -v uv >/dev/null 2>&1 || pip install uv==0.9.1; \
SAM_CLI_DEV=1 uv pip install --system --break-system-packages --python "$$(uv python find $$UV_PYTHON)" -e '.[dev]'; \
else \
SAM_CLI_DEV=1 pip install -e '.[dev]'; \
fi
# Set up a pytest venv with test dependencies
setup-pytest:
python3.11 -m venv $(HOME)/pytest
uv pip install --python $(HOME)/pytest/bin/python3 -r requirements/dev.txt -r requirements/base.txt
sudo ln -sf $(HOME)/pytest/bin/pytest /usr/local/bin/pytest
pytest --version
# Install SAM CLI nightly binary
init-nightly:
bash tests/install-sam-cli-binary.sh sam-cli-nightly
# Install SAM CLI latest release binary
init-latest-release:
bash tests/install-sam-cli-binary.sh
test:
# Run unit tests and fail if coverage falls below 94%
pytest --cov samcli --cov schema --cov-report term-missing --cov-fail-under 94 tests/unit
test-cov-report:
# Run unit tests with html coverage report
pytest --cov samcli --cov schema --cov-report html --cov-fail-under 94 tests/unit
integ-test:
# Integration tests don't need code coverage
@echo Telemetry Status: $(SAM_CLI_TELEMETRY)
SAM_CLI_DEV=1 pytest tests/integration
func-test:
# Verify function test coverage only for `samcli.local` package
@echo Telemetry Status: $(SAM_CLI_TELEMETRY)
pytest --cov samcli.local --cov samcli.commands.local --cov-report term-missing tests/functional
regres-test:
@echo Telemetry Status: $(SAM_CLI_TELEMETRY)
SAM_CLI_DEV=1 pytest tests/regression
smoke-test:
# Smoke tests run in parallel
SAM_CLI_DEV=1 pytest -n 4 tests/smoke
lint:
# Linter performs static analysis to catch latent bugs
ruff check samcli schema
# mypy performs type check
mypy --exclude /testdata/ --exclude /init/templates/ --no-incremental setup.py samcli tests schema
# Command to run everytime you make changes to verify everything works
dev: lint test
black:
black setup.py samcli tests schema
black-check:
@if python -c "import sys; sys.exit(0 if sys.version_info >= (3, 10) else 1)" 2>/dev/null; then \
black --check setup.py samcli tests schema; \
else \
echo "Skipping black check on Python < 3.10"; \
fi
format: black
ruff check samcli --fix
schema:
python -m schema.make_schema
# Verifications to run before sending a pull request
pr: init schema black-check dev
# lucashuy: Linux and MacOS are on the same Python version,
# however we should follow up in a different change
# to consider combining these files again
update-reproducible-linux-reqs:
python3.11 -m venv venv-update-reproducible-linux
venv-update-reproducible-linux/bin/pip install pip==24.0 pip-tools==7.4.1
venv-update-reproducible-linux/bin/pip install -r requirements/base.txt
venv-update-reproducible-linux/bin/pip-compile --generate-hashes --allow-unsafe -o requirements/reproducible-linux.txt
update-reproducible-mac-reqs:
python3.11 -m venv venv-update-reproducible-mac
venv-update-reproducible-mac/bin/pip install pip==24.0 pip-tools==7.4.1
venv-update-reproducible-mac/bin/pip install -r requirements/base.txt
venv-update-reproducible-mac/bin/pip-compile --generate-hashes --allow-unsafe -o requirements/reproducible-mac.txt
# note that this should be run on a windows environment with python3.8 as default interpreter
update-reproducible-win-reqs:
python -m venv venv-update-reproducible-win
.\venv-update-reproducible-win\Scripts\activate
python.exe -m pip install pip==24.0 pip-tools==7.4.1
pip install -r requirements\base.txt
pip-compile --generate-hashes --allow-unsafe -o requirements\reproducible-win.txt
update-reproducible-reqs: update-reproducible-linux-reqs update-reproducible-mac-reqs
# Update all reproducible requirements using uv (can run from any platform)
update-reproducible-reqs-uv:
@command -v uv >/dev/null 2>&1 || pip install uv
uv pip compile setup.py --generate-hashes --output-file requirements/reproducible-linux.txt --python-platform linux --python-version 3.11 --no-cache --no-strip-extras
uv pip compile setup.py --generate-hashes --output-file requirements/reproducible-mac.txt --python-platform macos --python-version 3.11 --no-cache --no-strip-extras
uv pip compile setup.py --generate-hashes --output-file requirements/reproducible-win.txt --python-platform windows --python-version 3.12 --no-cache --no-strip-extras