Test suite #283
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
name: Test suite | |
on: | |
create: # is used for publishing to PyPI and TestPyPI | |
push: # only publishes pushes to the main branch to TestPyPI | |
branches: # any branch but not tag | |
- >- | |
** | |
tags-ignore: | |
- >- | |
** | |
pull_request: | |
schedule: | |
- cron: 1 0 * * * # Run daily at 0:01 UTC | |
jobs: | |
lint: | |
uses: ./.github/workflows/reusable-linters.yml | |
tests: | |
if: >- # https://twitter.com/webKnjaZ/status/1308803017001652225 | |
github.event_name != 'create' || | |
github.event.ref_type == 'tag' | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: true | |
matrix: | |
python-version: | |
- 3.9 | |
- 2.7 | |
- pypy-3.7 | |
- 3.8 | |
- 3.7 | |
- 3.6 | |
- 3.5 | |
- pypy-2.7 | |
- pypy-3.6 | |
- 3.10.0-alpha - 3.10.0 | |
os: | |
- ubuntu-20.04 | |
- ubuntu-18.04 | |
- ubuntu-16.04 | |
- macOS-11.0 | |
- macOS-latest | |
- windows-latest | |
- windows-2016 | |
exclude: | |
# NOTE: macOS PyPy jobs are excluded because installing cryptography | |
# NOTE: needs openssl headers that aren't present at the moment. | |
# TODO: Remove the exclusions once this is addressed. | |
- os: macOS-11.0 | |
python-version: pypy-2.7 | |
- os: macOS-latest | |
python-version: pypy-2.7 | |
- os: macOS-11.0 | |
python-version: pypy-3.6 | |
- os: macOS-latest | |
python-version: pypy-3.6 | |
- os: macOS-11.0 | |
python-version: pypy-3.7 | |
- os: macOS-latest | |
python-version: pypy-3.7 | |
continue-on-error: >- | |
${{ | |
contains(matrix.python-version, 'alpha') | |
&& true | |
|| false | |
}} | |
timeout-minutes: 7 # NOTE: default is 360 (6h) | |
env: | |
PYTEST_ADDOPTS: >- | |
${{ | |
( | |
matrix.python-version == 'pypy-2.7' && | |
startsWith(matrix.os, 'ubuntu-') | |
) && | |
'-p no:warnings' || '' | |
}} | |
PY_COLORS: 1 | |
TOXENV: python | |
TOX_PARALLEL_NO_SPINNER: 1 | |
steps: | |
- name: >- | |
Log platform.platform() | |
run: >- | |
python -m platform | |
- name: >- | |
Log platform.version() | |
run: | | |
import platform | |
print(platform.version()) | |
shell: python | |
- name: >- | |
Log platform.uname() | |
run: | | |
import platform | |
print(platform.uname()) | |
shell: python | |
- name: >- | |
Log platform.release() | |
run: | | |
import platform | |
print(platform.release()) | |
shell: python | |
- name: Windows system info | |
run: systeminfo | |
if: >- | |
startsWith(matrix.os, 'windows-') | |
- uses: actions/checkout@v2 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Pip cache | |
uses: actions/cache@v2 | |
with: | |
path: >- | |
${{ | |
runner.os == 'Linux' && | |
'~/.cache/pip' | |
|| '' | |
}}${{ | |
runner.os == 'macOS' && | |
'~/Library/Caches/pip' | |
|| '' | |
}}${{ | |
runner.os == 'Windows' && | |
'~\AppData\Local\pip\Cache' | |
|| '' | |
}} | |
key: >- | |
${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}-${{ | |
hashFiles('setup.py') }}-${{ hashFiles('tox.ini') }}-${{ | |
hashFiles('pyproject.toml') }}-${{ | |
hashFiles('.pre-commit-config.yaml') }}-${{ | |
hashFiles('pytest.ini') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
${{ runner.os }}- | |
- name: Install tox | |
run: >- | |
python -m | |
pip install | |
--upgrade | |
tox | |
# macOS-latest + CPython completes in 4s-1m26s | |
# macOS-11.0 + CPython completes in 3s-18s | |
# ubuntu-16.04 + CPython completes in 2s-8s | |
# ubuntu-16.04 + PyPy completes in 5s-16s | |
# ubuntu-18.04 + CPython completes in 3s-6s | |
# ubuntu-18.04 + PyPy completes in 4s-14s | |
# ubuntu-20.04 + CPython completes in 3s-8s | |
# ubuntu-20.04 + PyPy completes in 10s-15s | |
# windows-latest + CPython completes in 5s-25s | |
# windows-latest + PyPy completes in 22s-50s | |
# windows-2016 + CPython completes in 7s-24s | |
# windows-2016 + PyPy completes in 22s-41s | |
timeout-minutes: 2 | |
- name: 'Initialize tox envs: ${{ matrix.env.TOXENV }}' | |
run: >- | |
python -m | |
tox | |
--parallel auto | |
--parallel-live | |
-vv | |
--skip-missing-interpreters false | |
--notest | |
# macOS-latest + CPython completes in 11s-1m40s | |
# macOS-11.0 + CPython completes in 14s-18s | |
# ubuntu-16.04 + CPython completes in 9s-16s | |
# ubuntu-16.04 + PyPy completes in 14s-21s | |
# ubuntu-18.04 + CPython completes in 9s-15s | |
# ubuntu-18.04 + PyPy completes in 16s-24s | |
# ubuntu-20.04 + CPython completes in 10s-12s | |
# ubuntu-20.04 + PyPy completes in 16s-24s | |
# windows-latest + CPython completes in 17s-31s | |
# windows-latest + PyPy completes in 37s-44s | |
# windows-2016 + CPython completes in 18s-26s | |
# windows-2016 + PyPy completes in 37s-49s | |
timeout-minutes: 2 | |
- name: Test with tox | |
run: >- | |
python -m | |
tox | |
--parallel auto | |
--parallel-live | |
-vv | |
# macOS-latest + CPython completes in 9-2m12s | |
# macOS-11.0 + CPython completes in 8s-1m13s | |
# ubuntu-16.04 + CPython completes in 8s-13s | |
# ubuntu-16.04 + PyPy completes in 13s-16s | |
# ubuntu-18.04 + CPython completes in 8s-13s | |
# ubuntu-18.04 + PyPy completes in 13s-15s | |
# ubuntu-20.04 + CPython completes in 8s-14s | |
# ubuntu-20.04 + PyPy completes in 13s-16s | |
# windows-latest + CPython completes in 7s-9s | |
# windows-latest + PyPy completes in 13s-24s | |
# windows-2016 + CPython completes in 7s-11s | |
# windows-2016 + PyPy completes in 13s-20s | |
timeout-minutes: 3 | |
- name: Dump test logs on failure | |
if: failure() | |
shell: bash | |
run: | | |
for log in magicbus/test/*.log | |
do | |
echo Dumping "'${log}'"... | |
cat "${log}" | |
done | |
check: # This job does nothing and is only used for the branch protection | |
if: always() | |
needs: | |
- lint | |
- tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Decide whether the needed jobs succeeded or failed | |
uses: re-actors/alls-green@release/v1 | |
with: | |
jobs: ${{ toJSON(needs) }} | |
publish: | |
name: Validate metadata and optionally publish 🐍📦 to PyPI | |
needs: | |
- check | |
runs-on: ${{ matrix.os }} | |
strategy: | |
# NOTE: Even though it's one job, it's easier to keep the params in one | |
# NOTE: place using a matrix: | |
matrix: | |
python-version: | |
- 3.9 | |
os: | |
- ubuntu-latest | |
env: | |
PY_COLORS: 1 | |
TOXENV: build-dists,metadata-validation | |
TOX_PARALLEL_NO_SPINNER: 1 | |
steps: | |
- uses: actions/checkout@master | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Pip cache | |
uses: actions/cache@v2 | |
with: | |
path: >- | |
${{ | |
runner.os == 'Linux' && | |
'~/.cache/pip' | |
|| '' | |
}}${{ | |
runner.os == 'macOS' && | |
'~/Library/Caches/pip' | |
|| '' | |
}}${{ | |
runner.os == 'Windows' && | |
'~\AppData\Local\pip\Cache' | |
|| '' | |
}} | |
key: >- | |
${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}-${{ | |
hashFiles('setup.py') }}-${{ hashFiles('tox.ini') }}-${{ | |
hashFiles('pyproject.toml') }}-${{ | |
hashFiles('.pre-commit-config.yaml') }}-${{ | |
hashFiles('pytest.ini') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
${{ runner.os }}- | |
- name: Install tox | |
run: >- | |
python -m | |
pip install | |
--upgrade | |
tox | |
- name: 'Initialize tox envs: ${{ matrix.env.TOXENV }}' | |
run: >- | |
python -m | |
tox | |
--parallel auto | |
--parallel-live | |
-vv | |
--skip-missing-interpreters false | |
--notest | |
- name: Build dists with tox | |
run: >- | |
python -m | |
tox | |
--parallel auto | |
--parallel-live | |
-vv | |
- name: Publish to pypi.org | |
if: >- # "create" workflows run separately from "push" & "pull_request" | |
github.event_name == 'create' && | |
github.event.ref_type == 'tag' | |
uses: pypa/gh-action-pypi-publish@release/v1 |