forked from facebookincubator/submitit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
105 lines (83 loc) · 3.11 KB
/
Copy pathMakefile
File metadata and controls
105 lines (83 loc) · 3.11 KB
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
# Run the linter and tests suite of this repo.
# `make use_venv=0` will use the default `python` otherwise uses the one in `.venv/`
use_venv=1
ifeq ($(use_venv),0)
BIN?=
else
BIN=venv/bin/
endif
CODE=submitit
CODE_AND_SETUP=$(CODE) setup.py docs/ integration/
which:
which $(BIN)python
$(BIN)python --version
test:
$(BIN)pytest $(CODE)
test_coverage:
$(BIN)pytest \
--cov=submitit --cov-report=html --cov-report=term \
--durations=10 \
--junitxml=test_results/pytest/results.xml \
$(CODE)
format:
$(BIN)python -m pre_commit
$(BIN)isort $(CODE_AND_SETUP)
$(BIN)black $(CODE_AND_SETUP)
check_format:
# also formats setup.py
$(BIN)isort --check --diff $(CODE_AND_SETUP)
$(BIN)black --check --diff $(CODE_AND_SETUP)
mypy:
$(BIN)mypy --version
$(BIN)mypy --junit-xml=test_results/pytest/results.xml $(CODE)
pylint:
$(BIN)pylint --version
$(BIN)pylint $(CODE)
lint: mypy pylint
venv: venv/requirements.txt
venv/requirements.txt: requirements/main.txt requirements/dev.txt
python3 -m venv venv
venv/bin/pip install --progress-bar off --upgrade pip
venv/bin/pip install --progress-bar off -U -e .[dev]
cat $^ > venv/requirements.txt
installable: installable_local installable_pypi
installable_local: venv
(. ./venv/bin/activate ; cd /tmp ; python -c "import submitit")
BUILD=dev$(CIRCLE_BUILD_NUM)
USER_VENV=test_results/user_venv/
CURRENT_VERSION=`grep -e '__version__' ./submitit/__init__.py | sed 's/__version__ = //' | sed 's/"//g'`
TEST_PYPI=--index-url 'https://test.pypi.org/simple/' --no-cache-dir --no-deps --progress-bar off
installable_pypi:
[ ! -d dist ] || rm -r dist
# Append .$(BUILD) to the current version
sed -i -e 's/__version__ = "[0-9].[0-9].[0-9]/&.$(BUILD)/' ./submitit/__init__.py
grep -e '__version__' ./submitit/__init__.py | sed 's/__version__ = //' | sed 's/"//g'
$(BIN)python setup.py sdist bdist_wheel
git checkout HEAD -- ./submitit/__init__.py
$(BIN)pip install --progress-bar off twine
TWINE_PASSWORD=$$TWINE_PASSWORD_TESTPYPI $(BIN)python -m twine upload --repository testpypi dist/*
[ ! -d $(USER_VENV) ] || rm -r $(USER_VENV)
python3 -m venv $(USER_VENV)
$(USER_VENV)bin/pip install --progress-bar off --upgrade pip
# Wait for the package to be visible.
sleep 10
$(USER_VENV)bin/pip install $(TEST_PYPI) submitit==$(CURRENT_VERSION).$(BUILD) || echo "will try again"
# Apparently we need to try twice before finding it in the index.
sleep 10
$(USER_VENV)bin/pip install $(TEST_PYPI) submitit==$(CURRENT_VERSION).$(BUILD)
clean:
rm -r venv
pre_commit: format lint
register_pre_commit: venv
(grep -e "^make pre_commit$$" .git/hooks/pre-commit) || (echo "make pre_commit" >> .git/hooks/pre-commit)
chmod +x .git/hooks/pre-commit
integration: venv check_format lint installable test_coverage
# Run the same tests than on CI
# use `make -k integration` to run all checks even if previous fails.
release: integration
grep -e '__version__' ./submitit/__init__.py | sed 's/__version__ = //' | sed 's/"//g'
[ ! -d dist ] || rm -r dist
$(BIN)python setup.py sdist bdist_wheel
$(BIN)pip install --progress-bar off twine
# Credentials are read from ~/.pypirc
$(BIN)python -m twine upload dist/*