Skip to content

Improve GitHub actions #35

Improve GitHub actions

Improve GitHub actions #35

Workflow file for this run

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:
os: [ubuntu-latest]
python: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Set tox_env
run: |
pyv=$(echo ${{matrix.python}} | sed 's/.//')
tox_env=py${pyv}-coverage
echo "tox env name: ${tox_env}"
echo "tox_env=${tox_env}">> $GITHUB_ENV
- 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@v3
with:
path: ${{ github.workspace }}/.tox/${{ env.tox_env }}
key: "tox|${{ matrix.os }}|${{ env.tox_env }}|${{ env.PY_CACHE_KEY }}|${{ hashFiles('tox.ini', 'setup.*') }}"
- name: Install/update tools
run: |
pip install -U pip setuptools virtualenv tox
- name: Setup tox environment
id: setup-tox
run: tox --notest -v --durations -e ${{ env.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: tox -v --durations -e ${{ env.tox_env }}
- name: Report coverage
if: always() && (steps.setup-tox.outcome == 'success' && contains(env.tox_env, '-coverage'))
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
flags: ${{ runner.os }}
name: ${{ env.tox_env }}
fail_ci_if_error: true