From d1101d3f65c20bdc8f328453b61e826606284cb6 Mon Sep 17 00:00:00 2001 From: samfreund Date: Fri, 12 Dec 2025 08:51:45 -0600 Subject: [PATCH 1/5] build python examples --- .github/workflows/build.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 23093b203b..46db0f9a02 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -68,6 +68,14 @@ jobs: run: | ./gradlew build ./gradlew clean + - name: Build Python examples + working-directory: photonlib-python-examples + run: | + if [ "${{ matrix.os }}" == "windows-2022" ]; then + .\run.bat + else + ./run.sh + fi playwright-tests: name: "Playwright E2E tests" runs-on: ubuntu-22.04 From 846651dbd1cf931dcfd92c788c27c49337ccd8af Mon Sep 17 00:00:00 2001 From: samfreund Date: Fri, 12 Dec 2025 09:50:29 -0600 Subject: [PATCH 2/5] in the case of no arg, run all --- photonlib-python-examples/run.bat | 18 ++++++++++++------ photonlib-python-examples/run.sh | 19 ++++++++++++------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/photonlib-python-examples/run.bat b/photonlib-python-examples/run.bat index dcb872588f..b6cf6bf259 100644 --- a/photonlib-python-examples/run.bat +++ b/photonlib-python-examples/run.bat @@ -1,12 +1,6 @@ @echo off setlocal -:: Check if the first argument is provided -if "%~1"=="" ( - echo Error: No example-to-run provided. - exit /b 1 -) - :: To run any example, we want to use photonlib out of the source code in this repo. :: Build the wheel first pushd %~dp0..\photon-lib\py @@ -18,6 +12,18 @@ popd set PHOTONLIBPY_ROOT=%~dp0..\photon-lib\py set PYTHONPATH=%PHOTONLIBPY_ROOT% +:: If an example to run is not provided, run all examples +if "%~1"=="" ( + echo No example provided, running all examples + for /D %%d in (*) do ( + if (not "%%d"=="." if not "%%d"=="..") ( + echo Running example in %%d + call "%~dp0run.bat" "%%d" + ) + ) + exit /b 0 +) + :: Move to to the right example folder cd %~1 diff --git a/photonlib-python-examples/run.sh b/photonlib-python-examples/run.sh index c5a82709d3..60219e9b5e 100755 --- a/photonlib-python-examples/run.sh +++ b/photonlib-python-examples/run.sh @@ -1,10 +1,3 @@ -# Check if the first argument is provided -if [ $# -eq 0 ] - then - echo "Error: No example-to-run provided." - exit 1 -fi - # To run any example, we want to use photonlib out of this repo # Build the wheel first pushd ../photon-lib/py @@ -18,6 +11,18 @@ popd export PHOTONLIBPY_ROOT=../photon-lib/py export PYTHONPATH=$PHOTONLIBPY_ROOT +# If an example to run is not provided, run all examples +if [ $# -eq 0 ] + then + echo "No example provided, running all examples" + for dir in */ + do + echo "Running example in $dir" + ./run.sh $dir + done + exit 0 +fi + # Move to the right example folder cd $1 From aee1a29956e84eb1364d4d89d7a473948254bad8 Mon Sep 17 00:00:00 2001 From: samfreund Date: Sat, 13 Dec 2025 22:14:22 -0600 Subject: [PATCH 3/5] install deps --- photonlib-python-examples/run.bat | 7 +++++++ photonlib-python-examples/run.sh | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/photonlib-python-examples/run.bat b/photonlib-python-examples/run.bat index b6cf6bf259..fc1b900c2e 100644 --- a/photonlib-python-examples/run.bat +++ b/photonlib-python-examples/run.bat @@ -8,6 +8,10 @@ if exist build rmdir /S /Q build python setup.py bdist_wheel popd +:: Setup robotpy +pip install robotpy + + :: Add the output directory to PYTHONPATH to make sure it gets picked up ahead of any other installs set PHOTONLIBPY_ROOT=%~dp0..\photon-lib\py set PYTHONPATH=%PHOTONLIBPY_ROOT% @@ -27,5 +31,8 @@ if "%~1"=="" ( :: Move to to the right example folder cd %~1 +:: Setup project +pip install . + :: Run the example robotpy sim diff --git a/photonlib-python-examples/run.sh b/photonlib-python-examples/run.sh index 60219e9b5e..d570d06ff3 100755 --- a/photonlib-python-examples/run.sh +++ b/photonlib-python-examples/run.sh @@ -11,6 +11,9 @@ popd export PHOTONLIBPY_ROOT=../photon-lib/py export PYTHONPATH=$PHOTONLIBPY_ROOT +# Setup robotpy +pip install robotpy + # If an example to run is not provided, run all examples if [ $# -eq 0 ] then @@ -26,5 +29,8 @@ fi # Move to the right example folder cd $1 +# Setup project +pip install . + # Run the example robotpy sim From 3163888652bb476a6566acc624f2ba8b68605bab Mon Sep 17 00:00:00 2001 From: samfreund Date: Sat, 13 Dec 2025 23:49:35 -0600 Subject: [PATCH 4/5] fix workflow --- .github/workflows/build.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 46db0f9a02..c70b849391 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -68,14 +68,15 @@ jobs: run: | ./gradlew build ./gradlew clean - - name: Build Python examples + - name: Build Python examples (Windows) + if: ${{ matrix.os == 'windows-2022' }} + working-directory: photonlib-python-examples + run: .\run.bat + - name: Build Python examples (POSIX) + if: ${{ matrix.os != 'windows-2022' }} working-directory: photonlib-python-examples run: | - if [ "${{ matrix.os }}" == "windows-2022" ]; then - .\run.bat - else - ./run.sh - fi + ./run.sh playwright-tests: name: "Playwright E2E tests" runs-on: ubuntu-22.04 From d42ebb6ea4552df2f2faa69b7cf6752a324eef2d Mon Sep 17 00:00:00 2001 From: samfreund Date: Tue, 16 Dec 2025 15:33:47 -0600 Subject: [PATCH 5/5] exit on error --- photonlib-python-examples/run.bat | 2 ++ photonlib-python-examples/run.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/photonlib-python-examples/run.bat b/photonlib-python-examples/run.bat index fc1b900c2e..304d69c87c 100644 --- a/photonlib-python-examples/run.bat +++ b/photonlib-python-examples/run.bat @@ -1,4 +1,6 @@ @echo off +setlocal enabledelayedexpansion +set "ERRORLEVEL=0" setlocal :: To run any example, we want to use photonlib out of the source code in this repo. diff --git a/photonlib-python-examples/run.sh b/photonlib-python-examples/run.sh index d570d06ff3..1c676ccb18 100755 --- a/photonlib-python-examples/run.sh +++ b/photonlib-python-examples/run.sh @@ -1,3 +1,5 @@ +set -e + # To run any example, we want to use photonlib out of this repo # Build the wheel first pushd ../photon-lib/py