-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathgithub-actions.sh
executable file
·100 lines (92 loc) · 2.76 KB
/
github-actions.sh
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
#!/bin/bash
: '
Author: Lander Usategui, lander dot usategui at gmail dot com
'
set -e
# Export colors
export RED="\033[31m"
export GREEN="\033[32m"
export YELLOW="\033[33m"
export BLUE="\033[34m"
export PURPLE="\e[0;35m"
export RESET="\e[0m"
# Paths
export WS="/root/ros2_ws"
export ROS2_DISTRO="rolling"
function prepare_ws()
{
echo -e "${YELLOW}Preparing work space${RESET}"
cd ${WS} || exit
cp -r /tmp/pendulum src
result=$?
if [ $result -ne 0 ]; then
echo -e "${RED}prepare_ws failed${RESET}"
exit $result
else
echo -e "${BLUE}prepare_ws function successfully finished${RESET}"
fi
}
function run_rosdep()
{
echo -e "${YELLOW}Making sure that everything is installed${RESET}"
cd ${WS} || exit
apt update -qq && rosdep update
rosdep install -q -y --from-paths . --ignore-src --rosdistro \
"${ROS2_DISTRO}" \
--as-root=apt:false || true
result=$?
if [ $result -ne 0 ]; then
echo -e "${RED}run_rosdep failled${RESET}"
exit $result
else
echo -e "${BLUE}All dependencies successfully installed${RESET}"
fi
}
function compile_ws()
{
# shellcheck source=/dev/null
source /opt/ros/"${ROS2_DISTRO}"/setup.bash
cd ${WS} || exit
echo -e "${YELLOW}###### Packages to be compiled ######${RESET}"
echo -e "${PURPLE}"
colcon list --names-only
echo -e "${RESET}"
echo -e "${YELLOW}Compile the WS for ROS2${RESET}"
if ! colcon build --build-base build-install --install-base install-merge --merge-install --packages-up-to pendulum; then
echo -e "${RED}Unable to compile the ws${RESET}"
exit 1
else
echo -e "${BLUE}WS compiled successfully${RESET}"
fi
echo -e "${YELLOW}Testing WS${RESET}"
if ! colcon test --build-base build-install --install-base install-merge --merge-install --return-code-on-test-failure; then
colcon test-result --test-result-base build-install --verbose
echo -e "${RED}Error testing the ws${RESET}"
exit 1
else
echo -e "${BLUE}WS compiled successfully${RESET}"
fi
}
function compile_ws_symlink()
{
# shellcheck source=/dev/null
source /opt/ros/"${ROS2_DISTRO}"/setup.bash
cd ${WS} || exit
echo -e "${YELLOW}###### Packages to be compiled ######${RESET}"
echo -e "${PURPLE}"
colcon list --names-only
echo -e "${RESET}"
echo -e "${YELLOW}Compile the WS for ROS2 using --symlink-install${RESET}"
if ! colcon build --build-base build-symlink --install-base install-symlink --symlink-install --packages-up-to pendulum; then
echo -e "${RED}Error compiling the WS_SYMLINK${RESET}"
exit 1
else
echo -e "${BLUE}WS_SYMLINK compiled successfully${RESET}"
fi
}
prepare_ws
run_rosdep
compile_ws
compile_ws_symlink
#If we're here everything is okay
echo -e "${GREEN}All steps successfully completed${RESET}"