Skip to content

Commit

Permalink
[test] Change yt-dlp failures to warnings, validate script/server out…
Browse files Browse the repository at this point in the history
…put directly (#39)

* Wip

* Update .github/workflows/test.yml

Co-authored-by: grqx <[email protected]>

* Update .github/workflows/test.yml

Co-authored-by: grqx <[email protected]>

* Apply suggestions from code review

Co-authored-by: grqx <[email protected]>

* Fix casing

* Apply suggestions from code review

Co-authored-by: N/Ame <[email protected]>

* Apply suggestions from code review

Co-authored-by: grqx <[email protected]>

---------

Co-authored-by: grqx <[email protected]>
Co-authored-by: N/Ame <[email protected]>
  • Loading branch information
3 people authored Dec 25, 2024
1 parent 9e3c035 commit 8a5dded
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ jobs:
run: |
exit_code=0
# check that the script is returning a POT
script_output=$(node server/build/generate_once.js)
echo "::group::POT response from the script"
echo "$script_output" | jq -C
echo "::endgroup::"
po_token=$(echo "$script_output" | jq -r '.poToken')
visit_identifier=$(echo "$script_output" | jq -r '.visitIdentifier')
if [[ "$po_token" == "null" || "$visit_identifier" == "null" ]]; then
echo "::error title=PoToken generation failed,file=server/src/session_manager.ts::'po_token' or 'visit_identifier' is null."
exit 1
fi
# expect this to fail, but just make sure that the plugin is invoked
{
script_response=$(./yt-dlp ${{ env.TEST_ARGS }} --extractor-args "youtube:getpot_bgutil_script=server/build/generate_once.js" dQw4w9WgXcQ 2>&1)
ret=$?
Expand All @@ -64,8 +79,7 @@ jobs:
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
echo "::warning title=yt-dlp failed when testing script,file=plugin/yt_dlp_plugins/extractor/getpot_bgutil_script.py::yt-dlp returned $ret exit status"
fi
if [[ "$script_response" != *"BgUtilScriptPot: Generating POT via script: "* ]]; then
Expand Down Expand Up @@ -123,6 +137,20 @@ jobs:
echo "$PING_RESP" | jq -C
echo "::endgroup::"
# check that the server is returning a POT
pot_response=$(curl -s -X POST "http://127.0.0.1:${{ env.PORT }}/get_pot")
echo "::group::Get pot response from the HTTP server"
echo "$pot_response" | jq -C
echo "::endgroup::"
po_token=$(echo "$pot_response" | jq -r '.po_token')
visit_identifier=$(echo "$pot_response" | jq -r '.visit_identifier')
if [[ "$po_token" == "null" || "$visit_identifier" == "null" ]]; then
echo "::error title=PoToken generation failed,file=server/src/session_manager.ts::'po_token' or 'visit_identifier' is null."
exit 1
fi
# expect this to fail, but just make sure that the plugin is invoked
{
script_response=$(./yt-dlp ${{ env.TEST_ARGS }} --extractor-args "youtube:getpot_bgutil_baseurl=http://127.0.0.1:${{ env.PORT }}" dQw4w9WgXcQ 2>&1)
ret=$?
Expand All @@ -137,10 +165,9 @@ 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
echo "::warning title=yt-dlp failed when testing HTTP server,file=plugin/yt_dlp_plugins/extractor/getpot_bgutil_http.py::yt-dlp returned $ret exit status"
fi
if [[ "$script_response" != *"BgUtilHTTPPot: Generating POT via HTTP server"* ]]; then
Expand Down

0 comments on commit 8a5dded

Please sign in to comment.