Skip to content

[gym_jiminy/common] Speed-up env pipeline. #2662

[gym_jiminy/common] Speed-up env pipeline.

[gym_jiminy/common] Speed-up env pipeline. #2662

Workflow file for this run

name: Ubuntu CI (Easy install dependencies)
on:
# Trigger the workflow on push on the master branch, or for any pull request
push:
branches:
- master
pull_request:
jobs:
build-test-and-deploy-doc-ubuntu:
name: >-
(${{ matrix.os }}) (${{ matrix.BUILD_TYPE }}) (${{ matrix.COMPILER }}, ${{ matrix.GENERATOR }})
Easy install the dependencies. Build the project and run the unit tests.
Generate and deploy the documentation.
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
GENERATOR: ['Unix Makefiles']
COMPILER: ['gcc']
BUILD_TYPE: ['Release']
include:
- os: ubuntu-20.04
GENERATOR: 'Unix Makefiles'
COMPILER: 'gcc'
BUILD_TYPE: 'Debug'
- os: ubuntu-20.04
GENERATOR: 'Ninja'
COMPILER: 'clang'
LINKER_FLAGS: '-fuse-ld=gold'
BUILD_TYPE: 'Release'
defaults:
run:
# Using bash with automatic sourcing `.bashrc` and fail-fast behavior enabled
shell: bash -ieo pipefail {0}
env:
TORCH_VERSION: "2.0.1+cpu"
#####################################################################################
steps:
- name: Checkout branch
uses: actions/checkout@v3
#####################################################################################
- name: Define environment variables
run: |
echo "CC=/usr/bin/${{ matrix.COMPILER }}" >> $GITHUB_ENV
if [[ "${{ matrix.COMPILER }}" == 'gcc' ]] ; then
echo "CXX=/usr/bin/g++" >> $GITHUB_ENV
else
echo "CXX=/usr/bin/${{ matrix.COMPILER }}++" >> $GITHUB_ENV
fi
echo "PYTHON_EXECUTABLE=/usr/bin/python3" >> $GITHUB_ENV
echo "PYTHON_INCLUDE_DIRS=$(${PYTHON_EXECUTABLE} -c \
'import sysconfig as sysconfig; print(sysconfig.get_path("include"))')" >> $GITHUB_ENV
echo "RootDir=${GITHUB_WORKSPACE}" >> $GITHUB_ENV
echo "InstallDir=${GITHUB_WORKSPACE}/install" >> $GITHUB_ENV
echo "/home/runner/.local/bin" >> $GITHUB_PATH
- name: Install pre-compiled dependencies
run: |
sudo env "PATH=$PATH" "$RootDir/build_tools/easy_install_deps_ubuntu.sh"
if [[ "${{ matrix.GENERATOR }}" == 'Ninja' ]] ; then
sudo apt install ninja-build
fi
"${PYTHON_EXECUTABLE}" -m pip install "torch==${TORCH_VERSION}" -f https://download.pytorch.org/whl/torch
"${PYTHON_EXECUTABLE}" -m pip install "gymnasium>=0.26,<0.29" "importlib-metadata>=3.3.0"
#####################################################################################
- name: PEP8 Code Style Check
if: matrix.os == 'ubuntu-20.04' && matrix.BUILD_TYPE == 'Release' && matrix.COMPILER == 'gcc'
run: |
"${PYTHON_EXECUTABLE}" -m pip install flake8
flake8 --ignore=E121,E126,E123,E226,E241,E266,E402,E741,F405,W504 \
--count --show-source --statistics --exclude unit_py,examples "$RootDir/python/"
#####################################################################################
- name: Build and install Jiminy
run: |
mkdir "$RootDir/build" "$InstallDir"
cd "$RootDir/build"
cmake "$RootDir" -G "${{ matrix.GENERATOR }}" -DCMAKE_EXE_LINKER_FLAGS="${{ matrix.LINKER_FLAGS }}" \
-DCMAKE_PREFIX_PATH="/opt/openrobots/" -DCMAKE_INSTALL_PREFIX="$InstallDir" \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DBoost_NO_SYSTEM_PATHS=OFF \
-DPYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}" -DPYTHON_INCLUDE_DIR="${PYTHON_INCLUDE_DIRS}" \
-DBUILD_TESTING=ON -DBUILD_EXAMPLES=ON -DBUILD_PYTHON_INTERFACE=ON \
-DCMAKE_BUILD_TYPE="${{ matrix.BUILD_TYPE }}"
if [[ "${{ matrix.GENERATOR }}" == 'Ninja' ]] ; then
ninja install -j2
else
make install -j2
fi
#####################################################################################
- name: Build extension module
run: |
"$InstallDir/bin/jiminy_double_pendulum"
RootDir="$RootDir/core/examples/external_project/"
mkdir -p "$RootDir/build"
cd "$RootDir/build"
cmake "$RootDir" -G "${{ matrix.GENERATOR }}" -DCMAKE_EXE_LINKER_FLAGS="${{ matrix.LINKER_FLAGS }}" \
-DCMAKE_PREFIX_PATH="/opt/openrobots/" -DCMAKE_INSTALL_PREFIX="$InstallDir" \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
-DPYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}" -DPYTHON_INCLUDE_DIR="${PYTHON_INCLUDE_DIRS}" \
-DCMAKE_BUILD_TYPE="${{ matrix.BUILD_TYPE }}"
if [[ "${{ matrix.GENERATOR }}" == 'Ninja' ]] ; then
ninja install
else
make install
fi
"$InstallDir/bin/pip_double_pendulum"
- name: Run unit tests for jiminy
run: |
cd "$RootDir/build/core/unit"
ctest --output-on-failure
cd "$RootDir/python/jiminy_py/unit_py"
"${PYTHON_EXECUTABLE}" -m unittest discover -v
- name: Run unit tests for gym_jiminy
if: matrix.BUILD_TYPE == 'Release'
run: |
cd "$RootDir/python/gym_jiminy/examples/reinforcement_learning/rllib"
"${PYTHON_EXECUTABLE}" acrobot_ppo.py
"${PYTHON_EXECUTABLE}" -m pip install "stable_baselines3>=2.0"
cd "$RootDir/python/gym_jiminy/unit_py"
"${PYTHON_EXECUTABLE}" -m unittest discover -v
#####################################################################################
- name: Python linter
if: matrix.os == 'ubuntu-20.04' && matrix.BUILD_TYPE == 'Release' && matrix.COMPILER == 'gcc'
run: |
cd "$RootDir/python/jiminy_py/"
pylint --rcfile="$RootDir/.pylintrc" "src/"
for name in "common" "toolbox" "rllib"; do
cd "$RootDir/python/gym_jiminy/$name"
pylint --rcfile="$RootDir/.pylintrc" "gym_jiminy/"
done
#####################################################################################
- name: Generate and install Doxygen documentation
run: |
cd build
cmake . # Reconfigure cmake since sphinx has been installed in the meantime
cmake . -DCOMPONENT=docs -P ./cmake_install.cmake
- name: Deploy to GitHub Pages
if: >-
matrix.os == 'ubuntu-20.04' && success() &&
github.repository == 'duburcqa/jiminy' && github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: crazy-max/ghaction-github-pages@v3
with:
target_branch: gh-pages
build_dir: docs/html
env:
GITHUB_TOKEN: ${{ secrets.GH_DEPLOY }}