forked from hiddify/HiddifyPanel-old
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
152 lines (133 loc) · 5.48 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
.ONESHELL:
ENV_PREFIX=$(shell python -c "if __import__('pathlib').Path('.venv/bin/pip').exists(): print('.venv/bin/')")
USING_POETRY=$(shell grep "tool.poetry" pyproject.toml && echo "yes")
.PHONY: help
help: ## Show the help.
@echo "Usage: make <target>"
@echo ""
@echo "Targets:"
@fgrep "##" Makefile | fgrep -v fgrep
.PHONY: prepare
prepare: ## Show the help.
cd scripts
./update_translations.sh
.PHONY: show
show: ## Show the current environment.
@echo "Current environment:"
@if [ "$(USING_POETRY)" ]; then poetry env info && exit; fi
@echo "Running using $(ENV_PREFIX)"
@$(ENV_PREFIX)python -V
@$(ENV_PREFIX)python -m site
.PHONY: install
install: ## Install the project in dev mode.
@if [ "$(USING_POETRY)" ]; then poetry install && exit; fi
@echo "Don't forget to run 'make virtualenv' if you got errors."
$(ENV_PREFIX)pip install -e cython .[test]
.PHONY: fmt
fmt: ## Format code using black & isort.
# $(ENV_PREFIX)isort hiddifypanel/
# $(ENV_PREFIX)black -l 79 hiddifypanel/
# $(ENV_PREFIX)black -l 79 tests/
@echo skip
.PHONY: lint
lint: ## Run pep8, black, mypy linters.
# $(ENV_PREFIX)flake8 hiddifypanel/
# $(ENV_PREFIX)black -l 79 --check hiddifypanel/
# $(ENV_PREFIX)black -l 79 --check tests/
# $(ENV_PREFIX)mypy --ignore-missing-imports hiddifypanel/
@echo skip
.PHONY: test
test: lint ## Run tests and generate coverage report.
# $(ENV_PREFIX)pytest -v --cov-config .coveragerc --cov=hiddifypanel -l --tb=short --maxfail=1 tests/
# $(ENV_PREFIX)coverage xml
# $(ENV_PREFIX)coverage html
@echo skip
.PHONY: watch
watch: ## Run tests on every change.
ls **/**.py | entr $(ENV_PREFIX)pytest -s -vvv -l --tb=long --maxfail=1 tests/
.PHONY: clean
clean: ## Clean unused files.
@find ./ -name '*.pyc' -exec rm -f {} \;
@find ./ -name '__pycache__' -exec rm -rf {} \;
@find ./ -name 'Thumbs.db' -exec rm -f {} \;
@find ./ -name '*~' -exec rm -f {} \;
@rm -rf .cache
@rm -rf .pytest_cache
@rm -rf .mypy_cache
@rm -rf build
@rm -rf dist
@rm -rf *.egg-info
@rm -rf htmlcov
@rm -rf .tox/
@rm -rf docs/_build
.PHONY: virtualenv
virtualenv: ## Create a virtual environment.
@if [ "$(USING_POETRY)" ]; then poetry install && exit; fi
@echo "creating virtualenv ..."
@rm -rf .venv
@python3 -m venv .venv
@./.venv/bin/pip install -U pip
@./.venv/bin/pip install -e .[test]
@echo
@echo "!!! Please run 'source .venv/bin/activate' to enable the environment !!!"
.PHONY: dev
dev: ## Create a new tag for release.
@echo "dev" > hiddifypanel/VERSION
@echo "__version__='dev'" > hiddifypanel/VERSION.py
@gitchangelog > HISTORY.md
@git add hiddifypanel/VERSION hiddifypanel/VERSION.py HISTORY.md
@git commit -m "release: switch to develop"
@git push -u origin HEAD
.PHONY: release
release:
ifeq ($(TAG),)
# @echo "previous tag was $$(git describe --tags $$(git rev-list --tags --max-count=1))"
# @echo "release last version $$(lastversion hiddifypanel)"
# @echo "beta last version $$(lastversion --pre hiddifypanel)"
@echo "WARNING: This operation will create s version tag and push to github"
@read -p "Version? (provide the next x.y.z semver) : " TAG
endif
@echo "$${TAG}" > hiddifypanel/VERSION
@echo "__version__='$${TAG}'" > hiddifypanel/VERSION.py
@echo "from datetime import datetime" >> hiddifypanel/VERSION.py
@echo "__release_date__= datetime.strptime('$$(date +%Y-%m-%d)','%Y-%m-%d')" >> hiddifypanel/VERSION.py
@git tag v$${TAG}
@gitchangelog > HISTORY.md
@git tag -d v$${TAG}
@git add hiddifypanel/VERSION hiddifypanel/VERSION.py HISTORY.md
@make prepare
@git add hiddifypanel/translations/* hiddifypanel/translations.i18n/*
@git commit -m "release: version $${TAG} 🚀"
@echo "creating git tag : $${TAG}"
@git tag v$${TAG}
@git push -u origin HEAD --tags
@echo "Github Actions will detect the new tag and release the new version."
.PHONY: docs
docs: ## Build the documentation.
@echo "building documentation ..."
@$(ENV_PREFIX)mkdocs build
URL="site/index.html"; xdg-open $$URL || sensible-browser $$URL || x-www-browser $$URL || gnome-open $$URL
.PHONY: switch-to-poetry
switch-to-poetry: ## Switch to poetry package manager.
@echo "Switching to poetry ..."
@if ! poetry --version > /dev/null; then echo 'poetry is required, install from https://python-poetry.org/'; exit 1; fi
@rm -rf .venv
@poetry init --no-interaction --name=a_flask_test --author=rochacbruno
@echo "" >> pyproject.toml
@echo "[tool.poetry.scripts]" >> pyproject.toml
@echo "hiddifypanel = 'hiddifypanel.__main__:main'" >> pyproject.toml
@cat requirements.txt | while read in; do poetry add --no-interaction "$${in}"; done
@cat requirements-base.txt | while read in; do poetry add --no-interaction "$${in}" --dev; done
@cat requirements-test.txt | while read in; do poetry add --no-interaction "$${in}" --dev; done
@poetry install --no-interaction
@mkdir -p .github/backup
@mv requirements* .github/backup
@mv setup.py .github/backup
@echo "You have switched to https://python-poetry.org/ package manager."
@echo "Please run 'poetry shell' or 'poetry run hiddifypanel'"
# This project has been generated from rochacbruno/flask-project-template
# __author__ = 'rochacbruno'
# __repo__ = https://github.com/rochacbruno/flask-project-template
# __sponsor__ = https://github.com/sponsors/rochacbruno/
stress_test:
echo "GET http://localhost:9000/x2hDG4gt32VDbuZsYY6iq/c9c0c597-f42c-44d8-96e1-81f91dbcf1d0/singbox/?asn=unknown" | vegeta attack -duration=5s | tee results.bin | vegeta report