Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ jobs:
run: |
./gradlew build
./gradlew clean
- 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: |
./run.sh
playwright-tests:
name: "Playwright E2E tests"
runs-on: ubuntu-22.04
Expand Down
27 changes: 21 additions & 6 deletions photonlib-python-examples/run.bat
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
@echo off
setlocal enabledelayedexpansion
set "ERRORLEVEL=0"
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
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%

:: 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

:: Setup project
pip install .

:: Run the example
robotpy sim
25 changes: 19 additions & 6 deletions photonlib-python-examples/run.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
# Check if the first argument is provided
if [ $# -eq 0 ]
then
echo "Error: No example-to-run provided."
exit 1
fi
set -e

# To run any example, we want to use photonlib out of this repo
# Build the wheel first
Expand All @@ -18,8 +13,26 @@ 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
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

# Setup project
pip install .

# Run the example
robotpy sim
Loading