Skip to content

Commit bbac0b2

Browse files
authored
CI: Fix flaky example runs (#223)
The example runs seem to fail quite often. This PR aims at fixing that. It seems that the simulated robot is reporting readiness for executing programs a bit too early and if we execute the program rightaway it is not started correctly. This only seems to happen in CI though.
1 parent d3baa8b commit bbac0b2

File tree

4 files changed

+52
-13
lines changed

4 files changed

+52
-13
lines changed

.github/helpers/check_urls.sh

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,54 @@
22

33
set -e
44

5+
IGNORE_FILES=""
6+
IGNORE_PATTERNS=""
7+
8+
while getopts ":f:d:p:" opt; do
9+
case "${opt}" in
10+
f)
11+
IGNORE_FILES="${OPTARG}";;
12+
d)
13+
IGNORE_DIRS="${OPTARG}";;
14+
p)
15+
IGNORE_PATTERNS="${OPTARG}";;
16+
\?)
17+
echo "Invalid option -$OPTARG"
18+
exit;;
19+
esac
20+
done
21+
22+
read -r -a ignore_files <<<"$IGNORE_FILES"
23+
read -r -a ignore_dirs <<<"$IGNORE_DIRS"
24+
read -r -a ignore_patterns <<<"$IGNORE_PATTERNS"
25+
26+
IGNORE_FILES_ARG=""
27+
for item in "${ignore_files[@]}"; do
28+
IGNORE_FILES_ARG="$IGNORE_FILES_ARG --exclude=$item"
29+
done
30+
IGNORE_DIRS_ARG=""
31+
for item in "${ignore_dirs[@]}"; do
32+
IGNORE_DIRS_ARG="$IGNORE_DIRS_ARG --exclude-dir=$item"
33+
done
34+
535
#Find URLs in code:
6-
urls=$(grep -oP "(http|ftp|https):\/\/([a-zA-Z0-9_-]+(?:(?:\.[a-zA-Z0-9_-]+)+))([a-zA-Z0-9_.,@?^=%&:\/~+#-]*[a-zA-Z0-9_@?^=%&\/~+#-])?" "$@")
36+
urls=$(grep -oP '(http|ftp|https):\/\/([a-zA-Z0-9_-]+(?:(?:\.[a-zA-Z0-9_-]+)+))([a-zA-Z0-9_.,@?^=%&:\/~+#-]*[a-zA-Z0-9_@?^=%&\/~+#-])?' -rI $IGNORE_FILES_ARG $IGNORE_DIRS_ARG)
737

838
fail_counter=0
939

1040
FAILED_LINKS=()
1141
for item in $urls; do
12-
# echo $item
42+
# echo $item
43+
skip=0
44+
for pattern in "${ignore_patterns[@]}"; do
45+
[[ "$item" =~ $pattern ]] && skip=1
46+
done
47+
48+
if [[ $skip == 1 ]]; then
49+
echo "SKIPPING $item"
50+
continue
51+
fi
52+
1353
filename=$(echo "$item" | cut -d':' -f1)
1454
url=$(echo "$item" | cut -d':' -f2-)
1555
echo -n "Checking $url from file $filename"
@@ -24,4 +64,4 @@ done
2464

2565
echo "Failed files:"
2666
printf '%s\n' "${FAILED_LINKS[@]}"
27-
exit $fail_counter
67+
exit $fail_counter

.github/workflows/ci.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
name: build (${{matrix.env.URSIM_VERSION}}-${{matrix.env.ROBOT_MODEL}})
99
strategy:
10+
fail-fast: false
1011
matrix:
1112
env:
1213
- DOCKER_RUN_OPTS: --network ursim_net
@@ -98,16 +99,10 @@ jobs:
9899
- uses: actions/checkout@v2
99100
- name: Check URLs
100101
run: |
101-
.github/helpers/check_urls.sh -rI \
102-
--exclude-dir=.git \
103-
--exclude-dir=build/ \
104-
--exclude-dir=tests \
105-
--exclude=package.xml \
106-
--exclude-dir=CMakeModules \
107-
--exclude=tcp_socket.cpp \
108-
--exclude-dir=debian \
109-
--exclude=dataflow.graphml \
110-
--exclude=start_ursim.sh
102+
.github/helpers/check_urls.sh \
103+
-d ".git build CMakeModules debian" \
104+
-f "package.xml architecture_coarse.svg dataflow.graphml start_ursim.sh" \
105+
-p "vnc\.html opensource\.org\/licenses\/BSD-3-Clause kernel\.org\/pub\/linux\/kernel"
111106
112107
rosdoc_lite_check:
113108
runs-on: ubuntu-latest

examples/dashboard_example.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <iostream>
3737
#include <memory>
3838
#include <thread>
39+
#include <unistd.h>
3940

4041
using namespace urcl;
4142

@@ -96,6 +97,8 @@ int main(int argc, char* argv[])
9697
return 1;
9798
}
9899

100+
sleep(1);
101+
99102
// Play loaded program
100103
if (!my_dashboard->commandPlay())
101104
{

src/ur/dashboard_client.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ bool DashboardClient::sendRequest(const std::string& command, const std::string&
156156
{
157157
URCL_LOG_DEBUG("Send Request: %s", command.c_str());
158158
std::string response = sendAndReceive(command);
159+
URCL_LOG_DEBUG("Got Response: %s", response.c_str());
159160
bool ret = std::regex_match(response, std::regex(expected));
160161
if (!ret)
161162
{

0 commit comments

Comments
 (0)