From a4c37f66e9f2f5ba488d3bfb5c32157981710fc4 Mon Sep 17 00:00:00 2001 From: N/Ame <173015200+grqz@users.noreply.github.com> Date: Sat, 21 Sep 2024 14:33:22 +1200 Subject: [PATCH] exit with 1 on yt-dlp failure (#35) * exit on yt-dlp failure * fix return code * always store return code --- .github/workflows/test.yml | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 132644a..0ddea20 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -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} @@ -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 @@ -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