Skip to content
Draft
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
36 changes: 35 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ ifndef PY
PY = 3
endif

FORMAT_ENFORCE_DIRS = ./mig/lib ./tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to include ./bin and ./sbin here in line with https://github.com/ucphhpc/migrid-sync/milestone/7 . Not sure it causes troubles with the out-of-dir symlinks being too 'greedy', though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, wasn't sure exactly how far we'd go here so so went for the places I was positive of for a first draft - will attempt that fuller list.

FORMAT_EXCLUDE_REGEX = '.git|tests/data/|tests/fixture/'
FORMAT_EXCLUDE_GLOB = '.git/* tests/data/* tests/fixture/*'
FORMAT_LINE_LENGTH = 80
LOCAL_PYTHON_BIN = './envhelp/lpython'

ifdef PYTHON_BIN
Expand Down Expand Up @@ -35,7 +39,37 @@ ifneq ($(MIG_ENV),'local')
@echo "unavailable outside local development environment"
@exit 1
endif
$(LOCAL_PYTHON_BIN) -m autopep8 --ignore E402 -i
@make format-python

.PHONY:format-python
format-python:
@$(LOCAL_PYTHON_BIN) -m black $(FORMAT_ENFORCE_DIRS) \
--line-length=$(FORMAT_LINE_LENGTH) \
--exclude=$(FORMAT_EXCLUDE_REGEX)
@$(LOCAL_PYTHON_BIN) -m isort $(FORMAT_ENFORCE_DIRS) \
--profile=black \
--line-length=$(FORMAT_LINE_LENGTH) \
--skip-glob=$(FORMAT_EXCLUDE_GLOB)

.PHONY: lint
lint:
ifneq ($(MIG_ENV),'local')
@echo "unavailable outside local development environment"
@exit 1
endif
@make lint-python

.PHONY: lint-python
lint-python:
@$(LOCAL_PYTHON_BIN) -m black $(FORMAT_ENFORCE_DIRS) \
--check \
--line-length=$(FORMAT_LINE_LENGTH) \
--exclude $(FORMAT_EXCLUDE_REGEX)
@$(LOCAL_PYTHON_BIN) -m isort $(FORMAT_ENFORCE_DIRS) \
--check-only \
--profile=black \
--line-length=$(FORMAT_LINE_LENGTH) \
--skip-glob=$(FORMAT_EXCLUDE_GLOB)

.PHONY: clean
clean:
Expand Down
2 changes: 2 additions & 0 deletions local-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# This list is mainly used to specify addons needed for the unit tests.
# We only need autopep8 on py 3 as it's used in 'make fmt' (with py3)
autopep8;python_version >= "3"
black
isort
# We need paramiko for the ssh unit tests
# NOTE: paramiko-3.0.0 dropped python2 and python3.6 support
paramiko;python_version >= "3.7"
Expand Down
Loading
Loading