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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This action runs cached `esy install` and `esy build` in the current directory
`${{ hashFiles('esy.lock/index.json') }}`
- `esy-prefix`: The prefix of esy folder
- `working-directory`: Working directory.
- `manifest`: JSON or opam file to be used

## Example usage

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ inputs:
esy-prefix:
description: Prefix of esy folder
required: false
manifest:
description: JSON or opam file to be used
required: false
runs:
using: node12
main: dist/index.js
Expand Down
19 changes: 15 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48437,6 +48437,13 @@ 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 __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
exports.__esModule = true;
var cache = __webpack_require__(7799);
var core = __webpack_require__(2186);
Expand All @@ -48446,6 +48453,7 @@ var os = __webpack_require__(2087);
var path = __webpack_require__(5622);
var esyPrefix = core.getInput("esy-prefix");
var cacheKey = core.getInput("cache-key");
var manifestKey = core.getInput("manifest");
function run(name, command, args) {
return __awaiter(this, void 0, void 0, function () {
var PATH;
Expand All @@ -48463,6 +48471,9 @@ function run(name, command, args) {
});
});
}
function runEsyCommand(name, args) {
return run(name, "esy", manifestKey ? __spreadArrays(["@" + manifestKey], args) : args);
}
function main() {
return __awaiter(this, void 0, void 0, function () {
var workingDirectory, platform, installPath, installKey, installCacheKey, ESY_FOLDER, esy3, depsPath, buildKey, restoreKeys, buildCacheKey, e_1;
Expand All @@ -48484,7 +48495,7 @@ function main() {
console.log("Restored the install cache");
}
core.endGroup();
return [4 /*yield*/, run("Run esy install", "esy", ["install"])];
return [4 /*yield*/, runEsyCommand("Run esy install", ["install"])];
case 2:
_a.sent();
if (!(installCacheKey != installKey)) return [3 /*break*/, 4];
Expand All @@ -48511,11 +48522,11 @@ function main() {
}
core.endGroup();
if (!!buildCacheKey) return [3 /*break*/, 7];
return [4 /*yield*/, run("Run esy build-dependencies", "esy", ["build-dependencies"])];
return [4 /*yield*/, runEsyCommand("Run esy build-dependencies", ["build-dependencies"])];
case 6:
_a.sent();
_a.label = 7;
case 7: return [4 /*yield*/, run("Run esy build", "esy", ["build"])];
case 7: return [4 /*yield*/, runEsyCommand("Run esy build", ["build"])];
case 8:
_a.sent();
if (!(buildCacheKey != buildKey)) return [3 /*break*/, 10];
Expand All @@ -48524,7 +48535,7 @@ function main() {
_a.sent();
_a.label = 10;
case 10:
if (!!buildCacheKey) return [3 /*break*/, 12];
if (!(!manifestKey && !buildCacheKey)) return [3 /*break*/, 12];
return [4 /*yield*/, run("Run esy cleanup", "esy", ["cleanup", "."])];
case 11:
_a.sent();
Expand Down
13 changes: 9 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ import * as path from "path";

const esyPrefix = core.getInput("esy-prefix");
const cacheKey = core.getInput("cache-key");
const manifestKey = core.getInput("manifest");

async function run(name: string, command: string, args: string[]) {
const PATH = process.env.PATH ? process.env.PATH : "";
core.startGroup(name);
await exec(command, args, { env: { ...process.env, PATH } });
core.endGroup();
}
function runEsyCommand(name: string, args: string[]) {
return run(name, "esy", manifestKey ? [`@${manifestKey}`, ...args] : args);
}

async function main() {
try {
Expand All @@ -36,7 +40,7 @@ async function main() {
}
core.endGroup();

await run("Run esy install", "esy", ["install"]);
await runEsyCommand("Run esy install", ["install"]);

if (installCacheKey != installKey) {
await cache.saveCache(installPath, installKey);
Expand Down Expand Up @@ -65,16 +69,17 @@ async function main() {
core.endGroup();

if (!buildCacheKey) {
await run("Run esy build-dependencies", "esy", ["build-dependencies"]);
await runEsyCommand("Run esy build-dependencies", ["build-dependencies"]);
}

await run("Run esy build", "esy", ["build"]);
await runEsyCommand("Run esy build", ["build"]);

if (buildCacheKey != buildKey) {
await cache.saveCache(depsPath, buildKey);
}

if (!buildCacheKey) {
// TODO: support cleanup + manifest
if (!manifestKey && !buildCacheKey) {
await run("Run esy cleanup", "esy", ["cleanup", "."]);
}
} catch (e) {
Expand Down