-
Notifications
You must be signed in to change notification settings - Fork 6
89 lines (86 loc) · 3.61 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
# This workflow will install Python dependencies, run tests
# and lint with a variety of Python versions
# For more information see:
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Unitest with pytest
on: # yamllint disable-line rule:truthy
pull_request_target:
types:
- opened
- edited
- synchronize
- reopened
workflow_call:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
# This is the version of the action for setting up Python,
# not the Python version.
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Check to make sure that the module is in your Python path
run: |
echo $PYTHONPATH
# You can test your matrix by printing the current Python version
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install pytest
pip install -r requirements.txt
- name: Version check
run:
pytest --version
- name: Unitest with pytest
# yamllint disable rule:line-length
run:
python -m pytest . -v -rP --doctest-modules --junitxml=junit/test-results-${{ matrix.os }}-${{ matrix.python-version }}.xml --cov-report term-missing --cov-fail-under=80 --cov=./ --cov-report html:test-coverage-${{ matrix.os }}-${{ matrix.python-version }}.html
# yamllint enable rule:line-length
- name: Upload pytest test artifacts
uses: actions/upload-artifact@v4
with:
# Name of the artifact to upload.
# Optional. Default is 'artifact'
name:
pytest-results-${{ matrix.os }}-${{ matrix.python-version }}
path:
junit/test-results-${{ matrix.os }}-${{ matrix.python-version }}.xml
# If true, an artifact with a matching name will be deleted before
# a new one is uploaded. If false, the action will fail if an
# artifact for the given name already exists. Does not fail if
# the artifact does not exist. Optional. Default is 'false'
overwrite: false
- name: Upload pytest coverage artifacts
uses: actions/upload-artifact@v4
with:
name:
pytest-coverage-${{ matrix.os }}-${{ matrix.python-version }}
path:
test-coverage-${{ matrix.os }}-${{ matrix.python-version }}.html
# The retention-days value cannot exceed the retention
# limit set by the repository, organization, or enterprise.
# You can define a custom retention period for individual
# artifacts created by a workflow. When using a workflow to
# create a new artifact, you can use retention-days with the
# upload-artifact action.
retention-days: 2
# If true, an artifact with a matching name will be deleted
# before a new one is uploaded. If false, the action will
# fail if an artifact for the given name already exists.
# Does not fail if the artifact does not exist.
# Optional. Default is 'false'
overwrite: false
# Use always() to always run this step to publish test results
# when there are test failures
if: ${{ always() }}