mirror of
https://github.com/videojs/video.js.git
synced 2026-11-20 06:29:27 +01:00
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
316 lines
9.6 KiB
YAML
316 lines
9.6 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches-ignore:
|
|
- 'rfc/**'
|
|
|
|
concurrency:
|
|
group: ci-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
# Every job installs from the pnpm store cache on its own. A shared warm-up job would only help the rare lockfile
|
|
# change, and gating on it costs every run the warm-up's wall time; on a miss the parallel installs race to save the
|
|
# cache and the losers log a warning.
|
|
jobs:
|
|
package_test_selection:
|
|
name: Select package tests
|
|
runs-on: blacksmith-2vcpu-ubuntu-2404
|
|
outputs:
|
|
has_standard_tests: ${{ steps.selection.outputs.has_standard_tests }}
|
|
matrix: ${{ steps.selection.outputs.matrix }}
|
|
run_spf: ${{ steps.selection.outputs.run_spf }}
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version-file: '.nvmrc'
|
|
package-manager-cache: false
|
|
|
|
- name: Test package selector
|
|
run: node --test .github/scripts/tests/package-test-matrix.test.js
|
|
|
|
- name: Select affected package tests
|
|
id: selection
|
|
env:
|
|
CHANGED_FILE_COUNT: ${{ github.event.pull_request.changed_files }}
|
|
EVENT_NAME: ${{ github.event_name }}
|
|
GH_TOKEN: ${{ github.token }}
|
|
GH_REPO: ${{ github.repository }}
|
|
NUMBER: ${{ github.event.pull_request.number }}
|
|
run: |
|
|
if [[ "$EVENT_NAME" == "pull_request" && "$CHANGED_FILE_COUNT" -lt 3000 ]]; then
|
|
selection=$(
|
|
gh api "repos/$GH_REPO/pulls/$NUMBER/files" --paginate \
|
|
--jq '.[] | .filename, (.previous_filename // empty)' |
|
|
node .github/scripts/package-test-matrix.js
|
|
)
|
|
else
|
|
selection=$(node .github/scripts/package-test-matrix.js --all)
|
|
fi
|
|
|
|
jq . <<<"$selection"
|
|
{
|
|
echo "has_standard_tests=$(jq -r '.hasStandardTests' <<<"$selection")"
|
|
echo "matrix=$(jq -c '.matrix' <<<"$selection")"
|
|
echo "run_spf=$(jq -r '.runSpf' <<<"$selection")"
|
|
} >> "$GITHUB_OUTPUT"
|
|
|
|
lint:
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v6.1.0
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version-file: '.nvmrc'
|
|
cache: pnpm
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile --prefer-offline
|
|
|
|
- name: Lint
|
|
run: pnpm lint
|
|
|
|
- name: Test lint rules
|
|
run: pnpm exec vp test run tools/oxlint/anti-slop/rules/tests tools/oxlint/videojs/rules/tests
|
|
|
|
- name: Test inline template transformation
|
|
run: pnpm exec node --import tsx --test build/plugins/tests/inline-template-plugin.test.ts
|
|
|
|
typecheck:
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v6.1.0
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version-file: '.nvmrc'
|
|
cache: pnpm
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile --prefer-offline
|
|
|
|
- name: Restore Vite Task cache
|
|
uses: actions/cache/restore@v6
|
|
with:
|
|
path: node_modules/.vite/task-cache
|
|
key: vite-task-${{ runner.os }}-${{ runner.arch }}-restore-only-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}
|
|
restore-keys: |
|
|
vite-task-${{ runner.os }}-${{ runner.arch }}-packages-
|
|
|
|
- name: Build packages for type resolution
|
|
run: pnpm build:packages
|
|
|
|
- name: Typecheck
|
|
run: pnpm typecheck
|
|
|
|
# The SPF API reference is generated from the sources and committed. It also reads
|
|
# the declarations of the packages SPF depends on, so it runs whenever the selector
|
|
# marks SPF affected, which includes those packages changing. Non-blocking: a
|
|
# dependency's doc change should flag the stale pages, not fail its author's PR.
|
|
spf-reference:
|
|
needs: package_test_selection
|
|
if: needs.package_test_selection.outputs.run_spf == 'true'
|
|
name: SPF API reference
|
|
runs-on: ubuntu-latest
|
|
continue-on-error: true
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v6.1.0
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version-file: '.nvmrc'
|
|
cache: pnpm
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile --prefer-offline
|
|
|
|
- name: Restore Vite Task cache
|
|
uses: actions/cache/restore@v6
|
|
with:
|
|
path: node_modules/.vite/task-cache
|
|
key: vite-task-${{ runner.os }}-${{ runner.arch }}-restore-only-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}
|
|
restore-keys: |
|
|
vite-task-${{ runner.os }}-${{ runner.arch }}-packages-
|
|
|
|
- name: Build SPF and its dependencies
|
|
run: pnpm exec vp run @videojs/spf#build
|
|
|
|
- name: Check the SPF API reference is current
|
|
run: pnpm -F @videojs/spf docs:reference:check
|
|
|
|
test:
|
|
needs: package_test_selection
|
|
if: needs.package_test_selection.outputs.has_standard_tests == 'true'
|
|
name: Test packages (${{ matrix.name }})
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
strategy:
|
|
fail-fast: false
|
|
matrix: ${{ fromJSON(needs.package_test_selection.outputs.matrix) }}
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v6.1.0
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version-file: '.nvmrc'
|
|
cache: pnpm
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile --prefer-offline
|
|
|
|
- name: Restore Vite Task cache
|
|
uses: actions/cache/restore@v6
|
|
with:
|
|
path: node_modules/.vite/task-cache
|
|
key: vite-task-${{ runner.os }}-${{ runner.arch }}-restore-only-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}
|
|
restore-keys: |
|
|
vite-task-${{ runner.os }}-${{ runner.arch }}-packages-
|
|
|
|
- name: Test packages
|
|
env:
|
|
PACKAGES: ${{ toJSON(matrix.packages) }}
|
|
run: |
|
|
filters=()
|
|
while IFS= read -r package; do
|
|
filters+=(--filter "$package")
|
|
done < <(jq -r '.[]' <<<"$PACKAGES")
|
|
|
|
.github/scripts/run-logged.sh test-packages pnpm exec vp run --fail-if-no-match "${filters[@]}" test:ci
|
|
|
|
test-spf:
|
|
needs: package_test_selection
|
|
if: needs.package_test_selection.outputs.run_spf == 'true'
|
|
name: Test (@videojs/spf)
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
container:
|
|
image: mcr.microsoft.com/playwright:v1.59.1-noble
|
|
env:
|
|
PLAYWRIGHT_BROWSERS_PATH: /ms-playwright
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v6.1.0
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version-file: '.nvmrc'
|
|
cache: pnpm
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile --prefer-offline
|
|
|
|
- name: Restore Vite Task cache
|
|
uses: actions/cache/restore@v6
|
|
with:
|
|
path: node_modules/.vite/task-cache
|
|
key: vite-task-${{ runner.os }}-${{ runner.arch }}-restore-only-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}
|
|
restore-keys: |
|
|
vite-task-${{ runner.os }}-${{ runner.arch }}-packages-
|
|
|
|
- name: Test SPF
|
|
run: .github/scripts/run-logged.sh test-spf pnpm exec vp run @videojs/spf#test:ci
|
|
|
|
workspace:
|
|
runs-on: blacksmith-2vcpu-ubuntu-2404
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v6.1.0
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version-file: '.nvmrc'
|
|
cache: pnpm
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile --prefer-offline
|
|
|
|
- name: Check workspace consistency
|
|
run: pnpm check:workspace
|
|
|
|
build:
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v6.1.0
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version-file: '.nvmrc'
|
|
cache: pnpm
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile --prefer-offline
|
|
|
|
- name: Restore Vite Task cache
|
|
id: vite-task-cache
|
|
uses: actions/cache/restore@v6
|
|
with:
|
|
path: node_modules/.vite/task-cache
|
|
key: vite-task-${{ runner.os }}-${{ runner.arch }}-packages-${{ github.run_id }}-${{ github.run_attempt }}
|
|
restore-keys: |
|
|
vite-task-${{ runner.os }}-${{ runner.arch }}-packages-
|
|
|
|
- name: Build
|
|
run: pnpm build:packages
|
|
|
|
- name: Build CDN bundles
|
|
run: pnpm build:cdn
|
|
|
|
# Mirroring @videojs/cdn onto another origin is supported, so the output must not
|
|
# reference an external CDN or resolve outside the directory.
|
|
- name: Check CDN bundles are self-contained
|
|
run: pnpm -F @videojs/cdn check:cdn
|
|
|
|
- name: Save Vite Task cache
|
|
if: success()
|
|
uses: actions/cache/save@v6
|
|
with:
|
|
path: node_modules/.vite/task-cache
|
|
key: ${{ steps.vite-task-cache.outputs.cache-primary-key }}
|