Skip to content

The open-source full-stack studio for Opus 5.5 motion video. Reverse engineering for any video. Code video with HTML: recreate, edit and render. BYOA + BYOK · Motion.md · Images, Video, Music & Voice.

fix(ci): reuse installed rendering tools and bound apt requests

罗高b0dd9ddd4af1
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e1847283..cbebd710 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -87,8 +87,17 @@ jobs:
run: |
# The hosted Ubuntu image provides Chrome; Ubuntu's chromium package pulls a desktop snap.
"$HYPERFRAMES_BROWSER_PATH" --version
- sudo apt-get update -qq
- sudo apt-get install -y -qq --no-install-recommends zip unzip ffmpeg fonts-noto-core
+ missing=()
+ for package in zip unzip ffmpeg fonts-noto-core; do
+ if [ "$(dpkg-query -W -f='${Status}' "$package" 2>/dev/null)" != 'install ok installed' ]; then
+ missing+=("$package")
+ fi
+ done
+ if ((${#missing[@]})); then
+ apt_options=(-o Acquire::Retries=2 -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30)
+ sudo apt-get "${apt_options[@]}" update
+ sudo apt-get "${apt_options[@]}" install -y --no-install-recommends "${missing[@]}"
+ fi
- name: Validate manual package selection
env:
PACKAGE_FORMAT: ${{ inputs.format || 'npm' }}
diff --git a/.github/workflows/motion-candidate.yml b/.github/workflows/motion-candidate.yml
index 082bfaa4..9e0c9b2d 100644
--- a/.github/workflows/motion-candidate.yml
+++ b/.github/workflows/motion-candidate.yml
@@ -59,8 +59,17 @@ jobs:
run: |
# The hosted Ubuntu image provides Chrome; avoid Ubuntu's desktop Chromium snap.
"$HYPERFRAMES_BROWSER_PATH" --version
- sudo apt-get update -qq
- sudo apt-get install -y -qq --no-install-recommends zip unzip ffmpeg fonts-noto-core
+ missing=()
+ for package in zip unzip ffmpeg fonts-noto-core; do
+ if [ "$(dpkg-query -W -f='${Status}' "$package" 2>/dev/null)" != 'install ok installed' ]; then
+ missing+=("$package")
+ fi
+ done
+ if ((${#missing[@]})); then
+ apt_options=(-o Acquire::Retries=2 -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30)
+ sudo apt-get "${apt_options[@]}" update
+ sudo apt-get "${apt_options[@]}" install -y --no-install-recommends "${missing[@]}"
+ fi
- name: Check the selected source
working-directory: source
run: |
diff --git a/tests/release-workflows.test.mjs b/tests/release-workflows.test.mjs
index 6097dfc0..aec9ca47 100644
--- a/tests/release-workflows.test.mjs
+++ b/tests/release-workflows.test.mjs
@@ -285,6 +285,32 @@ test('daily build and publication are separate manual entries without an indepen
assert(recovery.includes('uses: ./.github/workflows/motion-publish-test.yml') && !recovery.includes('source_sha:'));
});
+test('rendering tools reuse installed packages, bound apt networking and stop on installation failure', async t => {
+ const directory = await mkdtemp(path.join(os.tmpdir(), 'motion-render-tools-'));
+ t.after(() => rm(directory, { recursive: true, force: true }));
+ const workflow = await readFile(new URL('../.github/workflows/motion-candidate.yml', import.meta.url), 'utf8');
+ const step = workflow.split(' - name: Install rendering test tools\n')[1].split('\n - name: ')[0];
+ const script = step.split(' run: |\n')[1].split('\n').map(line => line.replace(/^ {10}/, '')).join('\n');
+ const calls = path.join(directory, 'apt-calls');
+ const mock = `dpkg-query() { if [[ "$MISSING_FONT" == 1 && "$*" == *fonts-noto-core* ]]; then return 1; fi; printf 'install ok installed'; }
+sudo() { printf '%s\\n' "$*" >> "$APT_CALLS"; [[ "$FAIL_APT" != 1 ]]; }`;
+ const env = { ...process.env, APT_CALLS: calls, HYPERFRAMES_BROWSER_PATH: '/usr/bin/true', FAIL_APT: '0' };
+ for (const missing of ['0', '1']) {
+ await writeFile(calls, '');
+ await runFile('bash', ['-e', '-o', 'pipefail', '-c', mock + '\n' + script], { env: { ...env, MISSING_FONT: missing } });
+ const commands = (await readFile(calls, 'utf8')).trim().split('\n').filter(Boolean);
+ assert.equal(commands.length, missing === '1' ? 2 : 0);
+ if (missing === '1') {
+ assert(commands.every(command => command.includes('Acquire::Retries=2') && command.includes('Acquire::http::Timeout=30') && command.includes('Acquire::https::Timeout=30')));
+ assert(commands[0].endsWith(' update'));
+ assert(commands[1].endsWith(' install -y --no-install-recommends fonts-noto-core'));
+ }
+ }
+ await writeFile(calls, '');
+ await assert.rejects(runFile('bash', ['-e', '-o', 'pipefail', '-c', mock + '\n' + script], { env: { ...env, MISSING_FONT: '1', FAIL_APT: '1' } }));
+ assert.equal((await readFile(calls, 'utf8')).trim().split('\n').length, 1, 'Failed apt update must not continue');
+});
+
function storage(candidate) {
const objects = new Map([['open-motion/dev/install.md', Buffer.from('# Install OpenMotion 0.6.4-test.1\n')]]), writes = [], reads = [];
let failKey;