forked from port-labs/ocean
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
114 lines (96 loc) · 2.77 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
ACTIVATE := . .venv/bin/activate
define run_checks
exit_code=0; \
cd $1; \
poetry check || exit_code=$$?;\
mypy . --exclude '/\.venv/' || exit_code=$$?; \
ruff . || exit_code=$$?; \
black --check . || exit_code=$$?; \
yamllint . || exit_code=$$?; \
if [ $$exit_code -eq 1 ]; then \
echo "\033[0;31mOne or more checks failed with exit code $$exit_code\033[0m"; \
else \
echo "\033[0;32mAll checks executed successfully.\033[0m"; \
fi; \
exit $$exit_code
endef
define install_poetry
if ! command -v poetry &> /dev/null; then \
pip install --upgrade pip; \
pip install poetry; \
else \
echo "Poetry is already installed."; \
fi
endef
define install_precommit
command pre-commit install
endef
define deactivate_virtualenv
if [ -n "$$VIRTUAL_ENV" ]; then \
unset VIRTUAL_ENV; \
unset PYTHONHOME; \
unset -f pydoc >/dev/null 2>&1; \
OLD_PATH="$$PATH"; \
PATH=$$(echo -n "$$PATH" | awk -v RS=: -v ORS=: '/\/virtualenv\/bin$$/ {next} {print}'); \
export PATH; \
hash -r; \
echo "Deactivated the virtual environment."; \
fi
endef
.SILENT: install install/all test/all lint build run new test clean bump/integrations bump/single-integration
# Install dependencies
install:
$(call deactivate_virtualenv) && \
$(call install_poetry) && \
poetry install --with dev --all-extras && \
$(ACTIVATE) && \
$(call install_precommit)
test/all: test
pytest --import-mode=importlib -n auto ./port_ocean/tests ./integrations/*/tests
install/all: install
exit_code=0; \
for dir in $(wildcard $(CURDIR)/integrations/*); do \
count=$$(find $$dir -type f -name '*.py' -not -path "*/venv/*" | wc -l); \
if [ $$count -ne 0 ]; then \
echo "Installing $$dir"; \
cd $$dir; \
$(MAKE) install || exit_code=$$?; \
cd ../..; \
fi; \
done; \
if [ $$exit_code -ne 0 ]; then \
exit 1; \
fi
# Linting
lint:
$(ACTIVATE) && \
$(call run_checks,.)
# Development commands
build:
$(ACTIVATE) && poetry build
run: lint
$(ACTIVATE) && poetry run ocean sail ./integrations/example
new:
$(ACTIVATE) && poetry run ocean new ./integrations --public
test:
$(ACTIVATE) && pytest -vv -n auto --ignore-glob=./integrations/* ./port_ocean/tests
clean:
@find . -name '.venv' -type d -exec rm -rf {} \;
@find . -name '*.pyc' -exec rm -rf {} \;
@find . -name '__pycache__' -exec rm -rf {} \;
@find . -name 'Thumbs.db' -exec rm -rf {} \;
@find . -name '*~' -exec rm -rf {} \;
rm -rf .cache
rm -rf build
rm -rf dist
rm -rf *.egg-info
rm -rf htmlcov
rm -rf .tox/
rm -rf docs/_build
rm -rf dist/
# make bump/integrations VERSION=0.3.2
bump/integrations:
./scripts/bump-all.sh $(VERSION)
# make bump/single-integration INTEGRATION=aws
bump/single-integration:
./scripts/bump-single-integration.sh -i $(INTEGRATION)