From 6ca7354542dc544b31aa67a4db0c697a15255161 Mon Sep 17 00:00:00 2001 From: Charlotte Wilson <251223230+cswilson252@users.noreply.github.com> Date: Wed, 7 Jan 2026 16:14:39 -0500 Subject: [PATCH] Build Python examples during CI run (#2273) Adds `photonlib-python-examples` to CI build run to make sure that Python builds cleanly against that PR/commit. --- .github/workflows/python.yml | 84 +++++++++++++++++++++++++++++--- photonlib-python-examples/run.sh | 2 +- 2 files changed, 77 insertions(+), 9 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index bb5618e8d..7f47b2aca 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -12,7 +12,7 @@ concurrency: cancel-in-progress: true jobs: - buildAndDeploy: + build-and-deploy: runs-on: ubuntu-24.04 steps: @@ -33,8 +33,7 @@ jobs: - name: Build wheel working-directory: ./photon-lib/py - run: | - python setup.py sdist bdist_wheel + run: python setup.py sdist bdist_wheel - name: Run Unit Tests working-directory: ./photon-lib/py @@ -43,11 +42,7 @@ jobs: pytest - name: Run mypy type checking - uses: liskin/gh-problem-matcher-wrap@v3 - with: - linters: mypy - run: | - mypy --show-column-numbers --config-file photon-lib/py/pyproject.toml photon-lib + run: mypy --show-column-numbers --config-file photon-lib/py/pyproject.toml photon-lib - name: Upload artifacts uses: actions/upload-artifact@master @@ -64,3 +59,76 @@ jobs: permissions: id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + + build-python-examples: + strategy: + matrix: + os: [ubuntu-24.04, windows-2022, macos-14] + runs-on: ${{ matrix.os }} + + steps: + + - name: Checkout code + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: 3.12 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel pytest mypy numpy wpilib pyntcore opencv-python robotpy==2026.1.1b1 pyfrc + + - name: Build wheel + working-directory: ./photon-lib/py + run: python setup.py sdist bdist_wheel + + - name: Run Unit Tests (Unix) + working-directory: ./photon-lib/py + if: runner.os != 'Windows' + run: | + pip install --no-cache-dir dist/*.whl + pytest + + - name: Run Unit Tests (Windows) + working-directory: ./photon-lib/py + if: runner.os == 'Windows' + shell: cmd + run: | + for %%f in (dist/*.whl) do ( + echo installing dist/%%f + pip install --no-cache-dir dist/%%f + ) + pytest + + - name: Build and configure PhotonLibPy (bash) + working-directory: ./photon-lib/py + if: runner.os != 'Windows' + run: | + ./buildAndTest.sh + ./enableUsingDevBuilds.sh + + - name: Build and configure PhotonLibPy (pwsh) + working-directory: ./photon-lib/py + if: runner.os == 'Windows' + run: | + ./buildandTest.bat + ./enableUsingDevBuilds.bat + + + - name: Run mypy type checking + run: mypy --show-column-numbers --config-file photon-lib/py/pyproject.toml photon-lib + + - name: Build Python examples + working-directory: photonlib-python-examples + shell: bash + run: | + for folder in */; + do + echo $folder + ./run.sh $folder + done diff --git a/photonlib-python-examples/run.sh b/photonlib-python-examples/run.sh index c5a82709d..d7ff04a54 100755 --- a/photonlib-python-examples/run.sh +++ b/photonlib-python-examples/run.sh @@ -22,4 +22,4 @@ export PYTHONPATH=$PHOTONLIBPY_ROOT cd $1 # Run the example -robotpy sim +python3 robot.py sim