forked from getsentry/relay
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
166 lines (122 loc) · 3.95 KB
/
Makefile
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
SHELL=/bin/bash
export RELAY_PYTHON_VERSION := python3
export RELAY_FEATURES := ssl
# This is the subset of --all-features that actually works on OS X. Notably it
# is missing kafka-ssl which would require openssl to be installed on OS X.
export RELAY_DEV_FEATURES := ssl,processing
all: check test
.PHONY: all
check: style lint
.PHONY: check
clean:
cargo clean
rm -rf .venv
.PHONY: clean
# Builds
build: setup-git
cd relay && cargo +stable build --features ${RELAY_DEV_FEATURES}
.PHONY: build
release: setup-git
@cd relay && cargo +stable build --release --locked --features ${RELAY_FEATURES}
.PHONY: release
build-linux-release: setup-git
cd relay && cargo build --release --locked --features ${RELAY_FEATURES} --target=${TARGET}
objcopy --only-keep-debug target/${TARGET}/release/relay{,.debug}
objcopy --strip-debug --strip-unneeded target/${TARGET}/release/relay
objcopy --add-gnu-debuglink target/${TARGET}/release/relay{.debug,}
.PHONY: build-linux-release
sdist: setup-git setup-venv
cd py && ../.venv/bin/python setup.py sdist --format=zip
.PHONY: sdist
wheel: setup-git setup-venv
cd py && ../.venv/bin/python setup.py bdist_wheel
.PHONY: wheel
wheel-manylinux: setup-git
@scripts/docker-manylinux.sh
.PHONY: wheel-manylinux
# Tests
test: test-rust-all test-python test-integration
.PHONY: test
test-rust: setup-git
cargo test --workspace
.PHONY: test-rust
test-rust-all: setup-git
cargo test --workspace --features ${RELAY_DEV_FEATURES}
.PHONY: test-rust-all
test-python: setup-git setup-venv
RELAY_DEBUG=1 .venv/bin/pip install -v --editable py
.venv/bin/pytest -v py
.PHONY: test-python
test-integration: build setup-venv
.venv/bin/pytest tests -n auto -v
.PHONY: test-integration
# Documentation
doc: doc-api
.PHONY: doc-api
doc-api: setup-git
cargo doc --workspace --all-features --no-deps
.PHONY: doc-api
# Style checking
style: style-rust style-python
.PHONY: style
style-rust:
@rustup component add rustfmt --toolchain stable 2> /dev/null
cargo +stable fmt --all -- --check
.PHONY: style-rust
style-python: setup-venv
.venv/bin/black --check py tests --exclude '\.eggs|sentry_relay/_lowlevel.*'
.PHONY: style-python
# Linting
lint: lint-rust lint-python
.PHONY: lint
lint-rust: setup-git
@rustup component add clippy --toolchain stable 2> /dev/null
cargo +stable clippy --workspace --all-features --tests -- -D clippy::all
.PHONY: lint-rust
lint-python: setup-venv
.venv/bin/flake8 py
.PHONY: lint-python
# Formatting
format: format-rust format-python
.PHONY: format
format-rust:
@rustup component add rustfmt --toolchain stable 2> /dev/null
cargo +stable fmt --all
.PHONY: format-rust
format-python: setup-venv
.venv/bin/black py tests scripts --exclude '\.eggs|sentry_relay/_lowlevel.*'
.PHONY: format-python
# Development
setup: setup-git setup-venv
.PHONY: setup
init-submodules:
@git submodule update --init --recursive
.PHONY: init-submodules
setup-git: .git/hooks/pre-commit init-submodules
.PHONY: setup-git
setup-venv: .venv/bin/python
.PHONY: setup-venv
devserver:
@systemfd --no-pid -s http::3000 -- cargo watch -x "run -- run"
.PHONY: devserver
clean-target-dir:
if [ "$$(du -s target/ | cut -f 1)" -gt 4000000 ]; then \
rm -rf target/; \
fi
.PHONY: clean-target-dir
# Dependencies
.venv/bin/python: Makefile
rm -rf .venv
@# --copies is necessary because OS X make checks the mtime of the symlink
@# target (/usr/local/bin/python), which is always much older than the
@# Makefile, and then proceeds to unconditionally rebuild the venv.
$$RELAY_PYTHON_VERSION -m venv --copies .venv
.venv/bin/pip install -U pip wheel
@# Work around https://github.com/confluentinc/confluent-kafka-python/issues/1190
@if [ "$$(uname -sm)" = "Darwin arm64" ]; then \
echo "Using 'librdkafka' from homebrew to build confluent-kafka"; \
export C_INCLUDE_PATH="$$(brew --prefix librdkafka)/include"; \
fi; \
.venv/bin/pip install -U -r requirements-dev.txt
.git/hooks/pre-commit:
@cd .git/hooks && ln -sf ../../scripts/git-precommit-hook pre-commit