Skip to content

Commit

Permalink
Improve run_tunnelmole.sh (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenroche5 authored Mar 14, 2024
1 parent 1b75e7f commit bd9556e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/notecard-binary-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
uses: JarvusInnovations/background-action@v1
with:
run: |
bash ./scripts/run_md5srv.sh
./scripts/run_md5srv.sh
wait-on:
# just a dummy wait-on since this is required.
file:${{github.workspace}}/scripts/run_md5srv.sh
Expand Down Expand Up @@ -161,7 +161,7 @@ jobs:
if: env.START_TUNNELMOLE!='false'
with:
run: |
bash ./scripts/run_tunnelmole.sh
./scripts/run_tunnelmole.sh
log-output-if: true
wait-on:
file:${{github.workspace}}/tmole_ready
Expand Down
38 changes: 32 additions & 6 deletions scripts/run_tunnelmole.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,50 @@
#!/bin/bash
set -e

[ -n "$MD5SRV_PORT" ] || (echo "MD5SRV_PORT not set" && exit 1)
which tmole
if [ -n "$MD5SRV_PORT" ]; then
echo "INFO: Using MD5 server port $MD5SRV_PORT." >&2
else
echo "ERROR: MD5SRV_PORT not defined." >&2
exit 1
fi

if ! which tmole > /dev/null 2>&1; then
echo "ERROR: tmole command not found." >&2
exit 1
fi

echo "INFO: Starting tmole..." >&2
tmole $MD5SRV_PORT > tmole.log 2>&1 &
TMOLE_PID=$!
echo "TMOLE_PID=$TMOLE_PID"
echo "INFO: tmole PID is $TMOLE_PID." >&2
echo "TMOLE_PID=$TMOLE_PID" >> $GITHUB_ENV
timeout 10 bash -c "until test -e tmole.log; do sleep 0.1; done"
if [ $? -ne 0 ]; then
echo "ERROR: tmole failed to start." >&2
exit 1
fi

sleep 1

# find the url
exec 3< tmole.log
# ignore the first line
read <&3 output
read <&3 output

echo "Getting MD5 server URL from tmole.log..." >&2
MD5SRV_URL=`echo "$output" | grep https | cut -d " " -f1`
[ -n "$MD5SRV_URL" ] || (echo "Could not fetch tunnelmole URL" && exit 1)
if [ -z "$MD5SRV_URL" ]; then
echo "ERROR: Failed to get MD5 server URL." >&2
exit 1
else
echo "INFO: Got MD5 server URL." >&2
fi

echo "MD5SRV_URL=$MD5SRV_URL" >> $GITHUB_ENV
# Only create tmole_ready once MD5SRV_URL has been set, as the next step in the
# GitHub workflow depends on it.
touch tmole_ready

sleep 2
echo "Tunnel mole started. Writing logs to `realpath tmole.log`"

echo "INFO: tmole ready. Logging to `realpath tmole.log`" >&2
6 changes: 3 additions & 3 deletions test/hitl/card.binary/lib/notecard_binary/NotecardComms.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ enum NotecardInterface {
#endif

#if defined(NOTECARD_DEBUG_STLINK)
HardwareSerial stlinkSerial(PIN_VCP_RX, PIN_VCP_TX);
#define dbgSerial stlinkSerial
HardwareSerial stlinkSerial(PIN_VCP_RX, PIN_VCP_TX);
#define dbgSerial stlinkSerial
#else
#define dbgSerial Serial
#define dbgSerial Serial
#endif

bool initialize_notecard_interface(NotecardInterface iface);
Expand Down

0 comments on commit bd9556e

Please sign in to comment.