Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .resources dir to all crates in workspace #501

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ Cargo.lock linguist-generated=true -diff -merge

libs/gl-client/.resources/proto/** linguist-generated=true -diff -text -merge
libs/gl-client/.resources/tls/** linguist-generated=true -diff -text -merge
libs/gl-plugin/.resources/proto/** linguist-generated=true -diff -text -merge
libs/gl-plugin/.resources/tls/** linguist-generated=true -diff -text -merge
libs/gl-signerproxy/.resources/proto/** linguist-generated=true -diff -text -merge
libs/gl-signerproxy/.resources/tls/** linguist-generated=true -diff -text -merge
44 changes: 36 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ 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

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

.PHONY: ensure-docker build-self check-self docker-image docs wheels

include libs/gl-client/Makefile
include libs/gl-client-py/Makefile
include libs/gl-testing/Makefile

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

check: check-rs check-py

clean: clean-rs
rm -rf ${ARTIFACTS}
rm ${GENALL}
Expand All @@ -77,7 +105,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
54 changes: 47 additions & 7 deletions libs/gl-client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,53 @@ REPO_ROOT=$(shell git rev-parse --show-toplevel)
endif

LIBS=${REPO_ROOT}/libs
GL_CLIENT_DIR=${LIBS}/gl-client
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:
rm -rf ${GL_CLIENT_DIR}/.resource/proto .resource/tls
rsync -avr ${LIBS}/proto/ ${GL_CLIENT_DIR}/.resources/proto
rsync -avr ${LIBS}/tls/ ${GL_CLIENT_DIR}/.resources/tls
git add ${GL_CLIENT_DIR}/.resources
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
Loading
Loading