Refactor code structure for improved readability and maintainability

This commit is contained in:
2025-10-25 21:17:36 +03:00
parent 3d8a634241
commit d2127b2b2c
2 changed files with 8 additions and 53 deletions
+8 -52
View File
@@ -1,4 +1,4 @@
name: Integration tests (full workflow)
name: Integration tests (minimal)
on:
push:
@@ -8,72 +8,28 @@ on:
jobs:
integration:
name: Run integration full-workflow tests
name: Run integration tests
runs-on: ubuntu-latest
env:
# opt-in flag consumed by the integration script
INTEGRATION_TEST: '1'
# default playlist (override via repo secret or workflow dispatch if desired)
TEST_PLAYLIST_URL: 'https://www.youtube.com/playlist?list=PLUmRr21IDW9WCW87FnbWAbIwwZHbf-lAz'
steps:
- name: Checkout repository
uses: https://gitea.com/actions/checkout@v5
- name: Install system packages (Python, jq)
run: |
sudo apt-get update -y
# ensure venv support is available so we can create an isolated environment
# jq is used to parse the release JSON when fetching assets from the repo
sudo apt-get install -y python3 python3-pip python3-venv jq curl
- name: Download latest release binaries from repo
- name: Create venv and install project
run: |
set -euo pipefail
# Use the provided releases URL host and owner/repo
GITEA_API_URL="https://git.darkzoul.org/api/v1/repos/dark_zoul/youtube-playlist-downloader/releases/latest"
echo "Fetching release info from: $GITEA_API_URL"
RELEASE_JSON=$(curl -sSL "$GITEA_API_URL" || true)
download_asset() {
local pattern="$1"
url=$(echo "$RELEASE_JSON" | jq -r --arg pat "$pattern" '.assets[] | select(.name | test($pat; "i")) | (.browser_download_url // .download_url) ' | head -n1 || true)
if [[ -n "$url" && "$url" != "null" ]]; then
echo "Downloading asset matching '$pattern' -> $url"
sudo curl -L --fail -o "/usr/local/bin/$(basename $url)" "$url"
sudo chmod +x "/usr/local/bin/$(basename $url)"
return 0
fi
return 1
}
fetched_any=0
if download_asset "yt-?dl" ; then fetched_any=1; fi
if download_asset "aria2" ; then fetched_any=1; fi
if download_asset "ffmpeg" ; then fetched_any=1; fi
if [[ $fetched_any -eq 0 ]]; then
echo "No matching release assets found for yt-dlp/aria2/ffmpeg on git.darkzoul.org; falling back to apt packages"
sudo apt-get install -y ffmpeg aria2 yt-dlp
else
echo "Installed binaries from latest release into /usr/local/bin"
ls -l /usr/local/bin/yt* /usr/local/bin/aria* /usr/local/bin/ffm* || true
fi
- name: Install project into virtual environment
run: |
# create a venv and use it for installs to avoid modifying the system Python
python3 -m venv .venv
# activate the venv for this step
. .venv/bin/activate
python -m pip install --upgrade pip
# install/upgrade yt-dlp inside the venv to ensure it's up-to-date (fixes nsig/format issues)
python -m pip install --upgrade yt-dlp
python -m pip install -e .
# Install project in editable mode. If the 'test' extra exists, prefer it.
python -m pip install -e .[test] || python -m pip install -e .
python -m pip install pytest
- name: Run integration test
run: |
# activate the venv created earlier so tests use the upgraded yt-dlp and installed project
set -euo pipefail
. .venv/bin/activate
python3 tests/integration_full_workflow_test.py
python -m pytest -q tests/integration_full_workflow_test.py
-1
View File
@@ -3,7 +3,6 @@
#Custom for this project
config/yt-playlist-config.json
/bin/
/tmp*
# Byte-compiled / optimized / DLL files
__pycache__/