-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
88 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
|
||
concurrency: | ||
group: tests-${{ github.head_ref || github.ref }} | ||
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
||
jobs: | ||
tests: | ||
name: ${{ matrix.os }} / ${{ matrix.python-version }} | ||
runs-on: ${{ matrix.image }} | ||
strategy: | ||
matrix: | ||
os: [Ubuntu, macOS, Windows] | ||
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] | ||
include: | ||
- os: Ubuntu | ||
image: ubuntu-22.04 | ||
- os: Windows | ||
image: windows-2022 | ||
- os: macOS | ||
image: macos-12 | ||
fail-fast: false | ||
defaults: | ||
run: | ||
shell: bash | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
id: setup-python | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install and configure Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
version: 1.7.1 | ||
virtualenvs-in-project: true | ||
|
||
- name: Set up cache | ||
uses: actions/cache@v4 | ||
id: cache | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | ||
|
||
- name: Ensure cache is healthy | ||
if: steps.cache.outputs.cache-hit == 'true' | ||
run: | | ||
# `timeout` is not available on macOS, so we define a custom function. | ||
[ "$(command -v timeout)" ] || function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; } | ||
# Using `timeout` is a safeguard against the Poetry command hanging for some reason. | ||
timeout 10s poetry run pip --version || rm -rf .venv | ||
- name: Check lock file | ||
run: poetry check --lock | ||
|
||
- name: Install dependencies | ||
run: poetry install | ||
|
||
- run: mkdir coverage | ||
|
||
- name: Run pytest | ||
run: poetry run coverage run -m pytest -v | ||
env: | ||
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }} | ||
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }} | ||
|
||
- name: Store coverage files | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: coverage | ||
path: coverage | ||
|
||
- name: Check for clean working tree | ||
run: | | ||
git diff --exit-code --stat HEAD |