Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/test-unit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Unit Test - Python

on:
- pull_request

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/action@v3.0.1

test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install uv
run: |
make uv
- name: Run Tests
run: |
make test-unit xml=true
- name: Upload coverage to Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
coveralls --verbose || echo "Coveralls report failed"
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ __debug_bin
# Python cache files
__pycache__/
*.egg-info/
bin

.coverage
bin
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,19 @@ uv: ## Install UV
ruff: ## Install Ruff
@uvx ruff --help &> /dev/null || uv tool install ruff


.PHONY: verify
verify: uv ruff ## install all required tools
@cd $(PY_DIR) && uv lock --check
@cd $(PY_DIR) && uvx ruff check --show-fixes

.PHONY: test-python
test-python: ## Run Python unit test.
uv install --dev
PYTHONPATH=$(PROJECT_DIR) pytest ./python/kubeflow

# make test-unit will produce html coverage by default. Run with `make test-unit report=xml` to produce xml report.
.PHONY: test-unit
test-unit:
uv pip install "./python[test]"
coverage run --source=kubeflow.trainer.api.trainer_client,kubeflow.trainer.utils.utils -m pytest ./python/kubeflow/trainer/api/trainer_client_test.py
coverage report -m kubeflow/trainer/api/trainer_client.py kubeflow/trainer/utils/utils.py
ifeq ($(report),xml)
coverage xml
else
coverage html
endif
Loading
Loading