CI #1430
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: CI | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
inputs: | |
push: | |
description: 'If true, actually push to the specified branch specified in the branch option.' | |
required: true | |
default: 'false' | |
branch: | |
description: 'Branch of icub-models to which the action will push' | |
required: true | |
default: 'devel' | |
schedule: | |
# * is a special character in YAML so you have to quote this string | |
# Execute a "nightly" build at 2 AM UTC | |
- cron: '0 2 * * *' | |
env: | |
URDF_PARSER_PY_REPOSITORY_URL: "https://github.com/ros/urdf_parser_py.git" | |
SIMMECHANICS_TO_URDF_REPOSITORY_URL: "https://github.com/robotology/simmechanics-to-urdf.git" | |
DEPLOYMENT_REPOSITORY: "robotology/icub-models" | |
TRIGGERING_BRANCH_VALID_FOR_DEPLOYMENT: "refs/heads/master" | |
TRIGGERING_REPOSITORY_URL_VALID_FOR_DEPLOYMENT: "https://github.com/robotology/icub-model-generator.git" | |
BOT_USER_NAME: "LOC2Bot" | |
ICUB_MODELS_BRANCH: "devel" | |
ICUB_MODELS_SOURCE_DIR: "/home/runner/work/icub-model-generator/icub-model-generator/icub-models" | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Change ICUB_MODELS_BRANCH if necessary | |
shell: bash | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
run: | | |
echo "ICUB_MODELS_BRANCH=${{ github.event.inputs.branch }}" >> $GITHUB_ENV | |
# Print environment variables to simplify development and debugging | |
- name: Environment Variables | |
shell: bash | |
run: env | |
# For all dependencies, we use fixed releases to avoid regression due to | |
# changes in the dependencies. In particular, we use the latest released | |
# version as of 16 Septembter 2019, except for some dependencies that use | |
# specific commits, more details are provided in inline comments | |
- name: Generate models | |
run: | | |
sudo apt-get update | |
sudo apt-get install ruby libeigen3-dev libace-dev libtinyxml-dev libxml2-dev | |
# Save the url of the repository and the user-name of the committ author | |
export CURRENT_REPOSITORY_URL=`git remote get-url origin` | |
# Start in the parent directory of icub-model-generator | |
cd ${GITHUB_WORKSPACE} | |
sudo apt-get install --assume-yes --force-yes python-lxml python-yaml python-numpy python-setuptools | |
# probably python on the path return a python interpreter and the find_package(PythonInterp) in CMake another, | |
# let's install both debian packages and pip packages to be sure | |
sudo pip install lxml numpy pyyaml catkin_pkg | |
# install urdf_parser_py and save the last commit SHA1 hash | |
git clone $URDF_PARSER_PY_REPOSITORY_URL | |
cd urdf_parser_py | |
# workaround for https://github.com/robotology/simmechanics-to-urdf/issues/36 | |
git checkout 31474b9baaf7c3845b40e5a9aa87d5900a2282c3 | |
export URDF_PARSER_PY_COMMIT=`git rev-parse HEAD` | |
sudo python setup.py install | |
cd ${GITHUB_WORKSPACE} | |
# install simmechanics-to-urdf and save the last commit SHA1 hash | |
git clone $SIMMECHANICS_TO_URDF_REPOSITORY_URL | |
cd simmechanics-to-urdf | |
export SIMMECHANICS_TO_URDF_COMMIT=`git rev-parse HEAD` | |
sudo python setup.py install | |
cd ${GITHUB_WORKSPACE} | |
# get C++ dependencies and save their last commit SHA1 hash | |
# ycm | |
git clone https://github.com/robotology/ycm.git | |
cd ycm | |
git checkout v0.12.0 | |
mkdir build | |
cd build | |
cmake .. | |
sudo cmake --build . --target install | |
cd ${GITHUB_WORKSPACE} | |
## yarp | |
git clone https://github.com/robotology/yarp.git | |
cd yarp | |
git checkout v3.4.0 | |
export YARP_COMMIT=`git rev-parse HEAD` | |
mkdir build | |
cd build | |
cmake -DCREATE_LIB_MATH:BOOL=OFF -DYARP_COMPILE_EXECUTABLES:BOOL=OFF .. | |
sudo cmake --build . --target install | |
cd ${GITHUB_WORKSPACE} | |
## idyntree | |
git clone https://github.com/robotology/idyntree.git | |
cd idyntree | |
git checkout v2.0.0 | |
export IDYNTREE_COMMIT=`git rev-parse HEAD` | |
mkdir build | |
cd build | |
cmake .. | |
sudo cmake --build . --target install | |
cd ${GITHUB_WORKSPACE} | |
# Prepare icub-model-generator build | |
mkdir build | |
cd build | |
cmake -DICUB_MODELS_SOURCE_DIR=$ICUB_MODELS_SOURCE_DIR .. | |
# Build and run | |
make VERBOSE=1 | |
ctest --output-on-failure | |
# Clone icub-models repo | |
git clone -b $ICUB_MODELS_BRANCH https://github.com/${DEPLOYMENT_REPOSITORY}.git ${ICUB_MODELS_SOURCE_DIR} | |
# Delete files in iCub directory of icub-models, as they are the one meant to be generated automatically every time | |
# See https://github.com/robotology/icub-models/issues/185 | |
cd ${ICUB_MODELS_SOURCE_DIR} | |
git rm -rf ./iCub | |
# Generate new files | |
cd ${GITHUB_WORKSPACE}/build | |
cmake --build . --target copy-models-to-icub-models | |
# Generate commit message | |
echo "Automatic build. GitHub Actions build: $GITHUB_RUN_ID" >> ${GITHUB_WORKSPACE}/deploy_commit_message | |
echo "icub-model-generator commit: robotology/icub-models-generator@$GITHUB_SHA" >> ${GITHUB_WORKSPACE}/deploy_commit_message | |
echo "urdf_parser_py commit: ros/urdf_parser_py@$URDF_PARSER_PY_COMMIT" >> ${GITHUB_WORKSPACE}/deploy_commit_message | |
echo "simmechanics-to-urdf commit: robotology/simmechanics-to-urdf@$SIMMECHANICS_TO_URDF_COMMIT" >> ${GITHUB_WORKSPACE}/deploy_commit_message | |
- name: Print generated models differences and add files | |
run: | | |
cd $ICUB_MODELS_SOURCE_DIR | |
git diff | |
# Add any new generated file | |
git add --all | |
git status | |
- name: Commit models | |
if: ${{ (github.event_name == 'push' && github.ref == env.TRIGGERING_BRANCH_VALID_FOR_DEPLOYMENT) || (github.event_name == 'workflow_dispatch' && github.event.inputs.push == 'true') }} | |
run: | | |
# See https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables | |
export GIT_COMMITTER_NAME="$(git --no-pager show -s --format='%cn' $GITHUB_SHA)" | |
export GIT_AUTHOR_NAME="$(git --no-pager show -s --format='%an' $GITHUB_SHA)" | |
export GIT_COMMITTER_EMAIL="$(git --no-pager show -s --format='%ce' $GITHUB_SHA)" | |
export GIT_AUTHOR_EMAIL="$(git --no-pager show -s --format='%ae' $GITHUB_SHA)" | |
echo "Commit committer is $GIT_COMMITTER_NAME (email: $GIT_COMMITTER_EMAIL)" | |
echo "Commit author is $GIT_AUTHOR_NAME (email: $GIT_AUTHOR_EMAIL)" | |
cd $ICUB_MODELS_SOURCE_DIR | |
# See https://stackoverflow.com/a/32507305 | |
git commit -a -F ${GITHUB_WORKSPACE}/deploy_commit_message || echo "No changes in the icub-models branch, so no commit was done." | |
- name: Push models | |
uses: ad-m/github-push-action@v0.6.0 | |
if: ${{ (github.event_name == 'push' && github.ref == env.TRIGGERING_BRANCH_VALID_FOR_DEPLOYMENT) || (github.event_name == 'workflow_dispatch' && github.event.inputs.push == 'true') }} | |
with: | |
directory: ${{ env.ICUB_MODELS_SOURCE_DIR }} | |
repository: ${{ env.DEPLOYMENT_REPOSITORY }} | |
branch: ${{ env.ICUB_MODELS_BRANCH }} | |
github_token: ${{ secrets.ICUB_MODELS_GENERATOR_TOKEN }} | |