Skip to content

Commit

Permalink
CI: Fix screenshots on Ubuntu 24.04
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mook-as committed Jan 23, 2025
1 parent 55fc4da commit e6e73c1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion screenshots/Screenshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 });
}
}
}

Expand Down

0 comments on commit e6e73c1

Please sign in to comment.