Skip to content

Commit

Permalink
fix: use venv in makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandr Chikovani committed Sep 19, 2023
1 parent d7cb2ab commit 5524533
Showing 1 changed file with 33 additions and 13 deletions.
46 changes: 33 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ endif

VENV=.venv
BUILD=$(VENV)/bin/activate
SHELL := /bin/bash

install: $(BUILD)

Expand All @@ -21,39 +22,58 @@ $(BUILD): $(REQ)
.PHONY: install server-run client-run clean lint format test integration_test docker-build docker-run

server-run: $(BUILD)
@source ./load_env.sh; load_env; \
python -m server.main --port=$(PORT)
( \
source $(VENV)/bin/activate; \
source ./load_env.sh; load_env; \
python -m debug_app --port=$(PORT); \
)

client-run: $(BUILD)
@source ./load_env.sh; load_env; \
python -m client.client_adapter
( \
source $(VENV)/bin/activate; \
source ./load_env.sh; load_env; \
python -m client.client_adapter; \
)

clean:
rm -rf $(VENV)
find . -type f -name '*.pyc' -not -path './.venv/*' -delete

lint: $(BUILD)
pyright
flake8
( \
source $(VENV)/bin/activate; \
pyright; \
flake8; \
)
$(MAKE) format ARGS="--check"

format: $(BUILD)
autoflake . $(ARGS)
isort . $(ARGS)
black . $(ARGS)
( \
source $(VENV)/bin/activate; \
autoflake . $(ARGS); \
isort . $(ARGS); \
black . $(ARGS); \
)

TEST_FILES ?= ./tests/unit_tests

# Add options "-s --log-cli-level=NOTSET" to pytest to see all logs
test: $(BUILD)
python -m pytest $(TEST_FILES) -v --durations=0 -rA
( \
source $(VENV)/bin/activate; \
source ./load_env.sh; load_env; \
python -m pytest $(TEST_FILES) -v --durations=0 -rA
)

integration_test: $(BUILD)
@source ./load_env.sh; load_env; \
python -m pytest ./tests/integration_tests -v --durations=0 -rA
( \
source $(VENV)/bin/activate; \
source ./load_env.sh; load_env; \
python -m pytest ./tests/integration_tests -v --durations=0 -rA
)

docker-build: Dockerfile
docker build --platform linux/amd64 -t $(IMAGE_NAME) .

docker-run: docker-build
docker run --platform linux/amd64 --env-file ./.env -p $(PORT):5000 $(IMAGE_NAME)
docker run --platform linux/amd64 --env-file ./.env -p $(PORT):5000 $(IMAGE_NAME)

0 comments on commit 5524533

Please sign in to comment.