From e6e73c122bd866b954bd183add19c82ba70b045e Mon Sep 17 00:00:00 2001 From: Mark Yen Date: Wed, 22 Jan 2025 15:18:08 -0800 Subject: [PATCH] CI: Fix screenshots on Ubuntu 24.04 The version of GraphicsMagick provided in Ubuntu 24.04 no longer creates the alias `import` for `gm import`. That used to exist since the ImageMagick days. Try to invoke `gm` directly if it exists, otherwise fallback to the old `import`. Signed-off-by: Mark Yen --- screenshots/Screenshots.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/screenshots/Screenshots.ts b/screenshots/Screenshots.ts index fd5fc5713af..916e013299c 100644 --- a/screenshots/Screenshots.ts +++ b/screenshots/Screenshots.ts @@ -3,6 +3,7 @@ import os from 'os'; import path from 'path'; import { expect } from '@playwright/test'; +import which from 'which'; import { NavPage } from '../e2e/pages/nav-page'; import { PreferencesPage } from '../e2e/pages/preferences'; @@ -105,7 +106,14 @@ export class Screenshots { if (!windowId) { throw new Error(`Failed to find window ID for ${ this.windowTitle }`); } - await spawnFile('import', ['-window', windowId, outPath], { stdio: this.log }); + // If `gm` is available, use `gm import`; otherwise, use `import`. + const args = ['-window', windowId, outPath]; + + if (await (which('gm', { nothrow: true }))) { + await spawnFile('gm', ['import', ...args], { stdio: this.log }); + } else { + await spawnFile('import', args, { stdio: this.log }); + } } }