Skip to content

Commit df48cd6

Browse files
committed
ci: update standalone preload script
1 parent 3467955 commit df48cd6

4 files changed

Lines changed: 33 additions & 13 deletions

File tree

.github/workflows/standalone-e2e.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
env:
1111
DOCKER_IMAGE_NAME: html-reporter-browsers
12+
INTEGRATION_BROWSER_VERSION: "138.0"
1213

1314
strategy:
1415
matrix:
@@ -28,17 +29,21 @@ jobs:
2829
uses: actions/cache@v3
2930
with:
3031
path: ~/.testplane
31-
key: ${{ runner.os }}-testplane-${{ matrix.browser }}
32-
restore-keys: |
33-
${{ runner.os }}-testplane-${{ matrix.browser }}-
34-
${{ runner.os }}-testplane-
32+
key: ${{ runner.os }}-testplane-browsers-${{ matrix.browser }}-${{ env.INTEGRATION_BROWSER_VERSION }}
3533

3634
- name: Install dependencies
3735
run: npm ci
3836

3937
- name: Build project
4038
run: npm run build
4139

40+
- name: Preload Chrome browser
41+
if: ${{ matrix.browser == 'chrome' }}
42+
timeout-minutes: 4
43+
env:
44+
BROWSER: ${{ matrix.browser }}
45+
run: TS_NODE_TRANSPILE_ONLY=1 node scripts/run-node-without-type-stripping.js -r ts-node/register scripts/preload-standalone-browser.ts
46+
4247
- name: "Prepare screenshot tests: Cache browser docker image"
4348
if: ${{ matrix.browser == 'chrome' }}
4449
uses: actions/cache@v3
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { BrowserInstallStatus, installBrowsersWithDrivers } from "../src/browser-installer";
2+
import { BROWSER_NAME, BROWSER_VERSION } from "../test/integration/standalone/constants";
3+
4+
async function preloadStandaloneBrowser(): Promise<void> {
5+
const browser = { browserName: BROWSER_NAME, browserVersion: BROWSER_VERSION };
6+
const resultByBrowser = await installBrowsersWithDrivers([browser]);
7+
const browserTag = `${browser.browserName}@${browser.browserVersion}`;
8+
const result = resultByBrowser[browserTag];
9+
10+
if (result?.status !== BrowserInstallStatus.Ok) {
11+
const reason = result && "reason" in result ? `: ${result.reason}` : "";
12+
13+
throw new Error(`Failed to preload standalone browser ${browserTag}${reason}`);
14+
}
15+
}
16+
17+
(async (): Promise<void> => {
18+
await preloadStandaloneBrowser();
19+
})().catch(err => {
20+
console.error(err);
21+
process.exitCode = 1;
22+
});

test/integration/standalone/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import _ from "lodash";
22

33
export const BROWSER_NAME = (process.env.BROWSER || "chrome").toLowerCase();
4+
export const BROWSER_VERSION = process.env.INTEGRATION_BROWSER_VERSION || "138.0";
45

56
export const BROWSER_CONFIG = {
67
desiredCapabilities: {
78
browserName: BROWSER_NAME,
8-
browserVersion: "138.0",
9+
browserVersion: BROWSER_VERSION,
910
},
1011
headless: true,
1112
system: {

test/integration/standalone/preload-browser.fixture.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)