-
Notifications
You must be signed in to change notification settings - Fork 27
168 lines (138 loc) · 6.52 KB
/
linux.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Linux 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-linux:
name: >-
(${{ matrix.PYTHON_VERSION }}) (${{ matrix.BUILD_TYPE }})
Build the dependencies. Build the project and run the unit tests.
runs-on: ubuntu-24.04
strategy:
matrix:
PYTHON_VERSION: ['3.10', '3.11', '3.12']
BUILD_TYPE: ['Release']
include:
- PYTHON_VERSION: '3.12'
BUILD_TYPE: 'Debug'
defaults:
run:
shell: bash -ieo pipefail {0}
env:
CXX_FLAGS: "-march=x86-64-v3 -mtune=generic"
#####################################################################################
steps:
- name: Configure Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.PYTHON_VERSION }}
- name: Free Disk Space
uses: jlumbroso/free-disk-space@v1.3.1
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
swap-storage: false
- name: Checkout jiminy
uses: actions/checkout@v4
#####################################################################################
- name: Define environment variables
run: |
PYTHON_EXECUTABLE="${pythonLocation}/bin/python3"
echo "PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}" >> $GITHUB_ENV
echo "RootDir=${GITHUB_WORKSPACE}" >> $GITHUB_ENV
echo "InstallDir=${GITHUB_WORKSPACE}/install" >> $GITHUB_ENV
echo "/home/runner/.local/bin" >> $GITHUB_PATH
- name: Setup minimal build environment
run: |
sudo apt update
sudo apt install -y gdb gnupg curl wget build-essential cmake doxygen graphviz texlive-latex-base
"${PYTHON_EXECUTABLE}" -m pip install setuptools wheel "pip>=20.3"
git config --global advice.detachedHead false
- name: Install pre-compiled binaries for additional gym-jiminy dependencies
if: matrix.PYTHON_VERSION != '3.13'
run: |
"${PYTHON_EXECUTABLE}" -m pip install "torch" -f https://download.pytorch.org/whl/torch
"${PYTHON_EXECUTABLE}" -m pip install "gymnasium>=0.28,<1.0" "stable_baselines3>=2.0,<2.4"
- name: Install latest numpy version at build-time for run-time binary compatibility
run: |
"${PYTHON_EXECUTABLE}" -m pip install --upgrade "numpy>=1.24" numba torch
- name: Build jiminy dependencies
run: |
BUILD_TYPE="${{ matrix.BUILD_TYPE }}" ./build_tools/build_install_deps_unix.sh
#####################################################################################
- name: Build and install Jiminy
run: |
unset Boost_ROOT
mkdir "${RootDir}/build"
cd "${RootDir}/build"
cmake "${RootDir}" -Wdev \
-DCMAKE_INSTALL_PREFIX="$InstallDir" -DCMAKE_PREFIX_PATH="$InstallDir" \
-DBOOST_ROOT="$InstallDir" -DBoost_INCLUDE_DIR="$InstallDir/include" \
-DBoost_NO_SYSTEM_PATHS=TRUE -DBoost_NO_BOOST_CMAKE=TRUE -DBoost_USE_STATIC_LIBS=ON \
-DPYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}" \
-DBUILD_TESTING=ON -DBUILD_EXAMPLES=ON -DBUILD_PYTHON_INTERFACE=ON \
-DINSTALL_GYM_JIMINY=${{ (matrix.PYTHON_VERSION == '3.13' && 'OFF') || 'ON' }} \
-DCMAKE_CXX_FLAGS="${CXX_FLAGS}" -DCMAKE_BUILD_TYPE="${{ matrix.BUILD_TYPE }}"
make install -j4
echo "LD_LIBRARY_PATH=$InstallDir/lib:$InstallDir/lib64:/usr/local/lib" >> $GITHUB_ENV
#####################################################################################
- name: Build extension module
run: |
"$InstallDir/bin/jiminy_double_pendulum"
mkdir -p "${RootDir}/core/examples/external_project/build"
cd "${RootDir}/core/examples/external_project/build"
cmake "${RootDir}/core/examples/external_project/" \
-DCMAKE_INSTALL_PREFIX="$InstallDir" -DCMAKE_PREFIX_PATH="$InstallDir" \
-DPYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}" \
-DCMAKE_CXX_FLAGS="${CXX_FLAGS}" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}"
make install
"$InstallDir/bin/pip_double_pendulum"
#####################################################################################
- name: Run unit tests for jiminy
run: |
ctest --output-on-failure --test-dir "${RootDir}/build/core/unit"
"${PYTHON_EXECUTABLE}" -m unittest discover -s "${RootDir}/python/jiminy_py/unit_py" -v
- name: Run unit tests for gym jiminy base module
run: |
if [[ "${{ matrix.BUILD_TYPE }}" == 'Debug' ]] ; then
export JIMINY_BUILD_DEBUG=
fi
"${PYTHON_EXECUTABLE}" -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'
run: |
cd "${RootDir}/python/gym_jiminy/examples/rllib"
"${PYTHON_EXECUTABLE}" acrobot_ppo.py
- name: Python static type checker
if: matrix.BUILD_TYPE != 'Debug' && matrix.PYTHON_VERSION == '3.10'
run: |
# Generate stubs
# FIXME: stubgen does not work with Numpy 2.X
# (see https://github.com/python/mypy/issues/17396)
"${PYTHON_EXECUTABLE}" -m pip install "numpy<2.0"
stubgen -p jiminy_py -o ${RootDir}/build/pypi/jiminy_py/src
"${PYTHON_EXECUTABLE}" "${RootDir}/build_tools/stubgen.py" \
-o ${RootDir}/build/stubs --ignore-invalid=all jiminy_py
cp ${RootDir}/build/stubs/jiminy_py-stubs/core/__init__.pyi \
${RootDir}/build/pypi/jiminy_py/src/jiminy_py/core/core.pyi
"${PYTHON_EXECUTABLE}" -m pip install --upgrade "numpy>=1.24" numba torch
# Re-install jiminy with stubs
cd "${RootDir}/build"
make install
# mypy is not able to follow `.pth` when checking directories or files.
# This bug may be fixed in the future. The only workaround is to set `MYPYPATH` manually.
# Anyway, the stubs generated for eigenpy, hppfcl and pinocchio they are incomplete and
# even partially wrong, so it is better to ignore them for now.
# See: https://github.com/python/mypy/issues/14848.
cd "${RootDir}/python/jiminy_py/src"
mypy --config-file="${RootDir}/.mypy.ini" -p jiminy_py
for name in "common" "envs" "toolbox" "rllib"; do
cd "${RootDir}/python/gym_jiminy/$name"
mypy --config-file="${RootDir}/.mypy.ini" -p gym_jiminy
done