Skip to content

Commit

Permalink
Add Python 3.10 to GitHub CI (#199)
Browse files Browse the repository at this point in the history
* Add Python 3.10 to GitHub CI

* Apply suggestions from code review

* Update .github/workflows/python-package.yml
  • Loading branch information
JeffLIrion committed Jan 13, 2022
1 parent 2dd0c05 commit bf4d348
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['2.7', '3.5', '3.6', '3.7', '3.8', '3.9']
python-version: ['2.7', '3.5', '3.6', '3.7', '3.8', '3.9', '3.10']

steps:
- uses: actions/checkout@v2
Expand All @@ -29,15 +29,15 @@ jobs:
python -m pip install flake8 pylint coveralls cryptography libusb1>=1.0.16 pycryptodome
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install .
if python --version 2>&1 | grep -q "Python 3.7" || python --version 2>&1 | grep -q "Python 3.8" || python --version 2>&1 | grep -q "Python 3.9"; then pip install aiofiles; fi
if python --version 2>&1 | grep -q "Python 3.7" || python --version 2>&1 | grep -q "Python 3.8" || python --version 2>&1 | grep -q "Python 3.9" || python --version 2>&1 | grep -q "Python 3.10"; then pip install aiofiles; fi
- name: Lint with pylint and flake8
run: |
if python --version 2>&1 | grep -q "Python 2" || python --version 2>&1 | grep -q "Python 3.5" || python --version 2>&1 | grep -q "Python 3.6"; then flake8 adb_shell/ --exclude="adb_shell/adb_device_async.py,adb_shell/transport/base_transport_async.py,adb_shell/transport/tcp_transport_async.py" && pylint --ignore="adb_device_async.py,base_transport_async.py,tcp_transport_async.py" adb_shell/; fi
if python --version 2>&1 | grep -q "Python 3.7" || python --version 2>&1 | grep -q "Python 3.8" || python --version 2>&1 | grep -q "Python 3.9"; then flake8 adb_shell/ && pylint adb_shell/; fi
if python --version 2>&1 | grep -q "Python 3.7" || python --version 2>&1 | grep -q "Python 3.8" || python --version 2>&1 | grep -q "Python 3.9" || python --version 2>&1 | grep -q "Python 3.10"; then flake8 adb_shell/ && pylint adb_shell/; fi
- name: Test with unittest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_SERVICE_NAME: github
run: |
if python --version 2>&1 | grep -q "Python 2" || python --version 2>&1 | grep -q "Python 3.5" || python --version 2>&1 | grep -q "Python 3.6" ; then for synctest in $(cd tests && ls test*.py | grep -v async); do python -m unittest discover -s tests/ -t . -p "$synctest" || exit 1; done; fi
if python --version 2>&1 | grep -q "Python 3.7" || python --version 2>&1 | grep -q "Python 3.8" || python --version 2>&1 | grep -q "Python 3.9"; then coverage run --source adb_shell -m unittest discover -s tests/ -t . && coverage report -m && coveralls; fi
if python --version 2>&1 | grep -q "Python 3.7" || python --version 2>&1 | grep -q "Python 3.8" || python --version 2>&1 | grep -q "Python 3.9" || python --version 2>&1 | grep -q "Python 3.10"; then coverage run --source adb_shell -m unittest discover -s tests/ -t . && coverage report -m && coveralls; fi
6 changes: 5 additions & 1 deletion tests/async_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@


def _await(coro):
"""Create a new event loop, run the coroutine, then close the event loop."""
loop = asyncio.new_event_loop()

with warnings.catch_warnings(record=True) as warns:
ret = asyncio.get_event_loop().run_until_complete(coro)
ret = loop.run_until_complete(coro)
loop.close()

if warns:
raise RuntimeError
Expand Down

0 comments on commit bf4d348

Please sign in to comment.