Skip to content

Commit 9122f93

Browse files
committed
Try playwright tool caching
1 parent df25d9b commit 9122f93

File tree

1 file changed

+16
-2
lines changed
  • .github/actions/src/playwright-cache

1 file changed

+16
-2
lines changed

.github/actions/src/playwright-cache/index.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as core from '@actions/core';
2-
import { getExecOutput } from '@actions/exec';
2+
import { exec, getExecOutput } from '@actions/exec';
33
import * as tc from '@actions/tool-cache';
44

55
interface YarnWhyEntry {
@@ -53,9 +53,23 @@ async function main() {
5353
const version = findInstalledVersion(entry);
5454
core.info(`playwright version for ${packageName} is ${version}`);
5555

56-
const playwrightDir = tc.find('playwright', version);
56+
let playwrightDir = tc.find('playwright', version);
57+
if (!playwrightDir) {
58+
core.info('playwright directory cache not located, installing');
59+
60+
const exitCode = await exec('yarn', ['playwright', 'install', 'chromium', '--with-deps', '--shell-only']);
61+
if (exitCode !== 0) {
62+
core.setFailed('Failed to install playwright');
63+
return;
64+
}
65+
66+
playwrightDir = await tc.cacheDir('~/.cache/ms-playwright', 'playwright', version);
67+
}
5768

5869
core.info(`Playwright directory is ${playwrightDir}`);
70+
core.addPath(playwrightDir);
71+
72+
await exec('yarn', ['playwright', '--version']);
5973
}
6074

6175
try {

0 commit comments

Comments
 (0)