Skip to content

Commit e9aa2de

Browse files
authored
Update to pytest and add coverage (#32)
* Update pytest.yml * Update pytest.yml * Update pytest.yml * Update pytest.yml
1 parent 01ceef1 commit e9aa2de

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

.github/workflows/pytest.yml

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
name: Run Unit Test via Pytest
22

3-
on: [push]
3+
concurrency:
4+
group: ${{ github.head_ref || github.run_id }}
5+
cancel-in-progress: true
6+
7+
on:
8+
# Run CI against all pushes (direct commits, also merged PRs), Pull Requests
9+
workflow_dispatch:
10+
push:
11+
branches:
12+
- main
13+
pull_request:
14+
# Runs CI on every day (at 06:00 UTC)
15+
schedule:
16+
- cron: '0 6 * * *'
417

518
jobs:
619
build:
@@ -10,19 +23,22 @@ jobs:
1023
python-version: ['3.9', '3.10', '3.11', '3.12']
1124

1225
steps:
13-
- uses: actions/checkout@v3
26+
- name: Check out the code
27+
uses: actions/checkout@v3
1428
- name: Set up Python ${{ matrix.python-version }}
1529
uses: actions/setup-python@v4
1630
with:
1731
python-version: ${{ matrix.python-version }}
1832
- name: Install dependencies
1933
run: |
2034
python -m pip install --upgrade pip
21-
pip install testtools
22-
pip install requests
23-
pip install pytest
24-
pip install pytest-coverage
35+
pip install testtools requests pytest pytest-coverage coverage
2536
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
26-
- name: Test with pytest
27-
run: |
28-
python -m unittest -v tests/test_*.py
37+
- name: Run Unit Test and Generate report
38+
run: |
39+
coverage run -m pytest -v tests/test_*.py
40+
- name: Upload Coverage to Codecov
41+
uses: codecov/codecov-action@v5
42+
if: ${{ matrix.python-version == '3.12' }}
43+
env:
44+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

0 commit comments

Comments
 (0)