Skip to content

Commit

Permalink
CI: Fix flaky example runs (#223)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
urfeex authored Nov 21, 2024
1 parent d3baa8b commit bbac0b2
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 13 deletions.
46 changes: 43 additions & 3 deletions .github/helpers/check_urls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,54 @@

set -e

IGNORE_FILES=""
IGNORE_PATTERNS=""

while getopts ":f:d:p:" opt; do
case "${opt}" in
f)
IGNORE_FILES="${OPTARG}";;
d)
IGNORE_DIRS="${OPTARG}";;
p)
IGNORE_PATTERNS="${OPTARG}";;
\?)
echo "Invalid option -$OPTARG"
exit;;
esac
done

read -r -a ignore_files <<<"$IGNORE_FILES"
read -r -a ignore_dirs <<<"$IGNORE_DIRS"
read -r -a ignore_patterns <<<"$IGNORE_PATTERNS"

IGNORE_FILES_ARG=""
for item in "${ignore_files[@]}"; do
IGNORE_FILES_ARG="$IGNORE_FILES_ARG --exclude=$item"
done
IGNORE_DIRS_ARG=""
for item in "${ignore_dirs[@]}"; do
IGNORE_DIRS_ARG="$IGNORE_DIRS_ARG --exclude-dir=$item"
done

#Find URLs in code:
urls=$(grep -oP "(http|ftp|https):\/\/([a-zA-Z0-9_-]+(?:(?:\.[a-zA-Z0-9_-]+)+))([a-zA-Z0-9_.,@?^=%&:\/~+#-]*[a-zA-Z0-9_@?^=%&\/~+#-])?" "$@")
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)

fail_counter=0

FAILED_LINKS=()
for item in $urls; do
# echo $item
# echo $item
skip=0
for pattern in "${ignore_patterns[@]}"; do
[[ "$item" =~ $pattern ]] && skip=1
done

if [[ $skip == 1 ]]; then
echo "SKIPPING $item"
continue
fi

filename=$(echo "$item" | cut -d':' -f1)
url=$(echo "$item" | cut -d':' -f2-)
echo -n "Checking $url from file $filename"
Expand All @@ -24,4 +64,4 @@ done

echo "Failed files:"
printf '%s\n' "${FAILED_LINKS[@]}"
exit $fail_counter
exit $fail_counter
15 changes: 5 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ jobs:
runs-on: ubuntu-latest
name: build (${{matrix.env.URSIM_VERSION}}-${{matrix.env.ROBOT_MODEL}})
strategy:
fail-fast: false
matrix:
env:
- DOCKER_RUN_OPTS: --network ursim_net
Expand Down Expand Up @@ -98,16 +99,10 @@ jobs:
- uses: actions/checkout@v2
- name: Check URLs
run: |
.github/helpers/check_urls.sh -rI \
--exclude-dir=.git \
--exclude-dir=build/ \
--exclude-dir=tests \
--exclude=package.xml \
--exclude-dir=CMakeModules \
--exclude=tcp_socket.cpp \
--exclude-dir=debian \
--exclude=dataflow.graphml \
--exclude=start_ursim.sh
.github/helpers/check_urls.sh \
-d ".git build CMakeModules debian" \
-f "package.xml architecture_coarse.svg dataflow.graphml start_ursim.sh" \
-p "vnc\.html opensource\.org\/licenses\/BSD-3-Clause kernel\.org\/pub\/linux\/kernel"
rosdoc_lite_check:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions examples/dashboard_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <iostream>
#include <memory>
#include <thread>
#include <unistd.h>

using namespace urcl;

Expand Down Expand Up @@ -96,6 +97,8 @@ int main(int argc, char* argv[])
return 1;
}

sleep(1);

// Play loaded program
if (!my_dashboard->commandPlay())
{
Expand Down
1 change: 1 addition & 0 deletions src/ur/dashboard_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ bool DashboardClient::sendRequest(const std::string& command, const std::string&
{
URCL_LOG_DEBUG("Send Request: %s", command.c_str());
std::string response = sendAndReceive(command);
URCL_LOG_DEBUG("Got Response: %s", response.c_str());
bool ret = std::regex_match(response, std::regex(expected));
if (!ret)
{
Expand Down

0 comments on commit bbac0b2

Please sign in to comment.