mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
ci: install ffmpeg through the GitHub API asset route with a cache (#7401)
* ci: install ffmpeg through the GitHub API asset route with a cache * ci: the three jobs without a prepared ffmpeg stop downloading ffmpeg-static from releases * ci: the ffmpeg install failure message counts its three downloads
This commit is contained in:
@@ -15,21 +15,45 @@ inputs:
|
||||
required: false
|
||||
default: 26d2ecd0cefba99f9d1ea92252a3a4f743a58df4c1c3cf9f8bbaaa40b1fca5b0
|
||||
|
||||
token:
|
||||
description: Token for the GitHub API asset route.
|
||||
required: false
|
||||
default: ${{ github.token }}
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Restore the ffmpeg tarball
|
||||
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
|
||||
with:
|
||||
path: ${{ runner.temp }}/ffmpeg-archive
|
||||
key: ffmpeg-linux-${{ inputs.sha256 }}
|
||||
- name: Install ffmpeg
|
||||
shell: bash
|
||||
env:
|
||||
URL: ${{ inputs.release-url }}
|
||||
SHA256: ${{ inputs.sha256 }}
|
||||
GH_TOKEN: ${{ inputs.token }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
archive="$RUNNER_TEMP/${URL##*/}"
|
||||
# Two attempts of at most 20 s keep the install under a minute.
|
||||
curl -fsSL --retry 1 --retry-all-errors --retry-max-time 25 --connect-timeout 10 --max-time 20 \
|
||||
--speed-limit 5000000 --speed-time 10 -o "$archive" "$URL"
|
||||
sha256sum -c --quiet <<<"$SHA256 $archive"
|
||||
name="${URL##*/}"
|
||||
repo="$(sed -E 's#^https://github.com/([^/]+/[^/]+)/releases/download/.*#\1#' <<<"$URL")"
|
||||
tag="$(sed -E 's#^.*/releases/download/([^/]+)/.*#\1#' <<<"$URL")"
|
||||
dir="$RUNNER_TEMP/ffmpeg-archive"
|
||||
archive="$dir/$name"
|
||||
mkdir -p "$dir"
|
||||
verified() { [ -f "$archive" ] && sha256sum -c --quiet <<<"$SHA256 $archive"; }
|
||||
# github.com/releases/download answers 504 under load; the API asset route does not.
|
||||
fetch() {
|
||||
local id
|
||||
id="$(gh api "repos/$repo/releases/tags/$tag" --jq ".assets[] | select(.name == \"$name\") | .id")"
|
||||
gh api -H "Accept: application/octet-stream" "repos/$repo/releases/assets/$id" > "$archive"
|
||||
}
|
||||
for attempt in 1 2 3 4; do
|
||||
verified && break
|
||||
[ "$attempt" = 4 ] && { echo "ffmpeg download failed three times" >&2; exit 1; }
|
||||
fetch || sleep $((attempt * 5))
|
||||
done
|
||||
bin="$RUNNER_TEMP/ffmpeg-bin"
|
||||
mkdir -p "$bin"
|
||||
tar -xJf "$archive" -C "$bin" --strip-components=2 --wildcards '*/bin/ffmpeg' '*/bin/ffprobe'
|
||||
|
||||
@@ -408,6 +408,8 @@ jobs:
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
||||
with:
|
||||
node-version: 22
|
||||
- uses: ./.github/actions/install-ffmpeg-linux
|
||||
- uses: ./.github/actions/prepare-ffmpeg-bin
|
||||
- run: bash scripts/ci/install-workspace-dependencies.sh
|
||||
- run: bun run --filter '@hyperframes/{parsers,lint,studio-server}' build
|
||||
- run: bun run --cwd packages/core build
|
||||
@@ -883,6 +885,8 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
||||
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
||||
- uses: ./.github/actions/install-ffmpeg-linux
|
||||
- uses: ./.github/actions/prepare-ffmpeg-bin
|
||||
- run: bash scripts/ci/install-workspace-dependencies.sh
|
||||
# Build workspace deps so the sdk's @hyperframes/parsers + core subpath
|
||||
# imports resolve via the "node" export condition (dist) under vitest.
|
||||
@@ -975,6 +979,8 @@ jobs:
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
||||
with:
|
||||
node-version: 22
|
||||
- uses: ./.github/actions/install-ffmpeg-linux
|
||||
- uses: ./.github/actions/prepare-ffmpeg-bin
|
||||
- run: bash scripts/ci/install-workspace-dependencies.sh
|
||||
# Same reason as studio-load-smoke: vite.config.ts is loaded by Node and
|
||||
# resolves the workspace packages through their "node" export condition.
|
||||
|
||||
Reference in New Issue
Block a user