mirror of
https://github.com/yt-dlp/ejs.git
synced 2026-06-13 00:32:11 +00:00
Add Python module test (#17)
This commit is contained in:
52
.github/workflows/ci.yml
vendored
52
.github/workflows/ci.yml
vendored
@@ -31,8 +31,40 @@ concurrency:
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
jobs:
|
||||
python_tests:
|
||||
name: Python tests
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14', pypy-3.11]
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Install Deno v2.x (latest)
|
||||
uses: denoland/setup-deno@v2
|
||||
with:
|
||||
deno-version: v2.x
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Build project
|
||||
run: |
|
||||
# `pip install -e` omits the force-included JS, so use `build` instead
|
||||
python -m pip install -U build
|
||||
python -m build
|
||||
unzip -u dist/yt_dlp_ejs-*.whl "yt_dlp_ejs/*"
|
||||
- name: Run Python tests
|
||||
timeout-minutes: 5
|
||||
run: |
|
||||
python -m unittest
|
||||
# python -Werror -m unittest
|
||||
|
||||
prepare:
|
||||
name: Prepare
|
||||
name: Prepare JS runtime tests
|
||||
needs: [python_tests]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
@@ -95,6 +127,12 @@ jobs:
|
||||
- name: Test Deno build
|
||||
run: |
|
||||
python -m build
|
||||
- name: Verify artifact contents
|
||||
run: |
|
||||
tar -tvzf dist/yt_dlp_ejs-*.tar.gz
|
||||
unzip -l dist/yt_dlp_ejs-*.whl | tee .wheel_contents
|
||||
grep -q 'yt_dlp_ejs/yt/solver/core\.min\.js' .wheel_contents
|
||||
grep -q 'yt_dlp_ejs/yt/solver/lib\.min\.js' .wheel_contents
|
||||
- name: Install Deno requirements
|
||||
run: |
|
||||
deno install
|
||||
@@ -156,6 +194,12 @@ jobs:
|
||||
- name: Test Bun build
|
||||
run: |
|
||||
python -m build
|
||||
- name: Verify artifact contents
|
||||
run: |
|
||||
tar -tvzf dist/yt_dlp_ejs-*.tar.gz
|
||||
unzip -l dist/yt_dlp_ejs-*.whl | tee .wheel_contents
|
||||
grep -q 'yt_dlp_ejs/yt/solver/core\.min\.js' .wheel_contents
|
||||
grep -q 'yt_dlp_ejs/yt/solver/lib\.min\.js' .wheel_contents
|
||||
- name: Install Bun requirements
|
||||
run: |
|
||||
bun install
|
||||
@@ -215,6 +259,12 @@ jobs:
|
||||
- name: Test Node build
|
||||
run: |
|
||||
python -m build
|
||||
- name: Verify artifact contents
|
||||
run: |
|
||||
tar -tvzf dist/yt_dlp_ejs-*.tar.gz
|
||||
unzip -l dist/yt_dlp_ejs-*.whl | tee .wheel_contents
|
||||
grep -q 'yt_dlp_ejs/yt/solver/core\.min\.js' .wheel_contents
|
||||
grep -q 'yt_dlp_ejs/yt/solver/lib\.min\.js' .wheel_contents
|
||||
- name: Install Node requirements
|
||||
run: |
|
||||
npm install
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,3 +6,4 @@
|
||||
/deno.lock
|
||||
/package-lock.json
|
||||
/.idea
|
||||
/.venv
|
||||
|
||||
@@ -2,7 +2,6 @@ import os
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
|
||||
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
|
||||
|
||||
|
||||
@@ -31,8 +30,10 @@ class CustomBuildHook(BuildHookInterface):
|
||||
"One of 'deno', 'bun', or 'npm' could not be found. "
|
||||
"Please install one of them to proceed with the build.")
|
||||
|
||||
build_data["force_include"]["dist/yt.solver.core.min.js"] = "yt_dlp_ejs/yt/solver/core.min.js"
|
||||
build_data["force_include"]["dist/yt.solver.lib.min.js"] = "yt_dlp_ejs/yt/solver/lib.min.js"
|
||||
build_data["force_include"].update({
|
||||
"dist/yt.solver.core.min.js": "yt_dlp_ejs/yt/solver/core.min.js",
|
||||
"dist/yt.solver.lib.min.js": "yt_dlp_ejs/yt/solver/lib.min.js",
|
||||
})
|
||||
|
||||
def clean(self, versions):
|
||||
shutil.rmtree('node_modules', ignore_errors=True)
|
||||
shutil.rmtree("node_modules", ignore_errors=True)
|
||||
|
||||
@@ -44,6 +44,9 @@ exclude = [
|
||||
"/src/yt/solver/test/players/*",
|
||||
]
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["yt_dlp_ejs"]
|
||||
|
||||
[tool.hatch.build.hooks.vcs]
|
||||
version-file = "yt_dlp_ejs/_version.py"
|
||||
|
||||
|
||||
0
test/__init__.py
Normal file
0
test/__init__.py
Normal file
18
test/test_modules.py
Normal file
18
test/test_modules.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import yt_dlp_ejs.yt.solver
|
||||
|
||||
BASE_PATH = Path(__file__).parent.parent
|
||||
CORE_PATH = BASE_PATH / 'yt_dlp_ejs/yt/solver/core.min.js'
|
||||
LIB_PATH = BASE_PATH / 'yt_dlp_ejs/yt/solver/lib.min.js'
|
||||
|
||||
|
||||
class TestModules(unittest.TestCase):
|
||||
def test_yt_solver(self):
|
||||
self.assertEqual(yt_dlp_ejs.yt.solver.core(), CORE_PATH.read_text(encoding='utf-8'))
|
||||
self.assertEqual(yt_dlp_ejs.yt.solver.lib(), LIB_PATH.read_text(encoding='utf-8'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user