Skip to content

Commit

Permalink
GitHub workflow: don't use the Poetry venv for tox
Browse files Browse the repository at this point in the history
- always install tox & co using pip3.9
- additionally install the Python version to test against (if not 3.9)
- this setup allows testing against Python 3.10
- map python-version to a TOXENV manually (obsoletes tox-gh-actions)
- ignore failures of tests running against PyPy for now
  (python-poetry/poetry#3545)
  • Loading branch information
brechtm committed Jan 28, 2021
1 parent 980e174 commit b4aa043
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 79 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/experiment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Experiment

on: [push]

env:
poetry_version: '1.1.4'
jobs:
unit-tests:
name: ${{ matrix.os }} / ${{ matrix.python-version }} unit tests
strategy:
fail-fast: false
matrix:
os: [Ubuntu, macOS, Windows]
python-version: [3.6, 3.10.0-alpha - 3.10, pypy-3.7]
runs-on: ${{ matrix.os }}-latest
steps:
- name: Install Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- uses: actions/checkout@v2
with:
submodules: true
- name: Install tox & co
run: |
pip3.9 install --requirement .github/workflows/requirements.txt
- name: Install Python ${{ matrix.python-version }}
if: matrix.python-version != '3.9'
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Set TOXENV matching Python ${{ matrix.python-version }}
uses: jannekem/run-python-script-action@v1
with:
script: |
import os
mapping = {'3.6': 'py36',
'3.7': 'py37',
'3.8': 'py38',
'3.9': 'py39',
'3.10.0-alpha - 3.10': 'py310',
'pypy-3.6': 'pypy3',
'pypy-3.7': 'pypy3'}
toxenv = mapping['${{ matrix.python-version }}']
with open(os.getenv('GITHUB_ENV'), 'a') as env:
print(f'TOXENV={toxenv}', file=env)
- name: Run tox
run: |
tox -v
40 changes: 40 additions & 0 deletions .github/workflows/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# main packages
tox==3.21.3
tox-poetry-installer==0.6.2
poetry==1.1.4

# dependencies
appdirs==1.4.4
CacheControl==0.12.6
cachy==0.3.0
certifi==2020.12.5
chardet==4.0.0
cleo==0.8.1
clikit==0.6.2
crashtest==0.3.1
distlib==0.3.1
filelock==3.0.12
html5lib==1.1
idna==2.10
keyring==21.8.0
lockfile==0.12.2
msgpack==0.6.2 # https://github.com/python-poetry/poetry/issues/3607
packaging==20.8
pastel==0.2.1
pexpect==4.8.0
pkginfo==1.7.0
pluggy==0.13.1
poetry-core==1.0.0
ptyprocess==0.7.0
py==1.10.0
pylev==1.3.0
pyparsing==2.4.7
requests==2.25.1
requests-toolbelt==0.9.1
shellingham==1.3.2
six==1.15.0
toml==0.10.2
tomlkit==0.7.0
urllib3==1.26.3
virtualenv==20.4.0
webencodings==0.5.1
130 changes: 61 additions & 69 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
workflow_dispatch:

env:
poetry_version: '1.1.4'
current_python: '3.9'
jobs:
check:
name: ${{ matrix.os }} / ${{ matrix.python-version }} ${{ matrix.env.TOXENV }}
Expand All @@ -29,32 +29,14 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set up Python
- name: Install Python ${{ env.current_python }}
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: ${{ env.current_python }}
- name: Get full Python version
id: full-python-version
run: python -c "import sys; print('::set-output name=version::' + '-'.join(str(v) for v in sys.version_info))"

- name: Install Poetry
uses: Gr1N/setup-poetry@v4
with:
poetry-version: ${{ env.poetry_version }}
- name: Get Poetry cache-dir
id: cache-dirs-poetry
run: |
echo "::set-output name=dir::$(poetry config cache-dir)"
- name: Cache Poetry cache-dir
uses: actions/cache@v2
with:
path: ${{ steps.cache-dirs-poetry.outputs.dir }}
key: ${{ env.TOXENV }}-${{ runner.os }}-${{ matrix.python-version }}-${{ steps.full-python-version.outputs.version }}-poetry-${{ hashFiles('**/poetry.lock') }}

- name: Install development dependencies
run: |
poetry install -vv --no-root
- name: Cache docs references cache
if: env.TOXENV == 'build-docs'
uses: actions/cache@v2
Expand All @@ -65,8 +47,7 @@ jobs:
${{ env.TOXENV }}-references-
- name: Run tox
run: |
poetry run tox -v
run: tox -v

- name: Determine directory to publish docs to
id: docs-publish-dir
Expand Down Expand Up @@ -98,7 +79,7 @@ jobs:
fail-fast: false
matrix:
os: [Ubuntu, MacOS, Windows]
python-version: [3.6, 3.7, 3.8, 3.9, pypy-3.6, pypy-3.7]
python-version: [3.6, 3.7, 3.8, 3.9, 3.10.0-alpha - 3.10, pypy-3.6, pypy-3.7]
env:
- DIST: sdist
WITH_COVERAGE: 1
Expand All @@ -108,41 +89,52 @@ jobs:
env: ${{ matrix.env}}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
- name: Install Python ${{ env.current_python }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.current_python }}
- name: Install tox & co
run: |
pip${{ env.current_python }} install --requirement .github/workflows/requirements.txt
- name: Install Python ${{ matrix.python-version }}
if: matrix.python-version != env.current_python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Set TOXENV matching Python ${{ matrix.python-version }}
uses: jannekem/run-python-script-action@v1
with:
script: |
import os
mapping = {'3.6': 'py36',
'3.7': 'py37',
'3.8': 'py38',
'3.9': 'py39',
'3.10.0-alpha - 3.10': 'py310',
'pypy-3.6': 'pypy3',
'pypy-3.7': 'pypy3'}
toxenv = mapping['${{ matrix.python-version }}']
with open(os.getenv('GITHUB_ENV'), 'a') as env:
print(f'TOXENV={toxenv}', file=env)
- name: Get full Python version
id: full-python-version
run: python -c "import sys; print('::set-output name=version::' + '-'.join(str(v) for v in sys.version_info))"

- name: Install Poetry
uses: Gr1N/setup-poetry@v4
with:
poetry-version: ${{ env.poetry_version }}
- name: Get Poetry cache dir
id: cache-dirs-poetry
run: |
echo "::set-output name=dir::$(poetry config cache-dir)"
- name: Cache Poetry cache-dir
uses: actions/cache@v2
with:
path: ${{ steps.cache-dirs-poetry.outputs.dir }}
key: test-${{ runner.os }}-${{ matrix.python-version }}-${{ steps.full-python-version.outputs.version }}-poetry-${{ hashFiles('**/poetry.lock') }}

- name: Install development dependencies
run: |
poetry install -vv --no-root
- name: Create wheel
if: env.DIST == 'wheel'
run: |
poetry build -f wheel
python -c "import os; from pathlib import Path; open(os.getenv('GITHUB_ENV'), 'a').write('INSTALLPKG=--installpkg ' + str(next(Path('dist').glob('*.whl'))))"
run: poetry build --format wheel
- name: Find path to wheel
uses: jannekem/run-python-script-action@v1
with:
script: |
import os
from pathlib import Path
wheel_path = str(next(Path('dist').glob('*.whl'))
with open(os.getenv('GITHUB_ENV'), 'a') as env:
print(f'INSTALLPKG=--installpkg {wheel_path}')
- name: Run tox
continue-on-error: ${{ startsWith(matrix.python-version, 'pypy') }}
run: |
poetry run tox -v ${{ env.INSTALLPKG }} -- -s
continue-on-error: ${{ startsWith(runner.os, 'Windows') && startsWith(matrix.python-version, 'pypy') }}
run: tox -v ${{ env.INSTALLPKG }} -- -s

- name: Upload coverage statistics to codecov.io
if: env.WITH_COVERAGE == 1
Expand Down Expand Up @@ -174,28 +166,22 @@ jobs:
IMAGEMAGICK_VERSION: 7.0.10.29
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
- name: Install Python ${{ env.current_python }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.current_python }}
- name: Install tox & co
run: |
pip${{ env.current_python }} install --requirement .github/workflows/requirements.txt
- name: Install Python ${{ matrix.python-version }}
if: matrix.python-version != env.current_python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Get full Python version
id: full-python-version
run: python -c "import sys; print('::set-output name=version::' + '-'.join(str(v) for v in sys.version_info))"

- name: Install Poetry
uses: Gr1N/setup-poetry@v4
with:
poetry-version: ${{ env.poetry_version }}
- name: Get Poetry cache dir
id: cache-dirs-poetry
run: |
echo "::set-output name=dir::$(poetry config cache-dir)"
- name: Cache Poetry cache-dir
uses: actions/cache@v2
with:
path: ${{ steps.cache-dirs-poetry.outputs.dir }}
key: ${{ env.TOXENV }}-${{ runner.os }}-${{ matrix.python-version }}-${{ steps.full-python-version.outputs.version }}-poetry-${{ hashFiles('**/poetry.lock') }}

- name: Get Homebrew cache dir (macOS)
id: cache-dirs-macos
if: startsWith(runner.os, 'macOS')
Expand Down Expand Up @@ -253,13 +239,19 @@ jobs:
- name: Create wheel
if: env.DIST == 'wheel'
run: |
poetry build -f wheel
python -c "import os; from pathlib import Path; open(os.getenv('GITHUB_ENV'), 'a').write('INSTALLPKG=--installpkg ' + str(next(Path('dist').glob('*.whl'))))"
run: poetry build --format wheel
- name: Find path to wheel
uses: jannekem/run-python-script-action@v1
with:
script: |
import os
from pathlib import Path
wheel_path = str(next(Path('dist').glob('*.whl'))
with open(os.getenv('GITHUB_ENV'), 'a') as env:
print(f'INSTALLPKG=--installpkg {wheel_path}')
- name: Run tox
continue-on-error: ${{ startsWith(matrix.python-version, 'pypy') }}
run: |
poetry run tox -v ${{ env.INSTALLPKG }} -- -s
run: run tox -v ${{ env.INSTALLPKG }} -- -s

- name: Upload coverage statistics to codecov.io
if: env.WITH_COVERAGE == 1
Expand Down
10 changes: 0 additions & 10 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@ isolated_build = True
[tox:.package]
basepython = python3

[gh-actions]
python =
3.6: py36
3.7: py37
3.8: py38
3.9: py39
3.10: py310
pypy-3.6: pypy36
pypy-3.7: pypy37

[base]
locked_deps =
pytest
Expand Down

0 comments on commit b4aa043

Please sign in to comment.