Skip to content

Commit

Permalink
chore: Add convenience targets to Makefiles
Browse files Browse the repository at this point in the history
Adds some rust (cargo) convenience targets to the Makefiles, this allows
to run clippy on `check` targets. This may help us to address clippy
hints in the future.

Signed-off-by: Peter Neuroth <[email protected]>
  • Loading branch information
nepet committed Aug 19, 2024
1 parent 5cdfe52 commit 9cdee63
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 8 deletions.
23 changes: 17 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ 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

Expand Down Expand Up @@ -58,6 +61,7 @@ DOCKER_OPTIONS= \
-v /tmp/gltesting/cargo/registry:/opt/cargo/registry \
-v ${REPO_ROOT}:/repo

# 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
Expand All @@ -68,18 +72,25 @@ 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

.PHONY: ensure-docker build-self check-self docker-image docs wheels
# Run clippy
clippy:
cargo clippy ${CLIPPY_OPTS}

# Run rust tests
test-rs:
cargo test

check-rs:
cargo test --all -- --test-threads=1
# 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

check: check-rs check-py

clean: clean-rs
rm -rf ${ARTIFACTS}
rm ${GENALL}
Expand All @@ -91,7 +102,7 @@ build-self: ensure-docker
cd libs/gl-client-py; maturin develop
#mypy examples/python

check-all: check-self check-gl-client check-py
check-all: check-rs check-self check-py

check-self: ensure-docker build-self
PYTHONPATH=/repo/libs/gl-testing \
Expand Down
43 changes: 41 additions & 2 deletions libs/gl-client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,51 @@ endif
LIBS=${REPO_ROOT}/libs
SELF_DIR=${LIBS}/gl-client

check-gl-client:
(cd ${GL_CLIENT_DIR}; cargo test)
MANIFEST_PATH = --manifest-path=${SELF_DIR}/Cargo.toml
FMT_OPTS = -- --check
CLIPPY_OPTS = --no-deps --message-format short

# Check code for formatting issues
fmt:
cargo fmt ${MANIFEST_PATH} ${FMT_OPTS}

# Fix formatting issues
fmt-fix:
cargo fmt ${MANIFEST_PATH}

# Check Clippy linter, does not fail on warnings
clippy:
cargo clippy ${CLIPPY_OPTS} ${MANIFEST_PATH}

# Run clippy linter and fix issues automatically where possible
clippy-fix:
cargo clippy --fix ${MANIFEST_PATH}

# Run tests
test:
cargo test ${MANIFEST_PATH}

# Checks that clippy and tests only produce warnings
check: clippy test

# Same as check but also fails if there are formatting issues
check-all: fmt clippy test

# Syncronize proto and tls files into .resources dir
sync-files:
rsync -avr --delete --delete-excluded ${LIBS}/proto/ ${SELF_DIR}/.resources/proto
rsync -avr --delete --delete-excluded ${LIBS}/tls/ ${SELF_DIR}/.resources/tls
git add ${SELF_DIR}/.resources

help:
@echo "Usage:"
@echo " make check - Check the project"
@echo " make check-all - Same as make check but also checks the format"
@echo " make test - Run tests"
@echo " make clippy - Run Clippy linter"
@echo " make clippy-fix - Run Clippy and automatically fix issues"
@echo " make fmt - Check code formatting"
@echo " make fmt-fix - Format the code (in-place)"
@echo " make help - Show this help message"

.PHONY: fmt fmt-fix clippy clippy-fix check sync-files help
30 changes: 30 additions & 0 deletions libs/gl-plugin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,36 @@ endif
LIBS=${REPO_ROOT}/libs
SELF_DIR=${LIBS}/gl-plugin

MANIFEST_PATH = --manifest-path=${SELF_DIR}/Cargo.toml
FMT_OPTS = -- --check
CLIPPY_OPTS = --no-deps --message-format short

# Check code for formatting issues
fmt:
cargo fmt ${MANIFEST_PATH} ${FMT_OPTS}

# Fix formatting issues
fmt-fix:
cargo fmt ${MANIFEST_PATH}

# Check Clippy linter, does not fail on warnings
clippy:
cargo clippy ${CLIPPY_OPTS} ${MANIFEST_PATH}

# Run clippy linter and fix issues automatically where possible
clippy-fix:
cargo clippy --fix ${MANIFEST_PATH}

# Run tests
test:
cargo test ${MANIFEST_PATH}

# Checks that clippy and tests only produce warnings
check: clippy test

# Same as check but also fails if there are formatting issues
check-all: fmt clippy test

# Syncronize proto and tls files into .resources dir
sync-files:
rsync -avr --delete --delete-excluded ${LIBS}/proto/glclient/greenlight.proto ${SELF_DIR}/.resources/proto/glclient/greenlight.proto
Expand Down
30 changes: 30 additions & 0 deletions libs/gl-signerproxy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,36 @@ endif
LIBS=${REPO_ROOT}/libs
SELF_DIR=${LIBS}/gl-signerproxy

MANIFEST_PATH = --manifest-path=${SELF_DIR}/Cargo.toml
FMT_OPTS = -- --check
CLIPPY_OPTS = --no-deps --message-format short

# Check code for formatting issues
fmt:
cargo fmt ${MANIFEST_PATH} ${FMT_OPTS}

# Fix formatting issues
fmt-fix:
cargo fmt ${MANIFEST_PATH}

# Check Clippy linter, does not fail on warnings
clippy:
cargo clippy ${CLIPPY_OPTS} ${MANIFEST_PATH}

# Run clippy linter and fix issues automatically where possible
clippy-fix:
cargo clippy --fix ${MANIFEST_PATH}

# Run tests
test:
cargo test ${MANIFEST_PATH}

# Checks that clippy and tests only produce warnings
check: clippy test

# Same as check but also fails if there are formatting issues
check-all: fmt clippy test

# Syncronize proto and tls files into .resources dir
sync-files:
rsync -avr --delete --delete-excluded ${LIBS}/proto/glclient/greenlight.proto ${SELF_DIR}/.resources/proto/glclient/greenlight.proto
Expand Down

0 comments on commit 9cdee63

Please sign in to comment.