Skip to content

Commit

Permalink
ci: move to GitHub Actions (#41)
Browse files Browse the repository at this point in the history
This uses Travis still for Python 3.4 (with https://github.com/blueyed/pytest/tree/my-4.6-maintenance).
  • Loading branch information
blueyed authored May 30, 2021
1 parent 545a7d6 commit f1e5513
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 25 deletions.
112 changes: 112 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: CI

on:
push:
branches:
- "master"
pull_request:
workflow_dispatch:

env:
PIP_DISABLE_PIP_VERSION_CHECK: true
PYTEST_ADDOPTS: "-vv"
# Set TERM to some commonly used default
# (not provided/setup by GitHub Actions by default).
TERM: xterm-256color

jobs:
tests:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
include:
# Linux
- tox_env: "py39-coverage"
python: "3.9"
os: ubuntu-20.04
- tox_env: "py38-coverage"
python: "3.8"
os: ubuntu-20.04
- tox_env: "py37-coverage"
python: "3.7"
os: ubuntu-20.04
- tox_env: "py36-coverage"
python: "3.6"
os: ubuntu-20.04
- tox_env: "py35-coverage"
python: "3.5"
os: ubuntu-20.04

- tox_env: "py27-coverage"
python: "2.7"
os: ubuntu-20.04

- tox_env: "pypy3-coverage"
python: "pypy-3.7"
os: ubuntu-20.04
- tox_env: "pypy-coverage"
python: "pypy-2.7"
os: ubuntu-20.04

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}

# Caching.
- name: set PY_CACHE_KEY
run: echo "PY_CACHE_KEY=$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV
- name: Cache .tox
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/.tox/${{ matrix.tox_env }}
key: "tox|${{ matrix.os }}|${{ matrix.tox_env }}|${{ env.PY_CACHE_KEY }}|${{ hashFiles('tox.ini', 'setup.*') }}"

- name: (Initial) version information/pinning
run: |
set -x
python -m site
python -m pip --version
python -m pip list
if [[ "${{ matrix.python }}" == "3.4" ]]; then
# Install latest available pip.
# 7.1.2 (installed) is too old to not install too new packages,
# including pip itself. 19.2 dropped support for Python 3.4.
python -m pip install -U pip==19.1.1
fi
python -m pip install -U setuptools==42.0.2
python -m pip install -U virtualenv==20.4.3
- name: Install tox
run: python -m pip install git+https://github.com/blueyed/tox@master

- name: Version information
run: python -m pip list

- name: Setup tox environment
id: setup-tox
run: python -m tox --notest -v --durations -e ${{ matrix.tox_env }}

- name: Test
env:
COLUMNS: "90" # better alignment (working around https://github.com/blueyed/pytest/issues/491).
PY_COLORS: "1"
# UTF-8 mode for Windows (https://docs.python.org/3/using/windows.html#utf-8-mode).
PYTHONUTF8: "1"
TOX_TESTENV_PASSENV: "PYTHONUTF8"
run: python -m tox -v --durations -e ${{ matrix.tox_env }}

- name: Report coverage
if: always() && (steps.setup-tox.outcome == 'success' && contains(matrix.tox_env, '-coverage'))
uses: codecov/codecov-action@v1
with:
files: ./coverage.xml
flags: ${{ runner.os }}
name: ${{ matrix.tox_env }}
fail_ci_if_error: true
27 changes: 5 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,20 @@ language: python

env:
global:
- PYTEST_ADDOPTS="--cov --cov-report=xml"
- PYTEST_ADDOPTS="-vv"

jobs:
include:
- python: '2.7'
env: TOXENV=py27-coverage
- python: '3.4'
env: TOXENV=py34-coverage
- python: '3.5'
env: TOXENV=py35-coverage
- python: '3.6'
env: TOXENV=py36-coverage
- python: '3.7'
env: TOXENV=py37-coverage
- python: '3.8'
env: TOXENV=py38-coverage
- python: '3.9'
env: TOXENV=py39-coverage
- python: 'pypy'
env: TOXENV=pypy-coverage
- python: 'pypy3'
env: TOXENV=pypy3-coverage
# Fails currently badly.
# - python: '3.7'
# env: TOXENV=qa
env:
- TOXENV=py34-coverage
- PYTEST="pytest @ git+https://github.com/blueyed/[email protected]"

install:
- pip install tox

script:
- tox
- tox --force-dep="$PYTEST"

after_script:
- |
Expand Down
10 changes: 7 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ envlist = py{27,34,35,36,37,38,39,py,py3}, flake8
deps =
pytest
pexpect
coverage: pytest-cov
coverage: coverage
commands =
pytest {posargs}
{env:_PYREPL_TOX_RUN_CMD:pytest} {posargs}
coverage: coverage combine
coverage: coverage report -m
coverage: coverage xml
passenv =
PYTEST_ADDOPTS
TERM
setenv =
coverage: PYTEST_ADDOPTS=--cov {env:PYTEST_ADDOPTS:}
coverage: _PYREPL_TOX_RUN_CMD=coverage run -m pytest

[testenv:qa]
deps =
Expand Down

0 comments on commit f1e5513

Please sign in to comment.