From 4c7af312d6290829e4c209b4ee6cff5602b208b7 Mon Sep 17 00:00:00 2001 From: aviruthen <91846056+aviruthen@users.noreply.github.com> Date: Wed, 3 Sep 2025 16:24:12 -0700 Subject: [PATCH 1/6] Add code coverage workflow --- .github/workflows/code-coverage.yml | 46 +++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/code-coverage.yml diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml new file mode 100644 index 00000000..73c5a46c --- /dev/null +++ b/.github/workflows/code-coverage.yml @@ -0,0 +1,46 @@ +name: "Code Coverage" +on: + pull_request: + branches: [ "main", "master" ] + +jobs: + coverage: + name: Overall Coverage Check + runs-on: ubuntu-latest + timeout-minutes: 15 + permissions: + contents: read + pull-requests: write + + strategy: + matrix: + python-version: ["3.11"] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + # Install project dependencies first + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + if [ -f setup.py ]; then pip install -e .; fi + # Install testing tools + pip install pytest pytest-cov + + - name: Run Unit Tests with Coverage + run: | + pytest test/unit_tests/ --cov=src/ --cov-report=term-missing --cov-report=xml --cov-fail-under=70 + + - name: Upload Coverage Report + uses: actions/upload-artifact@v3 + if: always() + with: + name: coverage-report + path: coverage.xml From 8744b0f50c79be2a4356d86044a9b81ae8a43ddd Mon Sep 17 00:00:00 2001 From: aviruthen <91846056+aviruthen@users.noreply.github.com> Date: Wed, 3 Sep 2025 17:00:13 -0700 Subject: [PATCH 2/6] Update artifact version to v4 --- .github/workflows/code-coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 73c5a46c..59b1a54c 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -39,7 +39,7 @@ jobs: pytest test/unit_tests/ --cov=src/ --cov-report=term-missing --cov-report=xml --cov-fail-under=70 - name: Upload Coverage Report - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: always() with: name: coverage-report From 1aa6bd53ebbe50945729b88e6e159c885534830a Mon Sep 17 00:00:00 2001 From: aviruthen <91846056+aviruthen@users.noreply.github.com> Date: Wed, 3 Sep 2025 17:06:22 -0700 Subject: [PATCH 3/6] Fixed report upload --- .github/workflows/code-coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 59b1a54c..3cd76204 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -36,7 +36,7 @@ jobs: - name: Run Unit Tests with Coverage run: | - pytest test/unit_tests/ --cov=src/ --cov-report=term-missing --cov-report=xml --cov-fail-under=70 + pytest test/unit_tests/ --cov=src/ --cov-report=term-missing --cov-report=xml:coverage.xml --cov-fail-under=70 - name: Upload Coverage Report uses: actions/upload-artifact@v4 From 954a12198742e4591d0b75e5319c9ddd8ab28056 Mon Sep 17 00:00:00 2001 From: aviruthen <91846056+aviruthen@users.noreply.github.com> Date: Wed, 3 Sep 2025 17:21:29 -0700 Subject: [PATCH 4/6] Simplified workflow using tox.ini --- .github/workflows/code-coverage.yml | 10 +++------- tox.ini | 6 ++++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 3cd76204..e33aa345 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -25,18 +25,14 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Install Dependencies + - name: Install tox run: | python -m pip install --upgrade pip - # Install project dependencies first - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - if [ -f setup.py ]; then pip install -e .; fi - # Install testing tools - pip install pytest pytest-cov + pip install tox - name: Run Unit Tests with Coverage run: | - pytest test/unit_tests/ --cov=src/ --cov-report=term-missing --cov-report=xml:coverage.xml --cov-fail-under=70 + tox -e coverage - name: Upload Coverage Report uses: actions/upload-artifact@v4 diff --git a/tox.ini b/tox.ini index 1751b2ee..e250fa9b 100644 --- a/tox.ini +++ b/tox.ini @@ -23,3 +23,9 @@ commands = description = Run integration tests commands = pytest test/integration_tests + +[testenv:coverage] +description = Run unit tests with coverage +deps = pytest-cov +commands = + pytest test/unit_tests --cov=src --cov-report=term-missing --cov-report=xml:coverage.xml --cov-fail-under=70 From 6bed27ea01467ebcafe522aa8e8313c6e0694e6c Mon Sep 17 00:00:00 2001 From: aviruthen <91846056+aviruthen@users.noreply.github.com> Date: Wed, 3 Sep 2025 17:27:01 -0700 Subject: [PATCH 5/6] Make sure coverage is on right source files --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index e250fa9b..ecefe5f1 100644 --- a/tox.ini +++ b/tox.ini @@ -28,4 +28,4 @@ commands = description = Run unit tests with coverage deps = pytest-cov commands = - pytest test/unit_tests --cov=src --cov-report=term-missing --cov-report=xml:coverage.xml --cov-fail-under=70 + pytest test/unit_tests --cov=src/sagemaker --cov-report=term-missing --cov-report=xml:coverage.xml --cov-fail-under=70 From c04687a10b4bb63da48d76640ce2eefc47bc1390 Mon Sep 17 00:00:00 2001 From: aviruthen <91846056+aviruthen@users.noreply.github.com> Date: Wed, 3 Sep 2025 20:42:17 -0700 Subject: [PATCH 6/6] Bug fix for 0 percent code coverage error --- tox.ini | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index ecefe5f1..e2fd7d55 100644 --- a/tox.ini +++ b/tox.ini @@ -26,6 +26,8 @@ commands = [testenv:coverage] description = Run unit tests with coverage -deps = pytest-cov +deps = + pytest-cov + -e . commands = - pytest test/unit_tests --cov=src/sagemaker --cov-report=term-missing --cov-report=xml:coverage.xml --cov-fail-under=70 + pytest test/unit_tests --cov=sagemaker.hyperpod --cov-report=term-missing --cov-report=xml:coverage.xml --cov-fail-under=70