Skip to content

Commit

Permalink
TS-534: Switch to localtunnel from tunnelmole.
Browse files Browse the repository at this point in the history
I'm not exactly sure why tunnelmole doesn't work anymore, but I couldn't get it
to run on the Orange Pi in my HIL setup, and there were literally no logs that I
could use to debug. This commit swaps out tunnelmole for localtunnel. I tested
it, and it works.
  • Loading branch information
haydenroche5 committed Jun 27, 2024
1 parent 2eac09e commit f4d271d
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 63 deletions.
25 changes: 14 additions & 11 deletions .github/workflows/notecard-binary-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ jobs:
# START_MD5SRV set to false to skip starting the MD5 server. There should be one
# already running locally with MD5SRV_PORT/ADDRESS/TOKEN set correspondingly.
START_MD5SRV: true
# START_TUNNELMOLE: set to false to skip starting tunnel mole.
START_TUNNELMOLE: true
# START_LT: set to false to skip starting localtunnel (lt).
START_LT: true
# When neither tunneling solution is used (because they're already instantiated outside of the workflow)
# be sure to set MD5SRV_URL in the environment
steps:
Expand Down Expand Up @@ -86,15 +86,18 @@ jobs:
source venv/bin/activate
export PLATFORMIO_BUILD_FLAGS="'-D NOTEHUB_PROXY_ROUTE_ALIAS=\"$NOTEHUB_PROXY_ROUTE_ALIAS\"' '-D PRODUCT_UID=\"$NOTEHUB_PRODUCT_UID\"'"
echo "build flags $PLATFORMIO_BUILD_FLAGS"
# Build the firmware
platformio run -e debug
timeout 10 ./scripts/wait_for_file.sh "$STLINK_PROGRAMMER_PORT"
# Upload the firmware
platformio test -e debug --without-testing --upload-port "$STLINK_PROGRAMMER_PORT" --project-dir "$PIO_PROJECT_DIR"
timeout 10 ./scripts/wait_for_file.sh "$SWAN_SERIAL"
- name: Start tunnelmole
if: env.START_TUNNELMOLE!='false'
- name: Start lt
if: env.START_LT!='false'
run: |
rm -f tmole.log
./scripts/run_tunnelmole.sh
rm -f lt.log
./scripts/run_lt.sh
- name: Check MD5 server is available
run: |
Expand Down Expand Up @@ -196,14 +199,14 @@ jobs:
fi
- name: Cleanup tunnelmole
- name: Cleanup lt
if: always()
run: |
if [ -n "$TMOLE_PID" ]; then
echo "Stopping tunnelmole."
kill $TMOLE_PID
if [ -n "$LT_PID" ]; then
echo "Stopping lt."
kill $LT_PID
else
echo "Tunnelmole not running (TMOLE_PID is empty)."
echo "lt not running (LT_PID is empty)."
fi
- name: Cleanup MD5 server
Expand Down
53 changes: 53 additions & 0 deletions scripts/run_lt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

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 lt > /dev/null 2>&1; then
echo "ERROR: lt command not found." >&2
exit 1
fi

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

sleep 1

TIMEOUT=8
SECONDS=0
MD5SRV_URL=""
# Check lt.log for the MD5 server URL every second.
until [ "$SECONDS" -ge "$TIMEOUT" ]
do
MD5SRV_URL=$(grep -oP "https://[\w\d\.-]+" lt.log)

if [ -n "$MD5SRV_URL" ]; then
break
else
SECONDS=$((SECONDS+1))
sleep 1
fi
done

if [ -z "$MD5SRV_URL" ]; then
echo "ERROR: Timed out waiting for MD5 server URL to get written to lt.log." >&2
echo "lt.log contents:" >&2
cat lt.log >&2
exit 1
fi

echo "INFO: Got MD5 server URL from lt.log." >&2
echo "MD5SRV_URL=$MD5SRV_URL" >> $GITHUB_ENV
echo "INFO: lt ready. Logging to `realpath lt.log`" >&2
4 changes: 4 additions & 0 deletions scripts/run_md5srv.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
. venv/bin/activate
python3 ./test/hitl/scripts/md5srv.py --dir md5srv-files --save > md5srv.log 2>&1 &
MD5SRV_PID=$!
if [ $? -ne 0 ]; then
echo "ERROR: Failed to start md5srv.py. Check md5srv.log." >&2
exit 1
fi
echo "MD5SRV_PID=$MD5SRV_PID" >> $GITHUB_ENV
52 changes: 0 additions & 52 deletions scripts/run_tunnelmole.sh

This file was deleted.

0 comments on commit f4d271d

Please sign in to comment.