blob: b035cb6a467ab21c4ccd78c05f67354d1731643a [file] [log] [blame]
name: check
on:
push:
pull_request:
schedule:
- cron: '0 8 * * *'
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: set PY
run: echo "::set-env name=PY::$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')"
- uses: actions/cache@v2
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- uses: pre-commit/action@v1.1.0
test:
name: test ${{ matrix.py }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os:
- Ubuntu
- Windows
- MacOs
py:
- 3.8
- 3.7
- 3.6
- 3.5
- pypy3
- 2.7
- pypy2
include:
- {os: MacOs, py: brew@py3}
- {os: MacOs, py: brew@py2}
- {os: Ubuntu, py: 3.9-dev}
steps:
- name: install OS dependencies
run: |
${{ runner.os == 'Linux' && 'sudo apt-get update -y && sudo apt-get install fish csh' || true}}
${{ runner.os == 'macOS' && 'brew update -vvv && brew install fish tcsh' || true}}
${{ runner.os == 'Windows' && ( matrix.py == '2.7' || matrix.py == 'pypy2' ) && 'choco install vcpython27 --yes -f' || true }}
shell: bash
- name: setup python for tox
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: install tox
run: python -m pip install tox
- uses: actions/checkout@v2
- name: use local virtualenv for tox
run: python -m pip install .
- name: setup python for test ${{ matrix.py }}
if: "!( startsWith(matrix.py,'brew@py') || endsWith(matrix.py, '-dev') )"
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.py }}
- name: setup DEV python for test ${{ matrix.py }}
uses: deadsnakes/action@v1.0.0
if: endsWith(matrix.py, '-dev')
with:
python-version: ${{ matrix.py }}
- name: setup brew python for test ${{ matrix.py }}
if: startsWith(matrix.py,'brew@py')
run: |
import os; import subprocess
version = "${{matrix.py}}"[-1]
subprocess.check_call(["brew", "install", f"python@{version}"])
print(f"::add-path::/usr/local/opt/python@{version}")
shell: python
- name: pick environment to run
run: |
import subprocess; import json
major, minor, impl = json.loads(subprocess.check_output(["python", "-c", "import json; import sys; import platform; print(json.dumps([sys.version_info[0], sys.version_info[1], platform.python_implementation()]));"], universal_newlines=True))
print('::set-env name=TOXENV::' + ("py" if impl == "CPython" else "pypy") + ("{}{}".format(major, minor) if impl == "CPython" else ("3" if major == 3 else "")))
shell: python
- name: setup test suite
run: tox -vv --notest
- name: run test suite
run: tox
env:
PYTEST_ADDOPTS: "-vv --durations=20"
CI_RUN: 'yes'
DIFF_AGAINST: HEAD
- name: rename coverage report file
run: |
import os; os.rename('.tox/coverage.{}.xml'.format(os.environ['TOXENV']), '.tox/coverage.xml')
shell: python
- uses: codecov/codecov-action@v1
with:
file: ./.tox/coverage.xml
flags: tests
name: ${{ matrix.py }} - ${{ matrix.os }}
check:
name: check ${{ matrix.tox_env }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os:
- Ubuntu
- Windows
tox_env:
- dev
- docs
- readme
- upgrade
- zipapp
exclude:
- {os: Windows, tox_env: readme}
- {os: Windows, tox_env: docs}
steps:
- uses: actions/checkout@v2
- name: setup Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: install tox
run: python -m pip install tox
- name: run check for ${{ matrix.tox_env }}
run: python -m tox -e ${{ matrix.tox_env }}
env:
UPGRADE_ADVISORY: 'yes'
publish:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: [check, test, lint]
runs-on: ubuntu-latest
steps:
- name: setup python to build package
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: install pep517
run: python -m pip install pep517
- uses: actions/checkout@v2
- name: build package
run: python -m pep517.build -s -b . -o dist
- name: publish to PyPi
uses: pypa/gh-action-pypi-publish@master
with:
skip_existing: true
user: __token__
password: ${{ secrets.pypi_password }}