Skip to content

Commit a822167

Browse files
committed
Use cache instead of tool-cache
1 parent 086281d commit a822167

File tree

3 files changed

+12
-23
lines changed

3 files changed

+12
-23
lines changed

.github/actions/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"@actions/core": "^1.11.1",
1616
"@actions/exec": "^1.1.1",
1717
"@actions/io": "^1.1.3",
18-
"@actions/tool-cache": "^2.0.2",
1918
"lodash": "^4.17.21"
2019
},
2120
"scripts": {

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as cache from '@actions/cache';
12
import * as core from '@actions/core';
23
import { exec, getExecOutput } from '@actions/exec';
34
import * as io from '@actions/io';
@@ -13,6 +14,8 @@ interface YarnWhyEntry {
1314
};
1415
}
1516

17+
const playwrightDir = '~/.cache/ms-playwright';
18+
1619
/**
1720
* Given the output from `yarn why`, figure out what the installed version is
1821
*/
@@ -54,8 +57,9 @@ async function main() {
5457
const version = findInstalledVersion(entry);
5558
core.info(`playwright version for ${packageName} is ${version}`);
5659

57-
let playwrightDir = tc.find('playwright', version);
58-
if (!playwrightDir) {
60+
await io.mkdirP(playwrightDir);
61+
const cacheHit = await cache.restoreCache([playwrightDir], `playwright-${version}`);
62+
if (!cacheHit) {
5963
core.info('playwright directory cache not located, installing');
6064

6165
const exitCode = await exec('yarn', ['workspaces', 'foreach', '-A', '--include', packageName, 'run', 'playwright', 'install', 'chromium', '--with-deps', '--only-shell'], { silent: true });
@@ -64,11 +68,11 @@ async function main() {
6468
return;
6569
}
6670

67-
await io.mkdirP('~/.cache/ms-playwright');
68-
playwrightDir = await tc.cacheDir('~/.cache/ms-playwright', 'playwright', version);
71+
await cache.saveCache([playwrightDir], `playwright-${version}`);
72+
} else {
73+
core.info('Playwright cache hit');
6974
}
7075

71-
core.info(`Playwright directory is ${playwrightDir}`);
7276
core.addPath(playwrightDir);
7377

7478
await exec('yarn', ['workspaces', 'foreach', '-A', '--include', packageName, 'run', 'playwright', '--version']);

yarn.lock

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ __metadata:
5353
languageName: node
5454
linkType: hard
5555

56-
"@actions/exec@npm:^1.0.0, @actions/exec@npm:^1.0.1, @actions/exec@npm:^1.1.1":
56+
"@actions/exec@npm:^1.0.1, @actions/exec@npm:^1.1.1":
5757
version: 1.1.1
5858
resolution: "@actions/exec@npm:1.1.1"
5959
dependencies:
@@ -94,26 +94,13 @@ __metadata:
9494
languageName: node
9595
linkType: hard
9696

97-
"@actions/io@npm:^1.0.1, @actions/io@npm:^1.1.1, @actions/io@npm:^1.1.3":
97+
"@actions/io@npm:^1.0.1, @actions/io@npm:^1.1.3":
9898
version: 1.1.3
9999
resolution: "@actions/io@npm:1.1.3"
100100
checksum: 10c0/5b8751918e5bf0bebd923ba917fb1c0e294401e7ff0037f32c92a4efa4215550df1f6633c63fd4efb2bdaae8711e69b9e36925857db1f38935ff62a5c92ec29e
101101
languageName: node
102102
linkType: hard
103103

104-
"@actions/tool-cache@npm:^2.0.2":
105-
version: 2.0.2
106-
resolution: "@actions/tool-cache@npm:2.0.2"
107-
dependencies:
108-
"@actions/core": "npm:^1.11.1"
109-
"@actions/exec": "npm:^1.0.0"
110-
"@actions/http-client": "npm:^2.0.1"
111-
"@actions/io": "npm:^1.1.1"
112-
semver: "npm:^6.1.0"
113-
checksum: 10c0/bc04870b59b969717bdc4966fa1fca8263d5e968bfb73e5dfac02018e6180ae5752d6d209a2a1e483219325389aaf62e9f8ebb80f04d77686e386a630481adfd
114-
languageName: node
115-
linkType: hard
116-
117104
"@algolia/autocomplete-core@npm:1.17.7":
118105
version: 1.17.7
119106
resolution: "@algolia/autocomplete-core@npm:1.17.7"
@@ -3759,7 +3746,6 @@ __metadata:
37593746
"@actions/core": "npm:^1.11.1"
37603747
"@actions/exec": "npm:^1.1.1"
37613748
"@actions/io": "npm:^1.1.3"
3762-
"@actions/tool-cache": "npm:^2.0.2"
37633749
"@sourceacademy/modules-repotools": "workspace:^"
37643750
"@types/node": "npm:^22.15.30"
37653751
lodash: "npm:^4.17.21"
@@ -14581,7 +14567,7 @@ __metadata:
1458114567
languageName: node
1458214568
linkType: hard
1458314569

14584-
"semver@npm:^6.1.0, semver@npm:^6.3.0, semver@npm:^6.3.1":
14570+
"semver@npm:^6.3.0, semver@npm:^6.3.1":
1458514571
version: 6.3.1
1458614572
resolution: "semver@npm:6.3.1"
1458714573
bin:

0 commit comments

Comments
 (0)