-
Notifications
You must be signed in to change notification settings - Fork 26
187 lines (157 loc) · 7.38 KB
/
ubuntu.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
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.
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' # For some reason, importing 'jiminy_py' causes segfault on ubuntu-22.04
GENERATOR: 'Ninja'
COMPILER: 'clang'
LINKER_FLAGS: '-fuse-ld=gold'
BUILD_TYPE: 'Release'
runs-on: ${{ matrix.OS }}
defaults:
run:
# Using bash with automatic sourcing `.bashrc` and fail-fast behavior enabled
shell: bash -ieo pipefail {0}
#####################################################################################
steps:
- name: Checkout branch
uses: actions/checkout@v4
- 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: Define environment variables
run: |
echo "CMAKE_C_COMPILER=/usr/bin/${{ matrix.COMPILER }}" >> $GITHUB_ENV
if [[ "${{ matrix.COMPILER }}" == 'gcc' ]] ; then
echo "CMAKE_CXX_COMPILER=/usr/bin/g++" >> $GITHUB_ENV
else
echo "CMAKE_CXX_COMPILER=/usr/bin/${{ matrix.COMPILER }}++" >> $GITHUB_ENV
fi
echo "PYTHON_EXECUTABLE=/usr/bin/python3" >> $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 project 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" -f https://download.pytorch.org/whl/torch
"${PYTHON_EXECUTABLE}" -m pip install "gymnasium>=0.28,<1.0" "stable_baselines3>=2.0"
#####################################################################################
- name: PEP8 Code Style Check
if: matrix.OS == 'ubuntu-20.04' && matrix.BUILD_TYPE != 'Debug' && 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}" -Wdev -G "${{ matrix.GENERATOR }}" \
-DCMAKE_EXE_LINKER_FLAGS="${{ matrix.LINKER_FLAGS }}" \
-DCMAKE_SHARED_LINKER_FLAGS="${{ matrix.LINKER_FLAGS }}" \
-DCMAKE_C_COMPILER="${CMAKE_C_COMPILER}" -DCMAKE_CXX_COMPILER="${CMAKE_CXX_COMPILER}" \
-DCMAKE_PREFIX_PATH="/opt/openrobots/" -DCMAKE_INSTALL_PREFIX="${InstallDir}" \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=${{ (matrix.BUILD_TYPE == 'Debug' && 'OFF') || 'ON' }} \
-DBoost_NO_SYSTEM_PATHS=OFF -DPYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}" \
-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"
# Make sure that jiminy_py Python module can be imported
# export LD_LIBRARY_PATH="$InstallDir/lib"
"${PYTHON_EXECUTABLE}" -c "import jiminy_py; print(jiminy_py.get_libraries())"
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_SHARED_LINKER_FLAGS="${{ matrix.LINKER_FLAGS }}" \
-DCMAKE_C_COMPILER="${CMAKE_C_COMPILER}" -DCMAKE_CXX_COMPILER="${CMAKE_CXX_COMPILER}" \
-DCMAKE_PREFIX_PATH="/opt/openrobots/" -DCMAKE_INSTALL_PREFIX="${InstallDir}" \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=${{ (matrix.BUILD_TYPE == 'Debug' && 'OFF') || 'ON' }} \
-DPYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}" -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: |
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 linter
if: matrix.OS == 'ubuntu-20.04' && matrix.BUILD_TYPE != 'Debug' && 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-22.04' && success() &&
github.repository == 'duburcqa/jiminy' && github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: crazy-max/ghaction-github-pages@v4
with:
target_branch: gh-pages
build_dir: docs/html
env:
GITHUB_TOKEN: ${{ secrets.GH_DEPLOY }}