Skip to content

Commit

Permalink
exit with 1 on yt-dlp failure (#35)
Browse files Browse the repository at this point in the history
* exit on yt-dlp failure

* fix return code

* always store return code
  • Loading branch information
grqz authored Sep 21, 2024
1 parent e45e1bb commit a4c37f6
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,34 @@ jobs:
- name: Test script method
shell: bash
run: |
script_response=$(./yt-dlp ${{ env.TEST_ARGS }} --extractor-args "youtube:getpot_bgutil_script=server/build/generate_once.js" dQw4w9WgXcQ 2>&1) || \
echo "::error title=Failed to run yt-dlp when testing script::\
yt-dlp returned $? exit status"
exit_code=0
script_response=$(./yt-dlp ${{ env.TEST_ARGS }} --extractor-args "youtube:getpot_bgutil_script=server/build/generate_once.js" dQw4w9WgXcQ 2>&1)
ret=$?
echo "::group::Logs from yt-dlp"
printf "%s\n" "$script_response"
echo "::endgroup::"
if [ "$ret" -ne 0 ]; then
echo "::error title=yt-dlp failed when testing script,file=plugin/yt_dlp_plugins/extractor/getpot_bgutil_script.py::yt-dlp returned $ret exit status"
[ "$exit_code" -eq 0 ] && exit_code=$ret
fi
if [[ "$script_response" != *"BgUtilScriptPot: Generating POT via script: "* ]]; then
echo "::error title=BgUtilScriptPot was not invoked,file=plugin/yt_dlp_plugins/extractor/getpot_bgutil_script.py::\
BgUtilScriptPot was not invoked"
exit 1
[ "$exit_code" -eq 0 ] && exit_code=1
fi
exit $exit_code
server-method:
name: Test plugin (server method)
runs-on: ubuntu-latest
env:
PORT: ${{ 4426 }}
# Interval/Timeout in seconds to wait for the server to be up
INTERVAL: ${{ 0.4 }}
INTERVAL: ${{ 0.5 }}
TIMEOUT: ${{ 7.5 }}
steps:
- uses: actions/checkout@v4
Expand All @@ -93,6 +101,7 @@ jobs:
timeout-minutes: 3
shell: bash
run: |
exit_code=0
ping() {
until curl -o- --silent --fail http://127.0.0.1:${{ env.PORT }}/ping 2>&1; do
sleep ${1:-0.5}
Expand All @@ -111,9 +120,8 @@ jobs:
echo "$PING_RESP" | jq -C
echo "::endgroup::"
script_response=$(./yt-dlp ${{ env.TEST_ARGS }} --extractor-args "youtube:getpot_bgutil_baseurl=http://127.0.0.1:${{ env.PORT }}" dQw4w9WgXcQ 2>&1) || \
echo "::error title=Failed to run yt-dlp when testing HTTP server::\
yt-dlp returned $? exit status"
script_response=$(./yt-dlp ${{ env.TEST_ARGS }} --extractor-args "youtube:getpot_bgutil_baseurl=http://127.0.0.1:${{ env.PORT }}" dQw4w9WgXcQ 2>&1)
ret=$?
docker stop bgutil-provider
Expand All @@ -124,9 +132,16 @@ jobs:
echo "::group::Logs from yt-dlp"
printf "%s\n" "$script_response"
echo "::endgroup::"
if [ "$ret" -ne 0 ]; then
echo "::error title=yt-dlp failed when testing HTTP server,file=plugin/yt_dlp_plugins/extractor/getpot_bgutil_http.py::yt-dlp returned $ret exit status"
[ "$exit_code" -eq 0 ] && exit_code=$ret
fi
if [[ "$script_response" != *"BgUtilHTTPPot: Generating POT via HTTP server"* ]]; then
echo "::error title=BgUtilHTTPPot was not invoked,file=plugin/yt_dlp_plugins/extractor/getpot_bgutil_http.py::\
BgUtilHTTPPot was not invoked"
exit 1
[ "$exit_code" -eq 0 ] && exit_code=1
fi
exit $exit_code

0 comments on commit a4c37f6

Please sign in to comment.