Skip to content

Don't run pytest under coverage on pypy, cache hatch envs #197

Don't run pytest under coverage on pypy, cache hatch envs

Don't run pytest under coverage on pypy, cache hatch envs #197

Workflow file for this run

name: test
on:
pull_request:
branches: ["*"]
push:
branches: [main]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CACHE_EPOCH: 0
jobs:
format:
name: format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: "3.12"
cache: pip
cache-dependency-path: pyproject.toml
- name: install dev dependencies
run: python -m pip install --upgrade pip hatch
- name: run formatters
run: |
echo "~~~bash" > "${GITHUB_STEP_SUMMARY}"
hatch run format:code 2>&1 | tee --append "${GITHUB_STEP_SUMMARY}"
echo "~~~" >> "${GITHUB_STEP_SUMMARY}"
- name: print diff
run: |
echo "~~~diff" >> "${GITHUB_STEP_SUMMARY}"
git diff | tee --append "${GITHUB_STEP_SUMMARY}"
echo "~~~" >> "${GITHUB_STEP_SUMMARY}"
test:
name: ${{ matrix.os }} ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.9"]
include:
- os: ubuntu-latest
hatch-envs: /home/runner/.local/share/hatch/env
- os: macos-latest
hatch-envs: /Users/runner/Library/Application Support/hatch/env
- os: windows-latest
hatch-envs: C:\Users\runneradmin\AppData\Local\hatch\env
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml
- name: cache hatch envs
uses: actions/cache@v3
with:
path: |
${{ matrix.hatch-envs }}
key: |
${{ env.CACHE_EPOCH }}-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
- name: install dev dependencies
run: python -m pip install --upgrade pip hatch
- name: run tests (coverage)
if: ${{ !contains(matrix.python-version, 'pypy') }}
run: hatch run test:cov
- name: run tests (no coverage)
if: ${{ contains(matrix.python-version, 'pypy') }}
run: hatch run test:run