-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
126 lines (113 loc) · 4.64 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
115
116
117
118
119
120
121
122
123
124
125
126
.DEFAULT_GOAL := help
.PHONY: help
help: ## Miscellaneous: Returns this Makefile's commands and their descriptions in a formatted table
@ci/scripts/makefile_help.sh $(MAKEFILE_LIST) 1
.PHONY: pkg-refresh ## purges all packages, then reinstalls only those that are imported
pkg-refresh:
@pipenv uninstall --all && pipenv install -c .
.PHONY: gh-act-install
gh-act-install: ## Linting: Install 'gh' and the 'nektos/act' extension
-@echo
-@echo '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='
-@echo $(shell echo '$@' | tr '[:lower:]' '[:upper:]')
-@echo '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='
-@echo
-@if command -v -- gh >/dev/null 2>&1; then \
echo "$(shell gh --version | head -n1) installed"; \
if gh act -h >/dev/null 2>&1; then \
echo "$(shell gh act --version) installed"; \
else \
echo "installing 'act'..." && \
gh extension install nektos/gh-act; \
fi; \
else \
echo "error: install 'gh', then re-run 'make $@'"; \
echo "https://github.com/cli/cli/blob/trunk/docs/install_linux.md#debian-ubuntu-linux-raspberry-pi-os-apt"; \
fi
.PHONY: lint
lint: gh-act-install ## Linting: Run MegaLinter with nektos/act
-@echo
-@echo '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='
-@echo $(shell echo '$@' | tr '[:lower:]' '[:upper:]')
-@echo '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='
-@echo
-gh act --artifact-server-path /tmp/artifacts -W .github/workflows/pre-commit.yml
.PHONY: lint-cleanup
lint-cleanup: ## Linting: Clean up any leftover docker continers from linting
-@echo
-@echo '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='
-@echo $(shell echo '$@' | tr '[:lower:]' '[:upper:]')
-@echo '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='
-@echo
-for container in $$(docker container ls -a --format='{{.Names}}' | grep -E '^act-'); do \
docker container stop --signal 9 "$${container}"; \
docker container rm "$${container}"; \
done && \
for volume in $$(docker volume ls --format='{{.Name}}' | grep -E '^act-'); do \
docker volume rm "$${volume}"; \
done
.PHONY: pipenv-install
pipenv-install: ## Linting: Install pipenv
-@echo
-@echo '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='
-@echo $(shell echo '$@' | tr '[:lower:]' '[:upper:]')
-@echo '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='
-@echo
-@command -v -- pipenv >/dev/null 2>&1 || pip3 install pipenv
-@if command -v -- pipenv >/dev/null 2>&1; then \
echo "$(shell pipenv --version) installed"; \
else \
echo "error: install 'pipenv', then re-run 'make $@'"; \
fi
.PHONY: pre-commit-install
pre-commit-install: pipenv-install ## Linting: Install pre-commit
-@echo
-@echo '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='
-@echo $(shell echo '$@' | tr '[:lower:]' '[:upper:]')
-@echo '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='
-@echo
-@if pipenv run pre-commit -V >/dev/null 2>&1; then \
echo "$(shell pipenv run pre-commit -V) installed"; \
else \
echo "installing pre-commit..." && \
pipenv install pre-commit; \
echo "$(shell pipenv run pre-commit -V) installed"; \
fi;
.PHONY: pytest-install
pytest-install: pipenv-install ## Linting: Install pytest
-@echo
-@echo '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='
-@echo $(shell echo '$@' | tr '[:lower:]' '[:upper:]')
-@echo '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='
-@echo
-@if pipenv run pytest -V >/dev/null 2>&1; then \
echo "$$(pipenv run pytest -V) installed"; \
else \
echo "installing pytest..." && \
pipenv install --dev pytest; \
echo "$$(pipenv run pytest -V) installed"; \
echo "installing pytest-mock..." && \
pipenv install --dev pytest-mock; \
fi;
.PHONY: pre-commit-install-hooks
pre-commit-install-hooks: pre-commit-install ## Linting: Install pre-commit hooks
-@echo
-@echo '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='
-@echo $(shell echo '$@' | tr '[:lower:]' '[:upper:]')
-@echo '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='
-@echo
-pipenv run pre-commit install
.PHONY: pre-commit
pre-commit: pre-commit-install ## Linting: Lints all files changed between the default branch and the current branch
-@echo
-@echo '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='
-@echo $(shell echo '$@' | tr '[:lower:]' '[:upper:]')
-@echo '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='
-@echo
-pipenv run pre-commit run --verbose --show-diff-on-failure --color=always --all-files
.PHONY: act # runs nektos/act
act:
gh act --verbose
.PHONY: tests
tests: pytest-install ## Tests: runs pytest tests
-@pipenv run python -m pytest # required to do it this way (https://stackoverflow.com/questions/10253826/path-issue-with-pytest-importerror-no-module-named/34140498#34140498)