-
Notifications
You must be signed in to change notification settings - Fork 27
/
Makefile
193 lines (155 loc) · 4.14 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
.PHONY: check-rustfmt
ifdef GL_DOCKER
REPO_ROOT=/repo
else
REPO_ROOT=$(shell git rev-parse --show-toplevel)
endif
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -p)
ifeq ($(UNAME_S),Linux)
OS = linux
endif
ifeq ($(UNAME_S),Darwin)
OS = macos
endif
ifeq (${UNAME_M},arm64)
RSARCH = "aarch64"
else
RSARCH = ${UNAME_M}
endif
# Path to workspace crates
LIBS = ${REPO_ROOT}/libs
GL_CLIENT = ${LIBS}/gl-client
GL_PLUGIN = ${LIBS}/gl-plugin
GL_SIGNERPROXY = ${LIBS}/gl-signerproxy
# Do not run clippy on dependencies
CLIPPY_OPTS = --no-deps --message-format short
ARTIFACTS = \
.coverage
CHANGED_RUST_SOURCES=$(shell git diff --name-only origin/main | grep '\.rs')
# Variable to collect all generated files into, so we can clean and
# rebuild them easily.
GENALL =
CLN_VERSIONS = \
v0.10.1 \
v0.10.2 \
v0.11.0.1 \
v0.11.2gl2 \
v0.11.2 \
v22.11gl1 \
v23.05gl1 \
v23.08gl1 \
v24.02gl1
DOCKER_OPTIONS= \
--rm \
--user $(shell id -u):$(shell id -g) \
-e TMPDIR=/tmp/gltesting/tmp \
-v /tmp/gltesting/tmp:/tmp/gltesting/tmp \
-e CARGO_TARGET_DIR=/tmp/gltesting/target/target \
-v /tmp/gltesting/target:/tmp/gltesting/target \
-v /tmp/gltesting/cargo/registry:/opt/cargo/registry \
-v ${REPO_ROOT}:/repo
include libs/gl-client-py/Makefile
include libs/gl-testing/Makefile
# sync-files section
.PHONY: sync-files gl_client_sync-files gl_plugin_sync-files gl_signerproxy_sync-files
gl_client_sync-files:
$(MAKE) -C ${GL_CLIENT} sync-files
gl_plugin_sync-files:
$(MAKE) -C ${GL_PLUGIN} sync-files
gl_signerproxy_sync-files:
$(MAKE) -C ${GL_SIGNERPROXY} sync-files
# Sync all files
sync-files: gl_client_sync-files gl_plugin_sync-files gl_signerproxy_sync-files
# Run clippy
clippy:
cargo clippy ${CLIPPY_OPTS}
# Run rust tests
test-rs:
cargo test
# Check runs clippy and the tests but does not fail on clippy warnings
check-rs: clippy test-rs
.PHONY: clippy test-rs check-rs ensure-docker build-self check-self check-all docker-image docs wheels
clean-rs:
cargo clean
clean: clean-rs
rm -rf ${ARTIFACTS}
rm ${GENALL}
gen: ${GENALL}
build-self: ensure-docker
cargo build --all
cd libs/gl-client-py; maturin develop
#mypy examples/python
check-all: check-rs check-self check-py
check-self: ensure-docker build-self
PYTHONPATH=/repo/libs/gl-testing \
pytest -vvv \
/repo/libs/gl-testing \
${PYTEST_OPTS}
check-rustfmt:
@if [ -n "${CHANGED_RUST_SOURCES}" ]; then \
rustfmt --edition 2021 --check ${CHANGED_RUST_SOURCES}; else \
echo "skip rustfmt check no changes detected ${CHANGED_RUST_SOURCES}"; \
fi
ensure-docker:
@if [ "x${GL_DOCKER}" != "x1" ]; then \
echo "We are not running in the gl-testing docker container, refusing to run"; \
exit 1; \
fi
docker-image: ${REPO_ROOT}/docker/gl-testing/Dockerfile
docker buildx build \
--load \
--build-arg DOCKER_USER=$(shell whoami) \
--build-arg UID=$(shell id -u) \
--build-arg GID=$(shell id -g) \
--build-arg GL_TESTING_IGNORE_HASH=1 \
-t gltesting \
-f docker/gl-testing/Dockerfile \
.
docker-volumes:
mkdir -p /tmp/gltesting/tmp && \
mkdir -p /tmp/gltesting/target &&\
mkdir -p /tmp/gltesting/cargo/registry \
docker-shell: docker-volumes
docker run \
-ti \
--cap-add=SYS_PTRACE \
${DOCKER_OPTIONS} \
gltesting bash
docker-check-self: docker-volumes
docker run \
-t \
${DOCKER_OPTIONS} \
gltesting make build-self check-self
docker-check-all:docker-volumes
docker run \
-t \
${DOCKER_OPTIONS} \
gltesting make build-self check-all
docker-check: docker-volumes
docker run \
-t \
-v ${REPO_ROOT}:/repo \
gltesting make check
docker-check-py: docker-volumes
docker run \
-t \
${DOCKER_OPTIONS} \
gltesting make build-self check-py
cln: ${CLN_TARGETS}
docs:
# TODO mypy fails to verify the generated primitives_pb2 types
mypy examples/python/snippets
cargo build --manifest-path=./examples/rust/Cargo.toml
mkdir -p ${REPO_ROOT}/site/
(cd docs; mkdocs build --strict --clean --site-dir=${REPO_ROOT}/site/ --verbose)
pdoc -o site/py glclient
docs-publish: docs
ghp-import ${REPO_ROOT}/site \
--no-jekyll \
-m "Deploy docs [skip ci]" \
--force \
--no-history \
--push \
--branch gh-pages \
--remote origin