diff --git a/.github/workflows/one_job.yml b/.github/workflows/one_job.yml index 6d95076cb..d6062c552 100644 --- a/.github/workflows/one_job.yml +++ b/.github/workflows/one_job.yml @@ -204,6 +204,20 @@ jobs: fi go build "${packages[@]}" + test-python: + needs: [changes, authorize] + if: needs.changes.outputs.should_build == 'true' + runs-on: ubuntu-24.04 + + steps: + - name: Checkout repository + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Test Python + run: make test-python + build-soperator-images: needs: - changes @@ -846,6 +860,7 @@ jobs: - pre-build - lint - build-e2e + - test-python - build-slurm-images - build-soperator-images - manifest-populate-jail diff --git a/Makefile b/Makefile index e5d6f5044..900079306 100644 --- a/Makefile +++ b/Makefile @@ -119,6 +119,30 @@ vet: ## Run go vet against code. test: manifests generate fmt vet envtest ## Run tests. go test ./... +.PHONY: test-python +test-python: ## Run all Python unit tests. + @found=false; \ + while IFS= read -r -d '' test_file; do \ + found=true; \ + test_dir=$$(dirname "$$test_file"); \ + test_pattern=$$(basename "$$test_file"); \ + echo "Running Python unit tests in $$test_file"; \ + PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover \ + -s "$$test_dir" \ + -p "$$test_pattern" \ + -v; \ + done < <(find . \ + -type d \( \ + -name .git -o \ + -name .venv -o \ + -name venv -o \ + -name __pycache__ \ + \) -prune -o \ + -type f \( -name '*_test.py' -o -name 'test_*.py' \) -print0); \ + if [ "$$found" = false ]; then \ + echo "No Python unit tests found; skipping."; \ + fi + .PHONY: test-coverage test-coverage: manifests generate fmt vet envtest ## Run tests and generate test coverage. go test ./... -coverprofile cover.out