Skip to content

Commit 050901b

Browse files
authored
Add code-coverage workflow to GitHub workflows (#257)
* Add code coverage workflow * Update artifact version to v4 * Fixed report upload * Simplified workflow using tox.ini * Make sure coverage is on right source files * Bug fix for 0 percent code coverage error
1 parent 60982da commit 050901b

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: "Code Coverage"
2+
on:
3+
pull_request:
4+
branches: [ "main", "master" ]
5+
6+
jobs:
7+
coverage:
8+
name: Overall Coverage Check
9+
runs-on: ubuntu-latest
10+
timeout-minutes: 15
11+
permissions:
12+
contents: read
13+
pull-requests: write
14+
15+
strategy:
16+
matrix:
17+
python-version: ["3.11"]
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: Install tox
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install tox
32+
33+
- name: Run Unit Tests with Coverage
34+
run: |
35+
tox -e coverage
36+
37+
- name: Upload Coverage Report
38+
uses: actions/upload-artifact@v4
39+
if: always()
40+
with:
41+
name: coverage-report
42+
path: coverage.xml

tox.ini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@ commands =
2323
description = Run integration tests
2424
commands =
2525
pytest test/integration_tests
26+
27+
[testenv:coverage]
28+
description = Run unit tests with coverage
29+
deps =
30+
pytest-cov
31+
-e .
32+
commands =
33+
pytest test/unit_tests --cov=sagemaker.hyperpod --cov-report=term-missing --cov-report=xml:coverage.xml --cov-fail-under=70

0 commit comments

Comments
 (0)