mirror of
https://github.com/video-dev/hls.js.git
synced 2026-05-17 13:30:38 +00:00
209d3a06f6
* Use BrowserStack to run macOS CI tests * Add more browserstack script targets and skip safari on assets blocking requests or failing with software aes * Pin browserstack/github-actions to v1.0.4 (93aebce225b754566349151c0676b26b005e591b)
505 lines
14 KiB
YAML
505 lines
14 KiB
YAML
name: Build
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
tags: ['v*']
|
|
pull_request:
|
|
|
|
permissions: {}
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
|
|
jobs:
|
|
config:
|
|
runs-on: ubuntu-latest
|
|
concurrency:
|
|
group: 'build:config:${{ github.ref }}'
|
|
cancel-in-progress: true
|
|
outputs:
|
|
canUseSauce: ${{ steps.check_sauce_access.outputs.result == 'true' }}
|
|
canUseBrowserStack: ${{ steps.check_browserstack_access.outputs.result == 'true' }}
|
|
tag: ${{ steps.extract_tag.outputs.result }}
|
|
isMainBranch: ${{ github.ref == 'refs/heads/master' }}
|
|
steps:
|
|
- name: check sauce access
|
|
id: check_sauce_access
|
|
run: |
|
|
if ! [[ -z "$SAUCE_USERNAME" ]] && ! [[ -z "$SAUCE_ACCESS_KEY" ]]; then
|
|
echo "result=true" >> $GITHUB_OUTPUT
|
|
fi
|
|
env:
|
|
CI: true
|
|
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
|
|
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
|
|
- name: check browserstack access
|
|
id: check_browserstack_access
|
|
run: |
|
|
if ! [[ -z "$BROWSERSTACK_USERNAME" ]] && ! [[ -z "$BROWSERSTACK_ACCESS_KEY" ]]; then
|
|
echo "result=true" >> $GITHUB_OUTPUT
|
|
fi
|
|
env:
|
|
CI: true
|
|
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
|
|
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
|
|
- name: extract tag
|
|
id: extract_tag
|
|
uses: actions/github-script@v8
|
|
with:
|
|
script: |
|
|
const prefix = 'refs/tags/';
|
|
const ref = context.ref;
|
|
return ref.startsWith(prefix) ? ref.substring(prefix.length) : '';
|
|
result-encoding: string
|
|
|
|
build:
|
|
needs: config
|
|
runs-on: ubuntu-latest
|
|
concurrency:
|
|
group: 'build:build:${{ github.ref }}'
|
|
cancel-in-progress: true
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: check package-lock.json version
|
|
uses: actions/github-script@v8
|
|
with:
|
|
script: |
|
|
const fs = require('fs');
|
|
if (
|
|
JSON.parse(fs.readFileSync('./package-lock.json', { encoding: 'utf8' }))
|
|
.lockfileVersion !== 2
|
|
) {
|
|
throw new Error(
|
|
'Expecting package-lock.json version to be 2. Please make sure you are using npm 7.'
|
|
);
|
|
}
|
|
|
|
- name: cache node_modules
|
|
uses: actions/cache@v4
|
|
env:
|
|
cache-name: cache-node-modules
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
|
${{ runner.os }}-build-
|
|
${{ runner.os }}-
|
|
|
|
- name: use Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version-file: '.node-version'
|
|
|
|
- name: install
|
|
run: |
|
|
npm ci
|
|
env:
|
|
CI: true
|
|
|
|
- name: lint
|
|
run: |
|
|
npm run lint
|
|
npm run prettier:verify
|
|
|
|
- name: set version
|
|
run: |
|
|
./scripts/set-package-version.sh
|
|
env:
|
|
CI: true
|
|
TAG: ${{ needs.config.outputs.tag }}
|
|
|
|
- name: build
|
|
run: |
|
|
npm run build:ci
|
|
npm run docs
|
|
./scripts/check-docs-built.sh
|
|
|
|
# check that hls.js doesn't error if requiring in node
|
|
# see https://github.com/video-dev/hls.js/pull/1642
|
|
node -e 'require("./" + require("./package.json").main)'
|
|
env:
|
|
CI: true
|
|
|
|
- name: upload build
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: build
|
|
# version number is set in package.json so need to include that
|
|
path: |
|
|
package.json
|
|
package-lock.json
|
|
api-docs/**
|
|
dist/**
|
|
|
|
test_unit:
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
concurrency:
|
|
group: 'build:test_unit:${{ github.ref }}'
|
|
cancel-in-progress: true
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- name: cache node_modules
|
|
uses: actions/cache@v4
|
|
env:
|
|
cache-name: cache-node-modules
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
|
${{ runner.os }}-build-
|
|
${{ runner.os }}-
|
|
|
|
- name: use Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version-file: '.node-version'
|
|
|
|
- name: download build
|
|
uses: actions/download-artifact@v5
|
|
with:
|
|
name: build
|
|
|
|
- name: install
|
|
run: |
|
|
npm ci
|
|
env:
|
|
CI: true
|
|
|
|
- name: run unit tests
|
|
run: |
|
|
npm run test:unit
|
|
env:
|
|
CI: true
|
|
|
|
cloudflare_pages:
|
|
needs: [config, test_unit]
|
|
if: needs.config.outputs.tag || needs.config.outputs.isMainBranch == 'true'
|
|
runs-on: ubuntu-latest
|
|
concurrency:
|
|
group: 'build:cloudflare_pages:${{ github.ref }}'
|
|
cancel-in-progress: true
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- name: cache node_modules
|
|
uses: actions/cache@v4
|
|
env:
|
|
cache-name: cache-node-modules
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
|
${{ runner.os }}-build-
|
|
${{ runner.os }}-
|
|
|
|
- name: use Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version-file: '.node-version'
|
|
|
|
- name: download build
|
|
uses: actions/download-artifact@v5
|
|
with:
|
|
name: build
|
|
|
|
- name: install
|
|
run: |
|
|
npm ci
|
|
env:
|
|
CI: true
|
|
|
|
- name: build for CloudFlare
|
|
run: |
|
|
./scripts/build-cloudflare.sh
|
|
env:
|
|
CI: true
|
|
|
|
- name: deploy to CloudFlare
|
|
run: |
|
|
./scripts/deploy-cloudflare.sh
|
|
env:
|
|
CI: true
|
|
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
|
|
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
|
|
update_draft_release:
|
|
needs: [config, test_unit]
|
|
if: needs.config.outputs.tag
|
|
runs-on: ubuntu-latest
|
|
concurrency:
|
|
group: 'build:update_draft_release:${{ github.ref }}'
|
|
cancel-in-progress: true
|
|
outputs:
|
|
upload_url: ${{ steps.draft_release.outputs.upload_url }}
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- name: draft release notes
|
|
id: draft_release
|
|
uses: tjenkinson/release-drafter@349214e6b3b889d8b333c012cc61a1f1753baf40
|
|
with:
|
|
tag: ${{ needs.config.outputs.tag }}
|
|
name: ${{ needs.config.outputs.tag }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
release_github:
|
|
needs: [config, test_unit, update_draft_release]
|
|
if: needs.config.outputs.tag
|
|
runs-on: ubuntu-latest
|
|
concurrency:
|
|
group: 'build:release_github:${{ github.ref }}'
|
|
cancel-in-progress: true
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- name: use Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version-file: '.node-version'
|
|
|
|
- name: download build
|
|
uses: actions/download-artifact@v5
|
|
with:
|
|
name: build
|
|
|
|
- name: build release zip
|
|
run: |
|
|
zip -r dist.zip dist
|
|
|
|
- name: upload assets to github release
|
|
uses: actions/upload-release-asset@v1
|
|
with:
|
|
upload_url: ${{ needs.update_draft_release.outputs.upload_url }}
|
|
asset_path: dist.zip
|
|
asset_name: release.zip
|
|
asset_content_type: application/zip
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
release_npm:
|
|
# npm oidc is configured for this environment
|
|
# https://docs.npmjs.com/trusted-publishers#for-github-actions
|
|
environment: release
|
|
needs: [config, test_unit]
|
|
if: needs.config.outputs.tag || needs.config.outputs.isMainBranch == 'true'
|
|
runs-on: ubuntu-latest
|
|
concurrency:
|
|
group: 'build:release_npm:${{ github.ref }}'
|
|
cancel-in-progress: true
|
|
permissions:
|
|
id-token: write
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- name: cache node_modules
|
|
uses: actions/cache@v4
|
|
env:
|
|
cache-name: cache-node-modules
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
|
${{ runner.os }}-build-
|
|
${{ runner.os }}-
|
|
|
|
- name: use Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version-file: '.node-version'
|
|
|
|
- name: download build
|
|
uses: actions/download-artifact@v5
|
|
with:
|
|
name: build
|
|
|
|
- name: install
|
|
run: |
|
|
npm ci
|
|
env:
|
|
CI: true
|
|
|
|
# Publishing with OICD needs >= 11.5.1
|
|
- name: Update npm to v11
|
|
run: npm install -g npm@11
|
|
|
|
- name: publish to npm
|
|
run: |
|
|
./scripts/publish-npm.sh
|
|
env:
|
|
CI: true
|
|
TAG: ${{ needs.config.outputs.tag }}
|
|
|
|
test_functional_required:
|
|
needs: [config, test_unit]
|
|
if: needs.config.outputs.canUseSauce == 'true'
|
|
runs-on: ubuntu-latest
|
|
concurrency:
|
|
group: 'build:test_functional_required:${{ matrix.config }}:${{ github.ref }}'
|
|
cancel-in-progress: true
|
|
name: test_functional_required (${{ matrix.config }})
|
|
strategy:
|
|
fail-fast: true
|
|
max-parallel: 8
|
|
matrix:
|
|
include:
|
|
- config: chrome-win_10
|
|
ua: chrome
|
|
os: Windows 10
|
|
- config: chrome-win_8-75.0
|
|
ua: chrome
|
|
os: Windows 8
|
|
uaVersion: '75.0'
|
|
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- name: cache node_modules
|
|
uses: actions/cache@v4
|
|
env:
|
|
cache-name: cache-node-modules
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
|
${{ runner.os }}-build-
|
|
${{ runner.os }}-
|
|
|
|
- name: use Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version-file: '.node-version'
|
|
|
|
- name: download build
|
|
uses: actions/download-artifact@v5
|
|
with:
|
|
name: build
|
|
|
|
- name: start SauceConnect tunnel
|
|
uses: saucelabs/sauce-connect-action@0ca0e6ce3a5513d6bec2a54044a536c3da3a53fb # v2
|
|
with:
|
|
username: ${{ secrets.SAUCE_USERNAME }}
|
|
accessKey: ${{ secrets.SAUCE_ACCESS_KEY }}
|
|
tunnelIdentifier: ${{ github.run_id }}-${{ matrix.config }}
|
|
retryTimeout: 300
|
|
|
|
- name: install
|
|
run: |
|
|
npm ci
|
|
env:
|
|
CI: true
|
|
|
|
- name: run functional tests
|
|
run: |
|
|
npm run test:func
|
|
npm run test:func:light
|
|
env:
|
|
CI: true
|
|
SAUCE_TUNNEL_ID: ${{ github.run_id }}-${{ matrix.config }}
|
|
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
|
|
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
|
|
UA: ${{ matrix.ua }}
|
|
UA_VERSION: ${{ matrix.uaVersion }}
|
|
OS: ${{ matrix.os }}
|
|
|
|
test_functional_optional:
|
|
needs: [config, test_functional_required]
|
|
if: needs.config.outputs.canUseBrowserStack == 'true'
|
|
runs-on: ubuntu-latest
|
|
concurrency:
|
|
group: 'build:test_functional_optional:${{ matrix.config }}:${{ github.ref }}'
|
|
cancel-in-progress: true
|
|
continue-on-error: true
|
|
name: test_functional_optional (${{ matrix.config }})
|
|
strategy:
|
|
fail-fast: false
|
|
max-parallel: 4
|
|
matrix:
|
|
include:
|
|
- config: safari-macOS_15
|
|
ua: safari
|
|
os: macOS 15
|
|
- config: chrome-macOS_14
|
|
ua: chrome
|
|
os: macOS 14
|
|
- config: firefox-macOS_15
|
|
ua: firefox
|
|
os: macOS 15
|
|
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- name: cache node_modules
|
|
uses: actions/cache@v4
|
|
env:
|
|
cache-name: cache-node-modules
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
|
${{ runner.os }}-build-
|
|
${{ runner.os }}-
|
|
|
|
- name: use Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version-file: '.node-version'
|
|
|
|
- name: download build
|
|
uses: actions/download-artifact@v5
|
|
with:
|
|
name: build
|
|
|
|
- name: setup BrowserStack env
|
|
uses: browserstack/github-actions/setup-env@93aebce225b754566349151c0676b26b005e591b # v1.0.4
|
|
with:
|
|
username: ${{ secrets.BROWSERSTACK_USERNAME }}
|
|
access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
|
|
|
|
- name: start BrowserStack Local
|
|
uses: browserstack/github-actions/setup-local@93aebce225b754566349151c0676b26b005e591b # v1.0.4
|
|
with:
|
|
local-testing: start
|
|
local-identifier: ${{ github.run_id }}-${{ matrix.config }}
|
|
|
|
- name: install
|
|
run: |
|
|
npm ci
|
|
env:
|
|
CI: true
|
|
|
|
- name: run functional tests
|
|
run: |
|
|
npm run test:func
|
|
env:
|
|
CI: true
|
|
BROWSERSTACK: 1
|
|
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
|
|
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
|
|
BROWSERSTACK_LOCAL_IDENTIFIER: ${{ github.run_id }}-${{ matrix.config }}
|
|
BROWSERSTACK_BUILD_ID: ${{ github.run_id }}-${{ matrix.config }}
|
|
UA: ${{ matrix.ua }}
|
|
UA_VERSION: ${{ matrix.uaVersion }}
|
|
OS: ${{ matrix.os }}
|
|
|
|
- name: stop BrowserStack Local
|
|
if: always()
|
|
uses: browserstack/github-actions/setup-local@93aebce225b754566349151c0676b26b005e591b # v1.0.4
|
|
with:
|
|
local-testing: stop
|