-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (69 loc) · 2.45 KB
/
pytest.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
##########################################################################################
# DESCRIPTION: Runs pytests with multiple versions of python.
# AUTHOR: W. Li
# VERSION: 1.0
# CREATED: 1/6/2024
#
# References:
# * https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-pythonCommon
#
##########################################################################################
name: pytests
on:
# Configure the branches you want Github actions to run on.
# Leave blank if you want to run on all branches.
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
##########################################################################################
# Jobs
##########################################################################################
jobs:
########################################################################################
# Run all tests.
########################################################################################
test:
# Set the OS and python versions
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11"]
steps:
# Checkout the repo
- name: Checkout Repo
uses: actions/checkout@v4
# Setup the python environments to use.
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
token: ${{ secrets.GH_GITHUB_COM_TOKEN }}
python-version: ${{ matrix.python-version }}
# Install poetry and disable virtual environments.
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: false
virtualenvs-in-project: false
installer-parallel: true
# Install dependencies.
- name: Install dependencies
run: |
poetry install --no-interaction --with=dev --no-root
# Run pytest with coverage.
- name: Test with pytest
run: >
pytest
--doctest-modules
--cov=./
--cov-report=xml
--cov-report=html:pytest-results-${{ matrix.python-version }}
# Save artifacts from pytests.
- name: Upload pytest test results
uses: actions/upload-artifact@v3
with:
name: pytest-results-${{ matrix.python-version }}
path: pytest-results-${{ matrix.python-version }}
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}