[gym_jiminy/common] Fix cache auto-refresh edge-case. #4825
This file contains 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
name: Windows CI (Build from source dependencies) | |
on: | |
# Trigger the workflow on push on the master branch, or for any pull request | |
push: | |
branches: | |
- master | |
pull_request: | |
jobs: | |
build-and-test-win10: | |
name: >- | |
(Windows) (${{ matrix.PYTHON_VERSION }}) (${{ matrix.BUILD_TYPE }}) | |
Build the dependencies. Build the project and run the unit tests. | |
runs-on: windows-2022 | |
defaults: | |
run: | |
shell: pwsh | |
env: | |
GENERATOR: "Visual Studio 17 2022" | |
CXX_FLAGS: "/DEIGEN_MPL2_ONLY /d2ReducedOptimizeHugeFunctions /fp:contract /arch:AVX2" | |
strategy: | |
matrix: | |
PYTHON_VERSION: ['3.10', '3.11', '3.12', '3.13'] | |
BUILD_TYPE: ['Release'] | |
include: | |
- PYTHON_VERSION: '3.12' | |
BUILD_TYPE: 'Debug' | |
##################################################################################### | |
steps: | |
- name: Configure Pagefile | |
uses: al-cheb/[email protected] | |
with: | |
disk-root: "C:" | |
- name: Create workspace on secondary drive (C:) that has more space | |
run: | | |
New-Item -ItemType Directory -Force -Path C:\workspace | |
New-Item -ItemType Junction -Force -Value C:\workspace -Path "${env:GITHUB_WORKSPACE}/workspace" | |
- name: Configure Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.PYTHON_VERSION }} | |
- name: Checkout jiminy | |
uses: actions/checkout@v4 | |
with: | |
path: 'workspace' | |
##################################################################################### | |
- name: Setup minimal build environment | |
run: | | |
git config --global advice.detachedHead false | |
python -m pip install setuptools wheel "pip>=20.3" | |
python -m pip install pefile machomachomangler | |
- name: Install pre-compiled binaries for additional gym-jiminy dependencies | |
run: | | |
# FIXME: Pre-release 2.6 is needed to install torch for Python 3.13 on Windows | |
python -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu | |
python -m pip install "gymnasium>=0.28,<1.1" "stable_baselines3>=2.0,<2.5" | |
- name: Install latest numpy version at build-time for run-time binary compatibility | |
run: | | |
python -m pip install --upgrade "numpy>=1.24" numba torch | |
- name: Build jiminy dependencies | |
run: | | |
${env:BUILD_TYPE} = "${{ matrix.BUILD_TYPE }}" | |
& "./workspace/build_tools/build_install_deps_windows.ps1" | |
##################################################################################### | |
- name: Configure and build jiminy | |
# FIXME: CMake exits with non-zero code if an error occurred in 'execute_process'. | |
# Indeed, such errors are expected to occur if some gym_jiminy add-on cannot be | |
# installed because of missing pre-compiled dependency on Pypi. | |
continue-on-error: true | |
run: | | |
$ErrorActionPreference = "Stop" | |
Set-PSDebug -Trace 1 | |
$RootDir = "${env:GITHUB_WORKSPACE}/workspace" -replace '\\', '/' | |
$InstallDir = "$RootDir/install" | |
if (Test-Path env:Boost_ROOT) { | |
Remove-Item env:Boost_ROOT | |
} | |
if (-not (Test-Path -PathType Container $RootDir/build)) { | |
New-Item -ItemType "directory" -Force -Path "$RootDir/build" | |
} | |
Set-Location -Path $RootDir/build | |
cmake "$RootDir" -Wdev -G "${env:GENERATOR}" -DCMAKE_GENERATOR_PLATFORM=x64 ` | |
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>DLL" ` | |
-DCMAKE_INSTALL_PREFIX="$InstallDir" -DCMAKE_PREFIX_PATH="$InstallDir" ` | |
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_VERBOSE_MAKEFILE=ON ` | |
-DBOOST_ROOT="$InstallDir" -DBoost_INCLUDE_DIR="$InstallDir/include" ` | |
-DBoost_NO_SYSTEM_PATHS=TRUE -DBoost_NO_BOOST_CMAKE=TRUE ` | |
-DBoost_USE_STATIC_LIBS=ON -DPYTHON_REQUIRED_VERSION="${{ matrix.PYTHON_VERSION }}" ` | |
-DBUILD_TESTING=ON -DBUILD_EXAMPLES=ON -DBUILD_PYTHON_INTERFACE=ON ` | |
-DCMAKE_CXX_FLAGS="${env:CXX_FLAGS} $( | |
) -DBOOST_ALL_NO_LIB -DBOOST_LIB_DIAGNOSTIC -DBOOST_CORE_USE_GENERIC_CMATH $( | |
) -DEIGENPY_STATIC -DURDFDOM_STATIC -DHPP_FCL_STATIC -DPINOCCHIO_STATIC" | |
cmake --build . --target ALL_BUILD --config "${{ matrix.BUILD_TYPE }}" --parallel 4 | |
if (-not (Test-Path -PathType Container "$RootDir/build/pypi/jiminy_py/src/jiminy_py")) { | |
New-Item -ItemType "directory" -Force -Path "$RootDir/build/pypi/jiminy_py/src/jiminy_py/core" | |
} | |
Copy-Item -Force -Recurse -Path "$InstallDir/lib/site-packages/*" ` | |
-Destination "$RootDir/build/pypi/jiminy_py/src/jiminy_py/core" | |
${env:Path} += ";$InstallDir/lib" | |
cmake --build . --target INSTALL --config "${{ matrix.BUILD_TYPE }}" | |
##################################################################################### | |
- name: Generating the Python Pip wheels | |
run: | | |
$RootDir = "${env:GITHUB_WORKSPACE}/workspace" -replace '\\', '/' | |
$InstallDir = "$RootDir/install" | |
${env:Path} += ";$InstallDir/lib" | |
# Generate stubs | |
# FIXME: stubgen does not work with Numpy 2.X without option `--no-analysis` | |
# (see https://github.com/python/mypy/issues/17396) | |
stubgen -p jiminy_py -o $RootDir/build/pypi/jiminy_py/src --no-analysis | |
python "$RootDir/build_tools/stubgen.py" ` | |
-o $RootDir/build/stubs --ignore-invalid=all jiminy_py | |
Copy-Item -Force -Path "$RootDir/build/stubs/jiminy_py-stubs/core/__init__.pyi" ` | |
-Destination "$RootDir/build/pypi/jiminy_py/src/jiminy_py/core/core.pyi" | |
# Generate wheels | |
Set-Location -Path "$RootDir/build" | |
cmake . -DCOMPONENT=pypi -P ./cmake_install.cmake | |
# Bundle non-standard dependencies with the wheels | |
Remove-Item -Recurse -Path "$RootDir/build/pypi" -Include *.tar.gz | |
Get-ChildItem -Recurse -Path "$RootDir/build/pypi/dist/jiminy_py" -Filter *.whl | | |
Foreach-Object { | |
$wheel_path = ($_.FullName) | |
python "$RootDir/build_tools/wheel_repair_win.py" "$wheel_path" -d "$InstallDir/lib" -w "$RootDir/build/wheelhouse" | |
} | |
Get-ChildItem -Path "$RootDir/build/wheelhouse" -Filter *.whl | | |
Foreach-Object { | |
$wheel_path = ($_.FullName) | |
python -m pip install --force-reinstall --no-deps $wheel_path | |
} | |
- name: Upload the wheel for Windows of jiminy_py | |
if: matrix.BUILD_TYPE != 'Debug' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheelhouse-${{ matrix.PYTHON_VERSION }} | |
path: 'workspace/build/wheelhouse' | |
##################################################################################### | |
- name: Build extension module | |
run: | | |
$ErrorActionPreference = "Stop" | |
Set-PSDebug -Trace 1 | |
$RootDir = "${env:GITHUB_WORKSPACE}/workspace" -replace '\\', '/' | |
$InstallDir = "$RootDir/install" | |
& "$InstallDir/bin/jiminy_double_pendulum.exe" | |
mkdir -p "$RootDir/core/examples/external_project/build" | |
cd "$RootDir/core/examples/external_project/build" | |
$JIMINY_LIB_DIR = (python -c "import os, jiminy_py ; print(os.path.dirname(jiminy_py.get_libraries()))") | |
echo $JIMINY_LIB_DIR | |
${env:Path} += ";$JIMINY_LIB_DIR" | |
cmake "$RootDir/core/examples/external_project/" -G "${env:GENERATOR}" -DCMAKE_GENERATOR_PLATFORM=x64 ` | |
-DCMAKE_INSTALL_PREFIX="$InstallDir" -DCMAKE_PREFIX_PATH="$InstallDir" ` | |
-DPYTHON_REQUIRED_VERSION="${{ matrix.PYTHON_VERSION }}" ` | |
-DCMAKE_CXX_FLAGS="${env:CXX_FLAGS}" | |
cmake --build . --target INSTALL --config "${{ matrix.BUILD_TYPE }}" | |
& "$InstallDir/bin/pip_double_pendulum.exe" | |
- name: Running unit tests for jiminy | |
run: | | |
$RootDir = "${env:GITHUB_WORKSPACE}/workspace" -replace '\\', '/' | |
ctest --output-on-failure --test-dir "${RootDir}/build/core/unit" | |
python -m unittest discover -s "${RootDir}/python/jiminy_py/unit_py" -v | |
- name: Run unit tests for gym jiminy base module | |
run: | | |
$RootDir = "${env:GITHUB_WORKSPACE}/workspace" -replace '\\', '/' | |
if ("${{ matrix.BUILD_TYPE }}" -eq "Debug") { | |
${env:JIMINY_BUILD_DEBUG} = 1 | |
} | |
python -m unittest discover -s "$RootDir/python/gym_jiminy/unit_py" -v | |
- name: Run examples for gym jiminy add-on modules | |
if: matrix.BUILD_TYPE != 'Debug' && matrix.PYTHON_VERSION != '3.13' | |
run: | | |
$RootDir = "${env:GITHUB_WORKSPACE}/workspace" -replace '\\', '/' | |
Set-Location -Path "$RootDir/python/gym_jiminy/examples/rllib" | |
python acrobot_ppo.py | |
######################################################################################### | |
publish-pypi-win10: | |
name: (Windows) Publish on PyPi the wheel for Windows of jiminy_py | |
runs-on: ubuntu-24.04 | |
permissions: | |
id-token: write | |
needs: build-and-test-win10 | |
if: github.repository == 'duburcqa/jiminy' && github.event_name == 'push' && github.ref == 'refs/heads/master' | |
steps: | |
- name: Download the wheels previously generated | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: wheelhouse-* | |
merge-multiple: true | |
path: wheelhouse | |
- name: Publish on PyPi the wheels | |
uses: pypa/[email protected] | |
with: | |
packages-dir: wheelhouse | |
verify-metadata: false |