Skip to content

Commit

Permalink
Don't use msys64 tar
Browse files Browse the repository at this point in the history
Signed-off-by: Sora Morimoto <sora@morimoto.io>
  • Loading branch information
smorimoto committed Mar 26, 2021
1 parent 93455b4 commit bdd83f3
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 121 deletions.
56 changes: 18 additions & 38 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81619,11 +81619,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};
exports.__esModule = true;
exports.installer = void 0;
var core = __nccwpck_require__(2186);
Expand All @@ -81641,7 +81636,7 @@ var profiler_1 = __nccwpck_require__(1044);
var system_1 = __nccwpck_require__(4300);
function installer() {
return __awaiter(this, void 0, void 0, function () {
var platform, numberOfProcessors, isDebug, opamRoot, groupName, originalPath, msys64Path, patchedPath, cygwinVersion, originalPath, msys64Path, patchedPath, cacheHit, originalPath, msys64Path, patchedPath, originalPath, msys64Path, patchedPath, originalPath, msys64Path, patchedPath, fnames;
var platform, numberOfProcessors, isDebug, opamRoot, groupName, cygwinVersion, cacheHit, fnames;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
Expand Down Expand Up @@ -81687,28 +81682,18 @@ function installer() {
core.exportVariable("MSYS", "winsymlinks:native");
}
if (!(platform === constants_1.Platform.Win32)) return [3 /*break*/, 7];
originalPath = process.env.PATH.split(path.delimiter);
msys64Path = path.join("C:", "msys64", "usr", "bin");
patchedPath = __spreadArray([msys64Path], originalPath);
process.env.PATH = patchedPath.join(path.delimiter);
return [4 /*yield*/, opam_1.getCygwinVersion()];
case 5:
cygwinVersion = _a.sent();
return [4 /*yield*/, cache_1.restoreCygwinCache(cygwinVersion)];
case 6:
_a.sent();
process.env.PATH = originalPath.join(path.delimiter);
_a.label = 7;
case 7:
if (!(platform === constants_1.Platform.Win32)) return [3 /*break*/, 9];
originalPath = process.env.PATH.split(path.delimiter);
msys64Path = path.join("C:", "msys64", "usr", "bin");
patchedPath = __spreadArray([msys64Path], originalPath);
process.env.PATH = patchedPath.join(path.delimiter);
return [4 /*yield*/, cache_1.restoreOpamRootCache()];
case 8:
_a.sent();
process.env.PATH = originalPath.join(path.delimiter);
return [3 /*break*/, 11];
case 9: return [4 /*yield*/, cache_1.restoreOpamRootCache()];
case 10:
Expand All @@ -81718,14 +81703,9 @@ function installer() {
case 12:
_a.sent();
if (!(platform === constants_1.Platform.Win32)) return [3 /*break*/, 14];
originalPath = process.env.PATH.split(path.delimiter);
msys64Path = path.join("C:", "msys64", "usr", "bin");
patchedPath = __spreadArray([msys64Path], originalPath);
process.env.PATH = patchedPath.join(path.delimiter);
return [4 /*yield*/, cache_1.restoreOpamLocalCache()];
case 13:
cacheHit = _a.sent();
process.env.PATH = originalPath.join(path.delimiter);
return [3 /*break*/, 16];
case 14: return [4 /*yield*/, cache_1.restoreOpamLocalCache()];
case 15:
Expand All @@ -81737,14 +81717,9 @@ function installer() {
case 17:
_a.sent();
if (!(platform === constants_1.Platform.Win32)) return [3 /*break*/, 19];
originalPath = process.env.PATH.split(path.delimiter);
msys64Path = path.join("C:", "msys64", "usr", "bin");
patchedPath = __spreadArray([msys64Path], originalPath);
process.env.PATH = patchedPath.join(path.delimiter);
return [4 /*yield*/, cache_1.saveOpamLocalCache()];
case 18:
_a.sent();
process.env.PATH = originalPath.join(path.delimiter);
return [3 /*break*/, 21];
case 19: return [4 /*yield*/, cache_1.saveOpamLocalCache()];
case 20:
Expand All @@ -81755,14 +81730,9 @@ function installer() {
_a.sent();
if (!constants_1.DUNE_CACHE) return [3 /*break*/, 28];
if (!(platform === constants_1.Platform.Win32)) return [3 /*break*/, 24];
originalPath = process.env.PATH.split(path.delimiter);
msys64Path = path.join("C:", "msys64", "usr", "bin");
patchedPath = __spreadArray([msys64Path], originalPath);
process.env.PATH = patchedPath.join(path.delimiter);
return [4 /*yield*/, cache_1.restoreDuneCache()];
case 23:
_a.sent();
process.env.PATH = originalPath.join(path.delimiter);
return [3 /*break*/, 26];
case 24: return [4 /*yield*/, cache_1.restoreDuneCache()];
case 25:
Expand Down Expand Up @@ -81813,6 +81783,17 @@ exports.installer = installer;

"use strict";

var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
Expand Down Expand Up @@ -82257,18 +82238,18 @@ function setupOpam() {
exports.setupOpam = setupOpam;
function installOcaml(ocamlVersion) {
return __awaiter(this, void 0, void 0, function () {
var groupName, platform, CYGWIN_ROOT_BIN, originalPath, patchedPath;
var groupName, platform, PATH;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
groupName = "Install OCaml";
profiler_1.startProfiler(groupName);
platform = system_1.getPlatform();
if (!(platform === constants_1.Platform.Win32)) return [3 /*break*/, 2];
CYGWIN_ROOT_BIN = process.env.CYGWIN_ROOT_BIN;
originalPath = process.env.PATH.split(path.delimiter);
patchedPath = __spreadArray([CYGWIN_ROOT_BIN], originalPath);
process.env.PATH = patchedPath.join(path.delimiter);
PATH = __spreadArray([
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
process.env.CYGWIN_ROOT_BIN
], process.env.PATH.split(path.delimiter)).join(path.delimiter);
return [4 /*yield*/, exec_1.exec("opam", [
"switch",
"create",
Expand All @@ -82277,10 +82258,9 @@ function installOcaml(ocamlVersion) {
"--packages",
ocamlVersion,
"--yes",
])];
], { env: __assign(__assign({}, process.env), { PATH: PATH }) })];
case 1:
_a.sent();
process.env.PATH = originalPath.join(path.delimiter);
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, exec_1.exec("opam", [
"switch",
Expand Down
44 changes: 19 additions & 25 deletions dist/post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81407,6 +81407,17 @@ exports.trimDuneCache = trimDuneCache;

"use strict";

var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
Expand Down Expand Up @@ -81851,18 +81862,18 @@ function setupOpam() {
exports.setupOpam = setupOpam;
function installOcaml(ocamlVersion) {
return __awaiter(this, void 0, void 0, function () {
var groupName, platform, CYGWIN_ROOT_BIN, originalPath, patchedPath;
var groupName, platform, PATH;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
groupName = "Install OCaml";
profiler_1.startProfiler(groupName);
platform = system_1.getPlatform();
if (!(platform === constants_1.Platform.Win32)) return [3 /*break*/, 2];
CYGWIN_ROOT_BIN = process.env.CYGWIN_ROOT_BIN;
originalPath = process.env.PATH.split(path.delimiter);
patchedPath = __spreadArray([CYGWIN_ROOT_BIN], originalPath);
process.env.PATH = patchedPath.join(path.delimiter);
PATH = __spreadArray([
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
process.env.CYGWIN_ROOT_BIN
], process.env.PATH.split(path.delimiter)).join(path.delimiter);
return [4 /*yield*/, exec_1.exec("opam", [
"switch",
"create",
Expand All @@ -81871,10 +81882,9 @@ function installOcaml(ocamlVersion) {
"--packages",
ocamlVersion,
"--yes",
])];
], { env: __assign(__assign({}, process.env), { PATH: PATH }) })];
case 1:
_a.sent();
process.env.PATH = originalPath.join(path.delimiter);
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, exec_1.exec("opam", [
"switch",
Expand Down Expand Up @@ -81971,33 +81981,21 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};
exports.__esModule = true;
var core = __nccwpck_require__(2186);
var path = __nccwpck_require__(5622);
var cache_1 = __nccwpck_require__(4810);
var constants_1 = __nccwpck_require__(9042);
var dune_1 = __nccwpck_require__(1903);
var opam_1 = __nccwpck_require__(1078);
var system_1 = __nccwpck_require__(4300);
function run() {
return __awaiter(this, void 0, void 0, function () {
var platform, originalPath, msys64Path, patchedPath, cygwinVersion, error_1;
var platform, cygwinVersion, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 8, , 9]);
platform = system_1.getPlatform();
originalPath = process.env.PATH.split(path.delimiter);
if (platform === constants_1.Platform.Win32) {
msys64Path = path.join("C:", "msys64", "usr", "bin");
patchedPath = __spreadArray([msys64Path], originalPath);
process.env.PATH = patchedPath.join(path.delimiter);
}
if (!(platform === constants_1.Platform.Win32)) return [3 /*break*/, 3];
return [4 /*yield*/, opam_1.getCygwinVersion()];
case 1:
Expand All @@ -82017,11 +82015,7 @@ function run() {
case 6:
_a.sent();
_a.label = 7;
case 7:
if (platform === constants_1.Platform.Win32) {
process.env.PATH = originalPath.join(path.delimiter);
}
return [3 /*break*/, 9];
case 7: return [3 /*break*/, 9];
case 8:
error_1 = _a.sent();
core.error(error_1.message);
Expand Down
30 changes: 0 additions & 30 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,63 +60,33 @@ 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);
const cygwinVersion = await getCygwinVersion();
await restoreCygwinCache(cygwinVersion);
process.env.PATH = originalPath.join(path.delimiter);
}
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 restoreOpamRootCache();
process.env.PATH = originalPath.join(path.delimiter);
} else {
await restoreOpamRootCache();
}
await setupOpam();
let cacheHit;
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);
cacheHit = await restoreOpamLocalCache();
process.env.PATH = originalPath.join(path.delimiter);
} else {
cacheHit = await restoreOpamLocalCache();
}
if (!cacheHit) {
await installOcaml(OCAML_VERSION);
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 saveOpamLocalCache();
process.env.PATH = originalPath.join(path.delimiter);
} else {
await saveOpamLocalCache();
}
}
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();
}
Expand Down
36 changes: 19 additions & 17 deletions src/opam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ async function setupOpamWindows() {
startProfiler(initialiseTheOpamState);
await initializeOpamWindows();
stopProfiler(initialiseTheOpamState);

process.env.PATH = originalPath.join(path.delimiter);
}

Expand All @@ -288,22 +287,25 @@ export async function installOcaml(ocamlVersion: string): Promise<void> {
startProfiler(groupName);
const platform = getPlatform();
if (platform === Platform.Win32) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const CYGWIN_ROOT_BIN = process.env.CYGWIN_ROOT_BIN!;
// 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 exec("opam", [
"switch",
"create",
".",
"--no-install",
"--packages",
ocamlVersion,
"--yes",
]);
process.env.PATH = originalPath.join(path.delimiter);
const PATH = [
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
process.env.CYGWIN_ROOT_BIN!,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
...process.env.PATH!.split(path.delimiter),
].join(path.delimiter);
await exec(
"opam",
[
"switch",
"create",
".",
"--no-install",
"--packages",
ocamlVersion,
"--yes",
],
{ env: { ...process.env, PATH } }
);
} else {
await exec("opam", [
"switch",
Expand Down
11 changes: 0 additions & 11 deletions src/post.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as core from "@actions/core";
import * as path from "path";

import { saveCygwinCache, saveDuneCache, saveOpamRootCache } from "./cache";
import { DUNE_CACHE, Platform } from "./constants";
Expand All @@ -10,13 +9,6 @@ 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 (platform === Platform.Win32) {
const cygwinVersion = await getCygwinVersion();
await saveCygwinCache(cygwinVersion);
Expand All @@ -26,9 +18,6 @@ async function run() {
await trimDuneCache();
await saveDuneCache();
}
if (platform === Platform.Win32) {
process.env.PATH = originalPath.join(path.delimiter);
}
} catch (error) {
core.error(error.message);
}
Expand Down

0 comments on commit bdd83f3

Please sign in to comment.