Skip to content

Commit 0abc021

Browse files
authored
feat: Added Makefile (appium#530)
* Created setup.cfg * Updated lib ver for pre-commit * Fix ci.sh to set failure even when one command failed * Fix pylint error * Add help to Makefile * Update README * Add check-all command
1 parent 2b187b1 commit 0abc021

File tree

9 files changed

+57
-39
lines changed

9 files changed

+57
-39
lines changed

.config-pep8

Lines changed: 0 additions & 2 deletions
This file was deleted.

.isort.cfg

Lines changed: 0 additions & 4 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
- repo: https://github.com/pre-commit/mirrors-autopep8
2-
rev: v1.4
2+
rev: v1.5.2
33
hooks:
44
- id: autopep8
5-
args: ["-a", "--global-config", ".config-pep8", "-i"]
5+
args: ["-a", "-i"]
66
- repo: https://github.com/pre-commit/mirrors-isort
7-
rev: v4.3.20
7+
rev: v4.3.21
88
hooks:
99
- id: isort
1010
args: ["-rc", "."]
1111
- repo: https://github.com/pre-commit/mirrors-mypy
12-
rev: 'v0.761'
12+
rev: 'v0.770'
1313
hooks:
1414
- id: mypy
1515
entry: mypy appium/ test/

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.PHONY: Commands for developers
2+
3+
.PHONY: check-all
4+
check-all: ## Run all lint checks and unittest
5+
@echo "[Notice] If you'd like to run commands with same env to CI, please run \`tox\`."
6+
@bash ci.sh
7+
8+
.PHONY: isort
9+
isort: ## Run isort
10+
python -m isort $(ARGS) -rc .
11+
12+
.PHONY: autopep8
13+
autopep8: ## Run autopep8
14+
python -m autopep8 $(ARGS) -a -r -i .
15+
16+
.PHONY: pylint
17+
pylint: ## Run pylint
18+
python -m pylint $(ARGS) --rcfile .pylintrc appium test
19+
20+
.PHONY: mypy
21+
mypy: ## Run mypy
22+
python -m mypy appium test
23+
24+
.PHONY: unittest
25+
unittest: ## Run unittest
26+
python -m pytest test/unit/
27+
28+
.PHONY: help
29+
help: ## Display this help screen
30+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ https://appium.github.io/python-client-sphinx/ is detailed documentation
135135

136136
- Code Style: [PEP-0008](https://www.python.org/dev/peps/pep-0008/)
137137
- Apply `autopep8`, `isort` and `mypy` as pre commit hook
138+
- Run `make` command for development. See `make help` output for details
138139
- Docstring style: [Google Style](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html)
139140
- `gitchangelog` generates `CHANGELOG.rst`
140141

appium/webdriver/extensions/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def events(self) -> Dict:
6060
session = self.session
6161
return session['events']
6262
except Exception as e:
63-
logger.warning('Could not find events information in the session. Error:', e)
63+
logger.warning('Could not find events information in the session. Error: %s', e)
6464
return {}
6565

6666
# pylint: disable=protected-access

ci.sh

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,27 @@
11
#!/bin/bash
22

3-
set -o pipefail
4-
53
EXIT_STATUS=0
6-
if ! python -m autopep8 --exit-code -a -r --global-config .config-pep8 -i . ; then
7-
echo "Please run command 'python -m autopep8 -a -r --global-config .config-pep8 -i .' on your local and commit the result"
4+
5+
if ! make autopep8 ARGS=--exit-code ; then
6+
echo "Please run command 'make autopep8' on your local and commit the result"
87
EXIT_STATUS=1
98
fi
109

11-
if ! python -m isort --check-only -rc . ; then
12-
echo "Please run command 'python -m isort -rc .' on your local and commit the result"
10+
if ! make isort ARGS=--check-only ; then
11+
echo "Please run command 'make isort' on your local and commit the result"
1312
EXIT_STATUS=1
1413
fi
1514

16-
(
17-
LINT_RESULT=$(python -m pylint --rcfile .pylintrc appium test --errors-only 2>&1 | tee /dev/tty)
18-
if [[ $? -ne 0 ]] ; then
19-
EXIT_STATUS=1
20-
fi
21-
22-
# FIXME: pylint x Python 3.7 cause this runtime error.
23-
# We must remove here when we drop Python 2 (and can update pylint) or
24-
# install newer pylint for Python 3.7 environment on CI
25-
if [[ $LINT_RESULT =~ "RuntimeError: generator raised StopIteration" ]] ; then
26-
EXIT_STATUS=0
27-
fi
28-
)
15+
if ! make pylint ARGS=--errors-only ; then
16+
echo "Please run command 'make pylint' on your local and fix errors"
17+
EXIT_STATUS=1
18+
fi
2919

30-
(
31-
python -m pytest test/unit/
32-
)
33-
if [[ $? -ne 0 ]] ; then
20+
if ! make unittest ; then
3421
EXIT_STATUS=1
3522
fi
3623

37-
(
38-
python -m mypy appium test
39-
)
40-
if [[ $? -ne 0 ]] ; then
24+
if ! make mypy ; then
4125
EXIT_STATUS=1
4226
fi
4327

docs/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
sphinx >= 3.0, <4.0
1+
sphinx >= 3.0, <4.0
2+
sphinx_rtd_theme < 1.0

mypy.ini renamed to setup.cfg

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
[pep8]
2+
max-line-length = 120
3+
4+
[isort]
5+
multi_line_output = 3
6+
known_third_party = dateutil,httpretty,pytest,selenium,setuptools,urllib3,mock,sauceclient
7+
known_first_party = test,appium
8+
19
[mypy]
210
check_untyped_defs = True
311
disallow_untyped_calls = True

0 commit comments

Comments
 (0)