Use pnpm binary if available
#103
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| paths-ignore: | |
| - 'README.md' | |
| - 'LICENSE' | |
| pull_request: | |
| paths-ignore: | |
| - 'README.md' | |
| - 'LICENSE' | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ci-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| ruff-format: | |
| name: Ruff format check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: astral-sh/ruff-action@v3 | |
| with: | |
| args: "check --output-format github" | |
| ruff-lint: | |
| name: Ruff linting check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: astral-sh/ruff-action@v3 | |
| with: | |
| args: "format --check --diff" | |
| prettier: | |
| name: Prettier check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install Deno v2.x (latest) | |
| uses: denoland/setup-deno@v2 | |
| with: | |
| deno-version: v2.x | |
| - name: Install requirements | |
| run: | | |
| python pnpm.py install --frozen-lockfile | |
| - name: Run Prettier check | |
| run: | | |
| python pnpm.py fmt:check | |
| eslint: | |
| name: ESLint check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install Deno v2.x (latest) | |
| uses: denoland/setup-deno@v2 | |
| with: | |
| deno-version: v2.x | |
| - name: Install requirements | |
| run: | | |
| python pnpm.py install --frozen-lockfile | |
| - name: Run ESLint check | |
| run: | | |
| python pnpm.py lint | |
| python_tests: | |
| name: Python tests | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| runner: [ubuntu-latest, windows-latest] | |
| 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 | |
| - name: Unpack wheel (Linux) | |
| if: matrix.runner == 'ubuntu-latest' | |
| run: | | |
| unzip -u dist/yt_dlp_ejs-*.whl "yt_dlp_ejs/*" | |
| - name: Unpack wheel (Windows) | |
| if: matrix.runner == 'windows-latest' | |
| shell: pwsh | |
| run: | | |
| Expand-Archive -Path dist/yt_dlp_ejs-*.whl -DestinationPath ./ -Force | |
| - name: Run Python tests | |
| timeout-minutes: 5 | |
| run: | | |
| python -Werror -m unittest | |
| prepare: | |
| name: Prepare JS runtime tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: pnpm/action-setup@v4 # respects packageManager version in package.json | |
| - name: Install requirements | |
| run: | | |
| python pnpm.py install --frozen-lockfile | |
| - name: Build control bundle | |
| run: | | |
| python pnpm.py run bundle | |
| - name: Generate bundle hashes | |
| run: | | |
| pushd dist | |
| sha256sum -- yt.solver.*.js | tee SHA2-256SUMS | |
| popd | |
| - name: Upload bundle hashes | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bundle-hashes | |
| path: | | |
| dist/SHA2-256SUMS | |
| compression-level: 0 | |
| - name: Cache player JS files | |
| uses: actions/cache@v4 | |
| env: | |
| SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1 | |
| with: | |
| path: | | |
| src/yt/solver/test/players | |
| key: test-player-js-${{ hashFiles('src/yt/solver/test/tests.ts') }} | |
| - name: Download player JS files | |
| run: | | |
| deno run \ | |
| --no-prompt \ | |
| --allow-read=src/yt/solver/test/players/ \ | |
| --allow-write=src/yt/solver/test/players/ \ | |
| --allow-net=www.youtube.com \ | |
| --allow-sys=uid \ | |
| src/yt/solver/test/download.ts | |
| - name: Upload player JS artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: player-js | |
| path: | | |
| src/yt/solver/test/players/* | |
| compression-level: 0 | |
| deno_build: | |
| name: Test Deno build | |
| needs: [prepare] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install Deno | |
| uses: denoland/setup-deno@v2 | |
| with: | |
| deno-version: "2.0.0" # minimum supported version | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.10" # minimum supported version | |
| - name: Install Python requirements | |
| run: | | |
| python -m pip install -U build | |
| - 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: | | |
| python pnpm.py install --frozen-lockfile | |
| - name: Bundle with Deno | |
| run: | | |
| deno task bundle | |
| - name: Download bundle hashes | |
| uses: actions/download-artifact@v5 | |
| with: | |
| path: dist | |
| name: bundle-hashes | |
| - name: Verify bundle hashes | |
| run: | | |
| cd dist | |
| sha256sum -c SHA2-256SUMS | |
| deno_tests: | |
| name: Run Deno tests | |
| needs: [prepare] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install Deno | |
| uses: denoland/setup-deno@v2 | |
| with: | |
| deno-version: "2.0.0" # minimum supported version | |
| - name: Install Deno requirements | |
| run: | | |
| python pnpm.py install --frozen-lockfile | |
| - name: Download player JS artifact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| path: src/yt/solver/test/players | |
| name: player-js | |
| - name: Run Deno tests | |
| run: | | |
| deno test \ | |
| --no-prompt \ | |
| --allow-read=src/yt/solver/test/players/ | |
| bun_build: | |
| name: Test Bun build | |
| needs: [prepare] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: "1.0.31" # minimum supported version | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.10" # minimum supported version | |
| - name: Install Python requirements | |
| run: | | |
| python -m pip install -U build | |
| - 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: | | |
| python pnpm.py install --frozen-lockfile | |
| - name: Bundle with Bun | |
| run: | | |
| bun --bun run bundle | |
| - name: Download bundle hashes | |
| uses: actions/download-artifact@v5 | |
| with: | |
| path: dist | |
| name: bundle-hashes | |
| - name: Verify bundle hashes | |
| run: | | |
| cd dist | |
| sha256sum -c SHA2-256SUMS | |
| bun_tests: | |
| name: Run Bun tests | |
| needs: [prepare] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: "1.2.11" # XXX: We support 1.0.31, but test suite requires 1.2.11+ | |
| - name: Install Bun requirements | |
| run: | | |
| python pnpm.py install --frozen-lockfile | |
| - name: Download player JS artifact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| path: src/yt/solver/test/players | |
| name: player-js | |
| - name: Run Bun tests | |
| run: | | |
| bun test | |
| node_build: | |
| name: Test Node build | |
| needs: [prepare] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install Node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: "20.0" # minimum supported version | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.10" # minimum supported version | |
| - name: Install Python requirements | |
| run: | | |
| python -m pip install -U build | |
| - 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: | | |
| python pnpm.py install --frozen-lockfile | |
| - name: Bundle with Node | |
| run: | | |
| npm run bundle | |
| - name: Download bundle hashes | |
| uses: actions/download-artifact@v5 | |
| with: | |
| path: dist | |
| name: bundle-hashes | |
| - name: Verify bundle hashes | |
| run: | | |
| cd dist | |
| sha256sum -c SHA2-256SUMS | |
| node_tests: | |
| name: Run Node tests | |
| needs: [prepare] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install Node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: "22.18" # XXX: We support 20.0, but test suite requires 22.18+ | |
| - name: Install Node requirements | |
| run: | | |
| python pnpm.py install --frozen-lockfile | |
| - name: Download player JS artifact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| path: src/yt/solver/test/players | |
| name: player-js | |
| - name: Run Node tests | |
| run: | | |
| node --test | |
| all_passed: | |
| needs: | |
| - ruff-format | |
| - ruff-lint | |
| - prettier | |
| - eslint | |
| - python_tests | |
| - deno_build | |
| - deno_tests | |
| - bun_build | |
| - bun_tests | |
| - node_build | |
| - node_tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: All checks passed | |
| run: | | |
| echo "All checks passed!" |