-
Notifications
You must be signed in to change notification settings - Fork 23
155 lines (143 loc) · 6.82 KB
/
ci.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
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}
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
run: |
cd $ICUB_MODELS_SOURCE_DIR
git diff
- 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
# Add any new generated file
git add --all
# 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 }}