1+ name : Test Suite
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ - develop
8+ pull_request :
9+ workflow_call :
10+ outputs :
11+ tests_passed :
12+ description : " Whether all tests passed"
13+ value : ${{ jobs.report.outputs.success }}
14+ workflow_dispatch :
15+
16+ jobs :
17+ # Step 1: Fast lint and format checks (fail fast on code style)
18+ lint-check :
19+ runs-on : ubuntu-22.04
20+ steps :
21+ - uses : actions/checkout@v4
22+
23+ - name : Set up uv
24+ uses : astral-sh/setup-uv@v6
25+ with :
26+ enable-cache : true
27+ cache-dependency-glob : " uv.lock"
28+
29+ - name : Run linting (fail fast)
30+ run : |
31+ uv sync --frozen
32+ uv run ruff check
33+ uv run ruff format --check
34+
35+ # Step 2: Build (only after linting passes)
36+ build :
37+ runs-on : ubuntu-22.04
38+ needs : lint-check
39+ outputs :
40+ wheel : ${{ steps.find_wheel.outputs.wheel_path }}
41+ steps :
42+ - name : Checkout this repo
43+ uses : actions/checkout@v4
44+
45+ - name : Set up uv
46+ uses : astral-sh/setup-uv@v6
47+ with :
48+ enable-cache : true
49+ cache-dependency-glob : " uv.lock"
50+
51+ - name : Build otdf-python wheel using uv
52+ run : |
53+ uv sync --frozen
54+ uv build
55+ shell : bash
56+
57+ - name : Find built wheel
58+ id : find_wheel
59+ run : |
60+ wheel_path=$(ls dist/*.whl | head -n1)
61+ echo "wheel_path=$wheel_path" >> $GITHUB_OUTPUT
62+ shell : bash
63+
64+ - name : Upload wheel as artifact
65+ uses : actions/upload-artifact@v4
66+ with :
67+ name : python-wheel
68+ path : dist/*.whl
69+
70+ # Step 3: Unit tests (only after build succeeds)
71+ unit-tests :
72+ runs-on : ubuntu-22.04
73+ needs : build
74+ steps :
75+ - uses : actions/checkout@v4
76+
77+ - name : Set up uv
78+ uses : astral-sh/setup-uv@v6
79+ with :
80+ enable-cache : true
81+ cache-dependency-glob : " uv.lock"
82+
83+ - name : Run unit tests
84+ run : |
85+ uv sync --frozen
86+ uv run pytest -m "not integration" --tb=short -v tests/
87+
88+ # Step 4: Integration tests (only after unit tests pass)
89+ integration-tests :
90+ strategy :
91+ fail-fast : true
92+ matrix :
93+ python3_version : ["3.10", "3.11", "3.12", "3.13"]
94+ needs : [build, unit-tests]
95+ uses : ./.github/workflows/platform-integration-test.yaml
96+ with :
97+ wheel : ${{ needs.build.outputs.wheel }}
98+ python_version : ${{ matrix.python3_version }}
99+
100+ report :
101+ runs-on : ubuntu-22.04
102+ needs : [lint-check, build, unit-tests, integration-tests]
103+ if : always()
104+ outputs :
105+ success : ${{ steps.check.outputs.success }}
106+ steps :
107+ - name : Check all jobs succeeded
108+ id : check
109+ run : |
110+ if [[ "${{ needs.lint-check.result }}" == "success" && "${{ needs.build.result }}" == "success" && "${{ needs.unit-tests.result }}" == "success" && "${{ needs.integration-tests.result }}" == "success" ]]; then
111+ echo "success=true" >> $GITHUB_OUTPUT
112+ echo "✅ All tests passed!"
113+ else
114+ echo "success=false" >> $GITHUB_OUTPUT
115+ echo "❌ Some tests failed:"
116+ echo " Lint Check: ${{ needs.lint-check.result }}"
117+ echo " Build: ${{ needs.build.result }}"
118+ echo " Unit Tests: ${{ needs.unit-tests.result }}"
119+ echo " Integration Tests: ${{ needs.integration-tests.result }}"
120+ exit 1
121+ fi
0 commit comments