-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert to GitHub Actions, fix Python 3.5.1 and add newer Pythons
- Loading branch information
1 parent
cbc5855
commit 7d3f51a
Showing
4 changed files
with
142 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
name: Test | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
name: Python ${{ matrix.python-version }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: | ||
- '2.7' | ||
- '3.5' | ||
- '3.6' | ||
- '3.7' | ||
- '3.8' | ||
- '3.9' | ||
- '3.10.0-alpha - 3.10' | ||
os: [ubuntu-latest] | ||
include: | ||
# is not on ubuntu-latest | ||
- python-version: '3.4' | ||
os: ubuntu-18.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Install dependencies | ||
id: install | ||
run: | | ||
set -x | ||
pip install -r requirements.txt | ||
# install mypy on Python 3.6+ | ||
if python -c \ | ||
'import sys; sys.exit(0 if sys.version_info >= (3, 6) else 1)'; then | ||
pip install -U mypy | ||
echo "::set-output name=mypy::true" | ||
fi | ||
- name: Run pytest | ||
run: | | ||
pytest | ||
- name: Run mypy | ||
if: ${{ steps.install.outputs.mypy }} | ||
run: | | ||
mypy pyannotate_* | ||
# This can be removed if Python 3.5.1 is supported by GitHub actions | ||
# setup-python or if Python 3.5.1 support is dropped. | ||
# | ||
# see: https://github.com/actions/setup-python/issues/187 | ||
docker: | ||
name: Docker Python | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
# does not have typing.Text | ||
- python-version: '3.5.1' | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
# The system Python 3.5 does not have lib2to3 tests so install a Python | ||
# version with it. | ||
- name: Set up Python 3.5 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.5 | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Test on Docker | ||
run: | | ||
set -x | ||
# Docker containers don't usually ship with tests and the tests | ||
# rely on lib2to3.tests | ||
IMAGE=python:${{ matrix.python-version }} | ||
HOST_LIB2TO3_TEST_DIR=$(python -c \ | ||
'import os, lib2to3.tests; print(os.path.dirname(lib2to3.tests.__file__))') | ||
DOCKER_LIB2TO3_TEST_DIR=$(docker run --rm "$IMAGE" python -c \ | ||
'import os, lib2to3; print(os.path.dirname(lib2to3.__file__))')/tests | ||
# and lib2to3.tests rely on test | ||
HOST_TEST_DIR=$(dirname $(dirname "$HOST_LIB2TO3_TEST_DIR"))/test | ||
DOCKER_TEST_DIR=$(dirname $(dirname "$DOCKER_LIB2TO3_TEST_DIR"))/test | ||
# remove any optimized files so they can be regenerated correctly if needed | ||
find "$HOST_TEST_DIR" "$HOST_LIB2TO3_TEST_DIR" -name '*.py[cod]' -delete | ||
# pip will not use the cache if it's owned by someone else | ||
sudo chown -R 0:0 "$HOME/.cache/pip" | ||
docker run \ | ||
--user 0:0 \ | ||
--volume "$HOST_TEST_DIR":"$DOCKER_TEST_DIR" \ | ||
--volume "$HOST_LIB2TO3_TEST_DIR":"$DOCKER_LIB2TO3_TEST_DIR" \ | ||
--volume "$HOME/.cache/pip:/root/.cache/pip" \ | ||
--volume "$PWD:$PWD" \ | ||
--workdir "$PWD" \ | ||
--rm "$IMAGE" bash -ex -c ' | ||
pip install -r requirements.txt | ||
pytest | ||
' | ||
# return the cache back to this user in case that affects the cache action | ||
sudo chown -R $(id -u):$(id -g) "$HOME/.cache/pip" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
mock; python_version < '3.3' | ||
mypy_extensions>=0.3.0 | ||
pytest>=3.3.0 | ||
pytest>=3.3.0; python_version > '3.5' | ||
# pytest >5.3.0 uses typing.Type from Python 3.5.2 | ||
pytest>=3.3.0,<=5.3.0; python_version <= '3.5' | ||
# importlib-metadata is needed for Python 3.5+, but pip does not seem to be | ||
# pinning it to a correct version for Python 3.5 (possibly because it's a | ||
# transitive dependency). | ||
# Python 3.5 support was dropped in importlib-metadata 3.0.0 | ||
importlib-metadata>=0.12,<3.0.0; python_version == '3.5' | ||
setuptools>=28.8.0 | ||
six>=1.11.0 | ||
typing>=3.6.2; python_version < '3.5' |