Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ and this project adheres to

## [unreleased]

### Fixed

- Speed up caching and get rid of bugs and hacks on Windows.

## [2.0.9]

### Fixed

- Take the sandbox option value into account when computing the cache key
- Take the sandbox option value into account when computing the cache key.

## [2.0.8]

Expand Down
430 changes: 254 additions & 176 deletions dist/index.js

Large diffs are not rendered by default.

380 changes: 249 additions & 131 deletions dist/post/index.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions lint-fmt/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"build": "npm-run-all -p 'build:**'"
},
"dependencies": {
"@actions/cache": "3.0.6",
"@actions/cache": "3.1.4",
"@actions/core": "1.10.0",
"@actions/exec": "1.1.1",
"@actions/github": "5.1.1",
Expand All @@ -23,17 +23,17 @@
"@actions/io": "1.1.2",
"@actions/tool-cache": "2.0.1",
"cheerio": "1.0.0-rc.12",
"core-js": "3.27.2",
"core-js": "3.28.0",
"date-fns": "2.29.3",
"semver": "7.3.8",
"yaml": "2.2.1"
},
"devDependencies": {
"@tsconfig/strictest": "1.0.2",
"@types/node": "18.13.0",
"@types/node": "18.14.0",
"@types/semver": "7.3.13",
"@typescript-eslint/eslint-plugin": "5.51.0",
"@typescript-eslint/parser": "5.51.0",
"@typescript-eslint/eslint-plugin": "5.53.0",
"@typescript-eslint/parser": "5.53.0",
"@vercel/ncc": "0.36.1",
"eslint": "8.34.0",
"eslint-config-prettier": "8.6.0",
Expand Down
55 changes: 4 additions & 51 deletions src/setup-ocaml/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,9 @@ export async function installer(): Promise<void> {
core.exportVariable("MSYS", "winsymlinks:native");
}
if (platform === Platform.Win32) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const originalPath = process.env["PATH"]!.split(path.delimiter);
const msys64Path = path.join("C:", "msys64", "usr", "bin");
const patchedPath = [msys64Path, ...originalPath];
process.env["PATH"] = patchedPath.join(path.delimiter);
await restoreCygwinCache();
process.env["PATH"] = originalPath.join(path.delimiter);
}
let opamCacheHit;
if (platform === Platform.Win32) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const originalPath = process.env["PATH"]!.split(path.delimiter);
const msys64Path = path.join("C:", "msys64", "usr", "bin");
const patchedPath = [msys64Path, ...originalPath];
process.env["PATH"] = patchedPath.join(path.delimiter);
opamCacheHit = await restoreOpamCache();
process.env["PATH"] = originalPath.join(path.delimiter);
} else {
opamCacheHit = await restoreOpamCache();
}
const opamCacheHit = await restoreOpamCache();
await setupOpam();
await repositoryRemoveAll();
await repositoryAddAll(OPAM_REPOSITORIES);
Expand All @@ -100,44 +83,14 @@ export async function installer(): Promise<void> {
: `ocaml-base-compiler.${await resolveVersion(OCAML_COMPILER)}`
: OCAML_COMPILER;
await installOcaml(ocamlCompiler);
if (platform === Platform.Win32) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const originalPath = process.env["PATH"]!.split(path.delimiter);
const msys64Path = path.join("C:", "msys64", "usr", "bin");
const patchedPath = [msys64Path, ...originalPath];
process.env["PATH"] = patchedPath.join(path.delimiter);
await saveOpamCache();
process.env["PATH"] = originalPath.join(path.delimiter);
} else {
await saveOpamCache();
}
}
if (platform === Platform.Win32) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const originalPath = process.env["PATH"]!.split(path.delimiter);
const msys64Path = path.join("C:", "msys64", "usr", "bin");
const patchedPath = [msys64Path, ...originalPath];
process.env["PATH"] = patchedPath.join(path.delimiter);
await restoreOpamDownloadCache();
process.env["PATH"] = originalPath.join(path.delimiter);
} else {
await restoreOpamDownloadCache();
await saveOpamCache();
}
await restoreOpamDownloadCache();
if (OPAM_DEPEXT) {
await installDepext(platform);
}
if (DUNE_CACHE) {
if (platform === Platform.Win32) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const originalPath = process.env["PATH"]!.split(path.delimiter);
const msys64Path = path.join("C:", "msys64", "usr", "bin");
const patchedPath = [msys64Path, ...originalPath];
process.env["PATH"] = patchedPath.join(path.delimiter);
await restoreDuneCache();
process.env["PATH"] = originalPath.join(path.delimiter);
} else {
await restoreDuneCache();
}
await restoreDuneCache();
await installDune();
core.exportVariable("DUNE_CACHE", "enabled");
core.exportVariable("DUNE_CACHE_TRANSPORT", "direct");
Expand Down
8 changes: 3 additions & 5 deletions src/setup-ocaml/opam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,9 @@ async function acquireOpamWindows() {
const cachedPath = tc.find("opam", opamVersion);
if (cachedPath === "") {
const downloadedPath = await tc.downloadTool(
`https://github.com/fdopen/opam-repository-mingw/releases/download/${opamVersion}/opam64.tar.xz`
`https://github.com/fdopen/opam-repository-mingw/releases/download/${opamVersion}/opam64.zip`
);
const extractedPath = await tc.extractTar(downloadedPath, undefined, [
"xv",
]);
const extractedPath = await tc.extractZip(downloadedPath);
const cachedPath = await tc.cacheDir(extractedPath, "opam", opamVersion);
const installSh = path.join(cachedPath, "opam64", "install.sh");
await fs.chmod(installSh, 0o755);
Expand Down Expand Up @@ -257,11 +255,11 @@ async function setupOpamWindows() {
core.addPath(CYGWIN_ROOT_WRAPPERBIN);
await setupCygwin();
core.endGroup();
await saveCygwinCache();
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const originalPath = process.env["PATH"]!.split(path.delimiter);
const patchedPath = [CYGWIN_ROOT_BIN, ...originalPath];
process.env["PATH"] = patchedPath.join(path.delimiter);
await saveCygwinCache();
core.startGroup("Install opam");
await acquireOpamWindows();
core.endGroup();
Expand Down
16 changes: 1 addition & 15 deletions src/setup-ocaml/post.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
import * as path from "node:path";

import * as core from "@actions/core";

import { saveDuneCache, saveOpamDownloadCache } from "./cache";
import { DUNE_CACHE, Platform } from "./constants";
import { DUNE_CACHE } from "./constants";
import { trimDuneCache } from "./dune";
import { getPlatform } from "./system";

async function run() {
try {
const platform = getPlatform();
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const originalPath = process.env["PATH"]!.split(path.delimiter);
if (platform === Platform.Win32) {
const msys64Path = path.join("C:", "msys64", "usr", "bin");
const patchedPath = [msys64Path, ...originalPath];
process.env["PATH"] = patchedPath.join(path.delimiter);
}
if (DUNE_CACHE) {
await trimDuneCache();
await saveDuneCache();
}
await saveOpamDownloadCache();
if (platform === Platform.Win32) {
process.env["PATH"] = originalPath.join(path.delimiter);
}
} catch (error) {
if (error instanceof Error) {
core.error(error.message);
Expand Down
Loading