Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test] Change yt-dlp failures to warnings, validate script/server output directly #39

Merged
merged 8 commits into from
Dec 25, 2024
Merged
31 changes: 26 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ jobs:
run: |
exit_code=0

# check that the script is returning a POT
script_output=$(node server/build/generate_once.js)
Brainicism marked this conversation as resolved.
Show resolved Hide resolved

po_token=$(echo "$script_output" | jq -r '.poToken')
visit_identifier=$(echo "$script_output" | jq -r '.visitIdentifier')

if [[ "$po_token" != "null" && "$visit_identifier" == "null" ]]; then
Brainicism marked this conversation as resolved.
Show resolved Hide resolved
echo "Error: 'po_token' or 'visit_identifier' is null."
Brainicism marked this conversation as resolved.
Show resolved Hide resolved
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 +76,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 +134,17 @@ 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")
Brainicism marked this conversation as resolved.
Show resolved Hide resolved
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
Brainicism marked this conversation as resolved.
Show resolved Hide resolved
echo "Error: 'po_token' or 'visit_identifier' is null."
Brainicism marked this conversation as resolved.
Show resolved Hide resolved
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 +159,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
Loading