preserve: all working state from workspace #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Sonar Vision CI/CD Pipeline | ||
| # | ||
| # Triggers: | ||
| # - push to main: test + build + lint | ||
| # - tag v*: test + build + publish to PyPI | ||
| # - pull_request: test only | ||
| # | ||
| # Builds sdist + manylinux wheels for x86_64 and aarch64. | ||
| name: sonar-sim-pipeline | ||
| on: | ||
| push: | ||
| branches: [main, master] | ||
| tags: ["v*"] | ||
| pull_request: | ||
| branches: [main, master] | ||
| jobs: | ||
| lint: | ||
| name: Lint | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.12" | ||
| - run: pip install mypy ruff tomli >/dev/null | ||
| - run: ruff check sonar-vision/packages/pipeline/ --no-fix || true | ||
| - run: mypy sonar-vision/packages/pipeline/ --ignore-missing-imports || true | ||
| test: | ||
| name: Test py${{ matrix.python }} | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python: ["3.9", "3.10", "3.11", "3.12"] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python }} | ||
| - name: Install | ||
| run: | | ||
| cd sonar-vision/packages/pipeline | ||
| pip install -e ".[dev]" >/dev/null 2>&1 | ||
| - name: Import check | ||
| run: | | ||
| cd sonar-vision/packages/pipeline | ||
| python -c "from sim_pipeline import *; print('import OK')" | ||
| - name: Run tests | ||
| run: | | ||
| cd sonar-vision/packages/pipeline | ||
| python -c " | ||
| import sys; sys.path.insert(0,'.') | ||
| from sim_pipeline import * | ||
| p = compute_physics(15.0, chl=4.0, season='summer', sediment='sand') | ||
| assert abs(p['temperature'] - 22.0) < 0.5, 'thermocline mismatch' | ||
| rt = SonarRayTracer(); ret = rt.compute_return(10.0, 50.0, 100.0) | ||
| assert 0.13 < ret['total_travel_time_s'] < 0.15, 'travel time out of range' | ||
| m = MissionPlanner().lawnmower('t', 500, 200, 25) | ||
| assert len(m.waypoints) == 8, 'lawnmower wp count' | ||
| sim = AUVFleetSimulator(FluxPhysics()); sim.spawn_fleet(3); sim.run_for(10) | ||
| assert sim.fleet_summary()['count'] == 3 | ||
| print('ALL TESTS PASSED (py${{ matrix.python }})') | ||
| " | ||
| build: | ||
| name: Build wheels | ||
| runs-on: ubuntu-latest | ||
| needs: [lint, test] | ||
| if: startsWith(github.ref, 'refs/tags/v') | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.12" | ||
| - name: Install build tools | ||
| run: pip install build wheel twine cibuildwheel >/dev/null | ||
| - name: Build sdist | ||
| run: | | ||
| cd sonar-vision/packages/pipeline | ||
| python -m build --sdist | ||
| - name: Build manylinux wheels | ||
| uses: pypa/cibuildwheel@v2.21 | ||
| env: | ||
| CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-*" | ||
| CIBW_ARCHS: "x86_64 aarch64" | ||
| CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9" | ||
| with: | ||
| package-dir: sonar-vision/packages/pipeline | ||
| output-dir: sonar-vision/packages/pipeline/dist | ||
| - name: Check distribution | ||
| run: | | ||
| cd sonar-vision/packages/pipeline | ||
| twine check dist/* | ||
| - name: Upload artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: dist | ||
| path: sonar-vision/packages/pipeline/dist/ | ||
| publish: | ||
| name: Publish to PyPI | ||
| runs-on: ubuntu-latest | ||
| needs: [build] | ||
| if: startsWith(github.ref, 'refs/tags/v') | ||
| environment: pypi | ||
| permissions: | ||
| id-token: write | ||
| steps: | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| name: dist | ||
| path: dist/ | ||
| - name: Publish to PyPI | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| packages-dir: dist/ | ||
| verbose: true | ||