-
Notifications
You must be signed in to change notification settings - Fork 1
107 lines (96 loc) · 3.91 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Test
on:
workflow_dispatch:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
lint-format:
name: Lint and format check
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- name: Install Ruff and autopep8
run: pip install ruff autopep8
- name: Python lint check (Ruff)
run: ruff check --output-format=github -v plugin/
- name: Python lint check (autopep8)
if: always()
run: autopep8 --diff plugin/
- name: Install server dependencies
if: always()
run: cd server && yarn install
- name: Server lint check (ESlint)
if: always()
run: cd server && npx eslint --max-warnings=0 src/
- name: Server format check (Prettier)
if: always()
run: cd server && npx prettier --check 'src/**/*.{js,ts}'
script-method:
name: Test plugin
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download yt-dlp
run: curl -L https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/latest/download/yt-dlp -o yt-dlp && chmod +x ./yt-dlp
- name: Install and build server dependencies
run: cd server/ && yarn install --frozen-lockfile && npx tsc
- name: Install plugin
run: |
mkdir ~/yt-dlp-plugins && curl -L "https://github.com/coletdjnz/yt-dlp-get-pot/releases/download/v0.1.1/yt-dlp-get-pot.zip" -o ~/yt-dlp-plugins/yt-dlp-get-pot.zip
cp -aT plugin/ ~/yt-dlp-plugins/bgutil-ytdlp-pot-provider/
- name: Test script method
shell: bash
run: |
script_response=$(./yt-dlp -vF --print-traffic BaW_jenozKc --extractor-args "youtube:getpot_bgutil_script=server/build/generate_once.js" 2>&1) || \
echo "::error title=Failed to run yt-dlp when testing script::\
yt-dlp returned $? exit status"
echo "::group::Logs from yt-dlp"
printf "%s\n" "$script_response"
echo "::endgroup::"
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
fi
- name: Test server method
timeout-minutes: 3
if: always()
shell: bash
run: |
cd server/
SERVER_LOG_PATH=$(mktemp)
node build/main.js >$SERVER_LOG_PATH 2>&1 &
NODE_PID=$!
echo "Waiting for server to be up..."
ping() {
until RESP=$(curl -o- --silent --fail http://127.0.0.1:4416/ping 2>&1); do
sleep ${1:-0.5}
done
}
export -f ping
timeout 7.5 bash -c "ping 0.5" || \
(echo "::error title=Timeout reached,file=server/src/main.ts::\
Timeout reached before the server is up." && exit 1)
echo "::group::Response from HTTP server"
echo $RESP | jq
echo "::endgroup::"
cd ..
script_response=$(./yt-dlp -vF --print-traffic BaW_jenozKc 2>&1) || \
echo "::error title=Failed to run yt-dlp when testing HTTP server::\
yt-dlp returned $? exit status"
kill $NODE_PID
echo "::group::Logs from HTTP server"
cat "$SERVER_LOG_PATH"
echo "::endgroup::"
rm -f $SERVER_LOG_PATH
echo "::group::Logs from yt-dlp"
printf "%s\n" "$script_response"
echo "::endgroup::"
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
fi