rebuild
This commit is contained in:
parent
271ff4b692
commit
d45cd2b045
|
@ -54598,147 +54598,170 @@ var external_path_ = __webpack_require__(5622);
|
|||
var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_);
|
||||
|
||||
// CONCATENATED MODULE: ./src/common.ts
|
||||
var __asyncValues = (undefined && undefined.__asyncValues) || function (o) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var m = o[Symbol.asyncIterator], i;
|
||||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
||||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
||||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const home = external_os_default().homedir();
|
||||
const paths = {
|
||||
index: external_path_default().join(home, ".cargo/registry/index"),
|
||||
cache: external_path_default().join(home, ".cargo/registry/cache"),
|
||||
git: external_path_default().join(home, ".cargo/git/db"),
|
||||
target: "target",
|
||||
};
|
||||
const RefKey = "GITHUB_REF";
|
||||
function isValidEvent() {
|
||||
return RefKey in process.env && Boolean(process.env[RefKey]);
|
||||
}
|
||||
async function getCaches() {
|
||||
const rustKey = await getRustKey();
|
||||
let lockHash = core.getState("lockHash");
|
||||
if (!lockHash) {
|
||||
lockHash = await getLockfileHash();
|
||||
core.saveState("lockHash", lockHash);
|
||||
}
|
||||
let targetKey = core.getInput("key");
|
||||
if (targetKey) {
|
||||
targetKey = `${targetKey}-`;
|
||||
}
|
||||
return {
|
||||
index: { path: paths.index, key: "registry-index-XXX", restoreKeys: ["registry-index"] },
|
||||
cache: { path: paths.cache, key: `registry-cache-${lockHash}`, restoreKeys: ["registry-cache"] },
|
||||
git: { path: paths.git, key: "git-db" },
|
||||
target: {
|
||||
path: paths.target,
|
||||
key: `target-${targetKey}${rustKey}-${lockHash}`,
|
||||
restoreKeys: [`target-${targetKey}${rustKey}`],
|
||||
},
|
||||
};
|
||||
}
|
||||
async function getRustKey() {
|
||||
const rustc = await getRustVersion();
|
||||
return `${rustc.release}-${rustc.host}-${rustc["commit-hash"]}`;
|
||||
}
|
||||
async function getRustVersion() {
|
||||
const stdout = await getCmdOutput("rustc", ["-vV"]);
|
||||
let splits = stdout
|
||||
.split(/[\n\r]+/)
|
||||
.filter(Boolean)
|
||||
.map((s) => s.split(":").map((s) => s.trim()))
|
||||
.filter((s) => s.length === 2);
|
||||
return Object.fromEntries(splits);
|
||||
}
|
||||
async function getCmdOutput(cmd, args = [], options = {}) {
|
||||
let stdout = "";
|
||||
await exec.exec(cmd, args, Object.assign({ silent: true, listeners: {
|
||||
stdout(data) {
|
||||
stdout += data.toString();
|
||||
},
|
||||
} }, options));
|
||||
return stdout;
|
||||
}
|
||||
async function getRegistryName() {
|
||||
const globber = await glob.create(`${paths.index}/**/.last-updated`, { followSymbolicLinks: false });
|
||||
const files = await globber.glob();
|
||||
if (files.length > 1) {
|
||||
core.debug(`got multiple registries: "${files.join('", "')}"`);
|
||||
}
|
||||
const first = files.shift();
|
||||
if (!first) {
|
||||
return;
|
||||
}
|
||||
return external_path_default().basename(external_path_default().dirname(first));
|
||||
}
|
||||
async function getLockfileHash() {
|
||||
var e_1, _a;
|
||||
const globber = await glob.create("**/Cargo.toml\n**/Cargo.lock", { followSymbolicLinks: false });
|
||||
const files = await globber.glob();
|
||||
files.sort((a, b) => a.localeCompare(b));
|
||||
const hasher = external_crypto_default().createHash("sha1");
|
||||
for (const file of files) {
|
||||
try {
|
||||
for (var _b = (e_1 = void 0, __asyncValues(external_fs_default().createReadStream(file))), _c; _c = await _b.next(), !_c.done;) {
|
||||
const chunk = _c.value;
|
||||
hasher.update(chunk);
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) await _a.call(_b);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
}
|
||||
return hasher.digest("hex");
|
||||
}
|
||||
var __asyncValues = (undefined && undefined.__asyncValues) || function (o) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var m = o[Symbol.asyncIterator], i;
|
||||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
||||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
||||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const home = external_os_default().homedir();
|
||||
const paths = {
|
||||
index: external_path_default().join(home, ".cargo/registry/index"),
|
||||
cache: external_path_default().join(home, ".cargo/registry/cache"),
|
||||
git: external_path_default().join(home, ".cargo/git/db"),
|
||||
target: "target",
|
||||
};
|
||||
const RefKey = "GITHUB_REF";
|
||||
function isValidEvent() {
|
||||
return RefKey in process.env && Boolean(process.env[RefKey]);
|
||||
}
|
||||
async function getCaches() {
|
||||
const rustKey = await getRustKey();
|
||||
let lockHash = core.getState("lockHash");
|
||||
if (!lockHash) {
|
||||
lockHash = await getLockfileHash();
|
||||
core.saveState("lockHash", lockHash);
|
||||
}
|
||||
let targetKey = core.getInput("key");
|
||||
if (targetKey) {
|
||||
targetKey = `${targetKey}-`;
|
||||
}
|
||||
const registryIndex = `v0-registry-index`;
|
||||
const registryCache = `v0-registry-cache`;
|
||||
const target = `v0-target-${targetKey}${rustKey}`;
|
||||
return {
|
||||
index: {
|
||||
name: "Registry Index",
|
||||
path: paths.index,
|
||||
key: `${registryIndex}-`,
|
||||
restoreKeys: [registryIndex],
|
||||
},
|
||||
cache: {
|
||||
name: "Registry Cache",
|
||||
path: paths.cache,
|
||||
key: `${registryCache}-${lockHash}`,
|
||||
restoreKeys: [registryCache],
|
||||
},
|
||||
// git: {
|
||||
// name: "Git Dependencies",
|
||||
// path: paths.git,
|
||||
// key: "git-db",
|
||||
// },
|
||||
target: {
|
||||
name: "Target",
|
||||
path: paths.target,
|
||||
key: `${target}-${lockHash}`,
|
||||
restoreKeys: [target],
|
||||
},
|
||||
};
|
||||
}
|
||||
async function getRustKey() {
|
||||
const rustc = await getRustVersion();
|
||||
return `${rustc.release}-${rustc.host}-${rustc["commit-hash"]}`;
|
||||
}
|
||||
async function getRustVersion() {
|
||||
const stdout = await getCmdOutput("rustc", ["-vV"]);
|
||||
let splits = stdout
|
||||
.split(/[\n\r]+/)
|
||||
.filter(Boolean)
|
||||
.map((s) => s.split(":").map((s) => s.trim()))
|
||||
.filter((s) => s.length === 2);
|
||||
return Object.fromEntries(splits);
|
||||
}
|
||||
async function getCmdOutput(cmd, args = [], options = {}) {
|
||||
let stdout = "";
|
||||
await exec.exec(cmd, args, Object.assign({ silent: true, listeners: {
|
||||
stdout(data) {
|
||||
stdout += data.toString();
|
||||
},
|
||||
} }, options));
|
||||
return stdout;
|
||||
}
|
||||
async function getRegistryName() {
|
||||
const globber = await glob.create(`${paths.index}/**/.last-updated`, { followSymbolicLinks: false });
|
||||
const files = await globber.glob();
|
||||
if (files.length > 1) {
|
||||
core.debug(`got multiple registries: "${files.join('", "')}"`);
|
||||
}
|
||||
const first = files.shift();
|
||||
if (!first) {
|
||||
return;
|
||||
}
|
||||
return external_path_default().basename(external_path_default().dirname(first));
|
||||
}
|
||||
async function getLockfileHash() {
|
||||
var e_1, _a;
|
||||
const globber = await glob.create("**/Cargo.toml\n**/Cargo.lock", { followSymbolicLinks: false });
|
||||
const files = await globber.glob();
|
||||
files.sort((a, b) => a.localeCompare(b));
|
||||
const hasher = external_crypto_default().createHash("sha1");
|
||||
for (const file of files) {
|
||||
try {
|
||||
for (var _b = (e_1 = void 0, __asyncValues(external_fs_default().createReadStream(file))), _c; _c = await _b.next(), !_c.done;) {
|
||||
const chunk = _c.value;
|
||||
hasher.update(chunk);
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) await _a.call(_b);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
}
|
||||
return hasher.digest("hex");
|
||||
}
|
||||
|
||||
// CONCATENATED MODULE: ./src/restore.ts
|
||||
|
||||
|
||||
|
||||
async function run() {
|
||||
if (!isValidEvent()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
core.exportVariable("CARGO_INCREMENTAL", 0);
|
||||
const caches = await getCaches();
|
||||
for (const [name, { path, key, restoreKeys }] of Object.entries(caches)) {
|
||||
try {
|
||||
core.startGroup(`Restoring "${path}" from "${key}"…`);
|
||||
const restoreKey = await cache.restoreCache([path], key, restoreKeys);
|
||||
if (restoreKey) {
|
||||
core.info(`Restored "${path}" from cache key "${restoreKey}".`);
|
||||
core.saveState(name, restoreKey);
|
||||
}
|
||||
else {
|
||||
core.info("No cache found.");
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
core.info(`[warning] ${e.message}`);
|
||||
}
|
||||
finally {
|
||||
core.endGroup();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
core.info(`[warning] ${e.message}`);
|
||||
}
|
||||
}
|
||||
run();
|
||||
|
||||
|
||||
|
||||
async function run() {
|
||||
if (!isValidEvent()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
core.exportVariable("CARGO_INCREMENTAL", 0);
|
||||
const caches = await getCaches();
|
||||
for (const [type, { name, path, key, restoreKeys }] of Object.entries(caches)) {
|
||||
const start = Date.now();
|
||||
core.startGroup(`Restoring ${name}"…`);
|
||||
core.info(`Restoring to path "${path}".`);
|
||||
core.info(`Using keys:\n ${[key, ...restoreKeys].join("\n ")}`);
|
||||
try {
|
||||
const restoreKey = await cache.restoreCache([path], key, restoreKeys);
|
||||
if (restoreKey) {
|
||||
core.info(`Restored from cache key "${restoreKey}".`);
|
||||
core.saveState(type, restoreKey);
|
||||
}
|
||||
else {
|
||||
core.info("No cache found.");
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
core.info(`[warning] ${e.message}`);
|
||||
}
|
||||
const duration = Math.round((Date.now() - start) / 1000);
|
||||
if (duration) {
|
||||
core.info(`Took ${duration}s.`);
|
||||
}
|
||||
core.endGroup();
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
core.info(`[warning] ${e.message}`);
|
||||
}
|
||||
}
|
||||
run();
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
|
|
@ -54581,285 +54581,317 @@ var exec = __webpack_require__(1514);
|
|||
// EXTERNAL MODULE: ./node_modules/@actions/glob/lib/glob.js
|
||||
var glob = __webpack_require__(8090);
|
||||
|
||||
// EXTERNAL MODULE: ./node_modules/@actions/io/lib/io.js
|
||||
var io = __webpack_require__(7436);
|
||||
|
||||
// EXTERNAL MODULE: external "crypto"
|
||||
var external_crypto_ = __webpack_require__(6417);
|
||||
var external_crypto_default = /*#__PURE__*/__webpack_require__.n(external_crypto_);
|
||||
|
||||
// EXTERNAL MODULE: ./node_modules/@actions/io/lib/io.js
|
||||
var io = __webpack_require__(7436);
|
||||
|
||||
// EXTERNAL MODULE: external "fs"
|
||||
var external_fs_ = __webpack_require__(5747);
|
||||
var external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_);
|
||||
|
||||
// EXTERNAL MODULE: external "path"
|
||||
var external_path_ = __webpack_require__(5622);
|
||||
var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_);
|
||||
|
||||
// EXTERNAL MODULE: external "os"
|
||||
var external_os_ = __webpack_require__(2087);
|
||||
var external_os_default = /*#__PURE__*/__webpack_require__.n(external_os_);
|
||||
|
||||
// EXTERNAL MODULE: external "path"
|
||||
var external_path_ = __webpack_require__(5622);
|
||||
var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_);
|
||||
|
||||
// CONCATENATED MODULE: ./src/common.ts
|
||||
var __asyncValues = (undefined && undefined.__asyncValues) || function (o) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var m = o[Symbol.asyncIterator], i;
|
||||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
||||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
||||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const home = external_os_default().homedir();
|
||||
const paths = {
|
||||
index: external_path_default().join(home, ".cargo/registry/index"),
|
||||
cache: external_path_default().join(home, ".cargo/registry/cache"),
|
||||
git: external_path_default().join(home, ".cargo/git/db"),
|
||||
target: "target",
|
||||
};
|
||||
const RefKey = "GITHUB_REF";
|
||||
function isValidEvent() {
|
||||
return RefKey in process.env && Boolean(process.env[RefKey]);
|
||||
}
|
||||
async function getCaches() {
|
||||
const rustKey = await getRustKey();
|
||||
let lockHash = core.getState("lockHash");
|
||||
if (!lockHash) {
|
||||
lockHash = await getLockfileHash();
|
||||
core.saveState("lockHash", lockHash);
|
||||
}
|
||||
let targetKey = core.getInput("key");
|
||||
if (targetKey) {
|
||||
targetKey = `${targetKey}-`;
|
||||
}
|
||||
return {
|
||||
index: { path: paths.index, key: "registry-index-XXX", restoreKeys: ["registry-index"] },
|
||||
cache: { path: paths.cache, key: `registry-cache-${lockHash}`, restoreKeys: ["registry-cache"] },
|
||||
git: { path: paths.git, key: "git-db" },
|
||||
target: {
|
||||
path: paths.target,
|
||||
key: `target-${targetKey}${rustKey}-${lockHash}`,
|
||||
restoreKeys: [`target-${targetKey}${rustKey}`],
|
||||
},
|
||||
};
|
||||
}
|
||||
async function getRustKey() {
|
||||
const rustc = await getRustVersion();
|
||||
return `${rustc.release}-${rustc.host}-${rustc["commit-hash"]}`;
|
||||
}
|
||||
async function getRustVersion() {
|
||||
const stdout = await getCmdOutput("rustc", ["-vV"]);
|
||||
let splits = stdout
|
||||
.split(/[\n\r]+/)
|
||||
.filter(Boolean)
|
||||
.map((s) => s.split(":").map((s) => s.trim()))
|
||||
.filter((s) => s.length === 2);
|
||||
return Object.fromEntries(splits);
|
||||
}
|
||||
async function getCmdOutput(cmd, args = [], options = {}) {
|
||||
let stdout = "";
|
||||
await exec.exec(cmd, args, Object.assign({ silent: true, listeners: {
|
||||
stdout(data) {
|
||||
stdout += data.toString();
|
||||
},
|
||||
} }, options));
|
||||
return stdout;
|
||||
}
|
||||
async function getRegistryName() {
|
||||
const globber = await glob.create(`${paths.index}/**/.last-updated`, { followSymbolicLinks: false });
|
||||
const files = await globber.glob();
|
||||
if (files.length > 1) {
|
||||
core.debug(`got multiple registries: "${files.join('", "')}"`);
|
||||
}
|
||||
const first = files.shift();
|
||||
if (!first) {
|
||||
return;
|
||||
}
|
||||
return external_path_default().basename(external_path_default().dirname(first));
|
||||
}
|
||||
async function getLockfileHash() {
|
||||
var e_1, _a;
|
||||
const globber = await glob.create("**/Cargo.toml\n**/Cargo.lock", { followSymbolicLinks: false });
|
||||
const files = await globber.glob();
|
||||
files.sort((a, b) => a.localeCompare(b));
|
||||
const hasher = external_crypto_default().createHash("sha1");
|
||||
for (const file of files) {
|
||||
try {
|
||||
for (var _b = (e_1 = void 0, __asyncValues(external_fs_default().createReadStream(file))), _c; _c = await _b.next(), !_c.done;) {
|
||||
const chunk = _c.value;
|
||||
hasher.update(chunk);
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) await _a.call(_b);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
}
|
||||
return hasher.digest("hex");
|
||||
}
|
||||
var __asyncValues = (undefined && undefined.__asyncValues) || function (o) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var m = o[Symbol.asyncIterator], i;
|
||||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
||||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
||||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const home = external_os_default().homedir();
|
||||
const paths = {
|
||||
index: external_path_default().join(home, ".cargo/registry/index"),
|
||||
cache: external_path_default().join(home, ".cargo/registry/cache"),
|
||||
git: external_path_default().join(home, ".cargo/git/db"),
|
||||
target: "target",
|
||||
};
|
||||
const RefKey = "GITHUB_REF";
|
||||
function isValidEvent() {
|
||||
return RefKey in process.env && Boolean(process.env[RefKey]);
|
||||
}
|
||||
async function getCaches() {
|
||||
const rustKey = await getRustKey();
|
||||
let lockHash = core.getState("lockHash");
|
||||
if (!lockHash) {
|
||||
lockHash = await getLockfileHash();
|
||||
core.saveState("lockHash", lockHash);
|
||||
}
|
||||
let targetKey = core.getInput("key");
|
||||
if (targetKey) {
|
||||
targetKey = `${targetKey}-`;
|
||||
}
|
||||
const registryIndex = `v0-registry-index`;
|
||||
const registryCache = `v0-registry-cache`;
|
||||
const target = `v0-target-${targetKey}${rustKey}`;
|
||||
return {
|
||||
index: {
|
||||
name: "Registry Index",
|
||||
path: paths.index,
|
||||
key: `${registryIndex}-`,
|
||||
restoreKeys: [registryIndex],
|
||||
},
|
||||
cache: {
|
||||
name: "Registry Cache",
|
||||
path: paths.cache,
|
||||
key: `${registryCache}-${lockHash}`,
|
||||
restoreKeys: [registryCache],
|
||||
},
|
||||
// git: {
|
||||
// name: "Git Dependencies",
|
||||
// path: paths.git,
|
||||
// key: "git-db",
|
||||
// },
|
||||
target: {
|
||||
name: "Target",
|
||||
path: paths.target,
|
||||
key: `${target}-${lockHash}`,
|
||||
restoreKeys: [target],
|
||||
},
|
||||
};
|
||||
}
|
||||
async function getRustKey() {
|
||||
const rustc = await getRustVersion();
|
||||
return `${rustc.release}-${rustc.host}-${rustc["commit-hash"]}`;
|
||||
}
|
||||
async function getRustVersion() {
|
||||
const stdout = await getCmdOutput("rustc", ["-vV"]);
|
||||
let splits = stdout
|
||||
.split(/[\n\r]+/)
|
||||
.filter(Boolean)
|
||||
.map((s) => s.split(":").map((s) => s.trim()))
|
||||
.filter((s) => s.length === 2);
|
||||
return Object.fromEntries(splits);
|
||||
}
|
||||
async function getCmdOutput(cmd, args = [], options = {}) {
|
||||
let stdout = "";
|
||||
await exec.exec(cmd, args, Object.assign({ silent: true, listeners: {
|
||||
stdout(data) {
|
||||
stdout += data.toString();
|
||||
},
|
||||
} }, options));
|
||||
return stdout;
|
||||
}
|
||||
async function getRegistryName() {
|
||||
const globber = await glob.create(`${paths.index}/**/.last-updated`, { followSymbolicLinks: false });
|
||||
const files = await globber.glob();
|
||||
if (files.length > 1) {
|
||||
core.debug(`got multiple registries: "${files.join('", "')}"`);
|
||||
}
|
||||
const first = files.shift();
|
||||
if (!first) {
|
||||
return;
|
||||
}
|
||||
return external_path_default().basename(external_path_default().dirname(first));
|
||||
}
|
||||
async function getLockfileHash() {
|
||||
var e_1, _a;
|
||||
const globber = await glob.create("**/Cargo.toml\n**/Cargo.lock", { followSymbolicLinks: false });
|
||||
const files = await globber.glob();
|
||||
files.sort((a, b) => a.localeCompare(b));
|
||||
const hasher = external_crypto_default().createHash("sha1");
|
||||
for (const file of files) {
|
||||
try {
|
||||
for (var _b = (e_1 = void 0, __asyncValues(external_fs_default().createReadStream(file))), _c; _c = await _b.next(), !_c.done;) {
|
||||
const chunk = _c.value;
|
||||
hasher.update(chunk);
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) await _a.call(_b);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
}
|
||||
return hasher.digest("hex");
|
||||
}
|
||||
|
||||
// CONCATENATED MODULE: ./src/save.ts
|
||||
var save_asyncValues = (undefined && undefined.__asyncValues) || function (o) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var m = o[Symbol.asyncIterator], i;
|
||||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
||||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
||||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
async function run() {
|
||||
if (!isValidEvent()) {
|
||||
//return;
|
||||
}
|
||||
try {
|
||||
const caches = await getCaches();
|
||||
const registryName = await getRegistryName();
|
||||
const packages = await getPackages();
|
||||
await pruneTarget(packages);
|
||||
if (registryName) {
|
||||
// save the index based on its revision
|
||||
const indexRef = await getIndexRef(registryName);
|
||||
caches.index.key = `registry-index-${indexRef}`;
|
||||
await io.rmRF(external_path_default().join(paths.index, registryName, ".cache"));
|
||||
await pruneRegistryCache(registryName, packages);
|
||||
}
|
||||
else {
|
||||
delete caches.index;
|
||||
delete caches.cache;
|
||||
}
|
||||
for (const [name, { path, key }] of Object.entries(caches)) {
|
||||
if (core.getState(name) === key) {
|
||||
core.info(`Cache for "${path}" up-to-date.`);
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
core.startGroup(`Saving "${path}" to cache key "${key}"…`);
|
||||
if (await cache.saveCache([path], key)) {
|
||||
core.info(`Saved "${path}" to cache key "${key}".`);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
core.info(`[warning] ${e.message}`);
|
||||
}
|
||||
finally {
|
||||
core.endGroup();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
core.info(`[warning] ${e.message}`);
|
||||
}
|
||||
}
|
||||
run();
|
||||
async function getIndexRef(registryName) {
|
||||
const cwd = external_path_default().join(paths.index, registryName);
|
||||
return (await getCmdOutput("git", ["rev-parse", "--short", "origin/master"], { cwd })).trim();
|
||||
}
|
||||
async function getPackages() {
|
||||
const meta = JSON.parse(await getCmdOutput("cargo", ["metadata", "--format-version", "1"]));
|
||||
return meta.packages.map(({ name, version }) => ({ name, version }));
|
||||
}
|
||||
async function pruneRegistryCache(registryName, packages) {
|
||||
var e_1, _a;
|
||||
const pkgSet = new Set(packages.map((p) => `${p.name}-${p.version}.crate`));
|
||||
const dir = await external_fs_default().promises.opendir(external_path_default().join(paths.cache, registryName));
|
||||
try {
|
||||
for (var dir_1 = save_asyncValues(dir), dir_1_1; dir_1_1 = await dir_1.next(), !dir_1_1.done;) {
|
||||
const dirent = dir_1_1.value;
|
||||
if (dirent.isFile() && !pkgSet.has(dirent.name)) {
|
||||
const fileName = external_path_default().join(dir.path, dirent.name);
|
||||
await external_fs_default().promises.unlink(fileName);
|
||||
core.debug(`deleting "${fileName}"`);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (dir_1_1 && !dir_1_1.done && (_a = dir_1.return)) await _a.call(dir_1);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
}
|
||||
async function pruneTarget(packages) {
|
||||
var e_2, _a;
|
||||
await external_fs_default().promises.unlink("./target/.rustc_info.json");
|
||||
await io.rmRF("./target/debug/examples");
|
||||
await io.rmRF("./target/debug/incremental");
|
||||
let dir;
|
||||
// remove all *files* from debug
|
||||
dir = await external_fs_default().promises.opendir("./target/debug");
|
||||
try {
|
||||
for (var dir_2 = save_asyncValues(dir), dir_2_1; dir_2_1 = await dir_2.next(), !dir_2_1.done;) {
|
||||
const dirent = dir_2_1.value;
|
||||
if (dirent.isFile()) {
|
||||
const fileName = external_path_default().join(dir.path, dirent.name);
|
||||
await external_fs_default().promises.unlink(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (dir_2_1 && !dir_2_1.done && (_a = dir_2.return)) await _a.call(dir_2);
|
||||
}
|
||||
finally { if (e_2) throw e_2.error; }
|
||||
}
|
||||
const keepPkg = new Set(packages.map((p) => p.name));
|
||||
await rmExcept("./target/debug/build", keepPkg);
|
||||
await rmExcept("./target/debug/.fingerprint", keepPkg);
|
||||
const keepDeps = new Set(packages.flatMap((p) => {
|
||||
const name = p.name.replace(/-/g, "_");
|
||||
return [name, `lib${name}`];
|
||||
}));
|
||||
await rmExcept("./target/debug/deps", keepDeps);
|
||||
}
|
||||
const twoWeeks = 14 * 24 * 3600 * 1000;
|
||||
async function rmExcept(dirName, keepPrefix) {
|
||||
var e_3, _a;
|
||||
const dir = await external_fs_default().promises.opendir(dirName);
|
||||
try {
|
||||
for (var dir_3 = save_asyncValues(dir), dir_3_1; dir_3_1 = await dir_3.next(), !dir_3_1.done;) {
|
||||
const dirent = dir_3_1.value;
|
||||
let name = dirent.name;
|
||||
const idx = name.lastIndexOf("-");
|
||||
if (idx !== -1) {
|
||||
name = name.slice(0, idx);
|
||||
}
|
||||
const fileName = external_path_default().join(dir.path, dirent.name);
|
||||
const { mtime } = await external_fs_default().promises.stat(fileName);
|
||||
if (!keepPrefix.has(name) || Date.now() - mtime.getTime() > twoWeeks) {
|
||||
core.debug(`deleting "${fileName}"`);
|
||||
if (dirent.isFile()) {
|
||||
await external_fs_default().promises.unlink(fileName);
|
||||
}
|
||||
else if (dirent.isDirectory()) {
|
||||
await io.rmRF(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (dir_3_1 && !dir_3_1.done && (_a = dir_3.return)) await _a.call(dir_3);
|
||||
}
|
||||
finally { if (e_3) throw e_3.error; }
|
||||
}
|
||||
}
|
||||
var save_asyncValues = (undefined && undefined.__asyncValues) || function (o) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var m = o[Symbol.asyncIterator], i;
|
||||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
||||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
||||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
async function run() {
|
||||
if (!isValidEvent()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const caches = await getCaches();
|
||||
const registryName = await getRegistryName();
|
||||
const packages = await getPackages();
|
||||
// TODO: remove this once https://github.com/actions/toolkit/pull/553 lands
|
||||
await macOsWorkaround();
|
||||
await pruneTarget(packages);
|
||||
if (registryName) {
|
||||
// save the index based on its revision
|
||||
const indexRef = await getIndexRef(registryName);
|
||||
caches.index.key += indexRef;
|
||||
await io.rmRF(external_path_default().join(paths.index, registryName, ".cache"));
|
||||
await pruneRegistryCache(registryName, packages);
|
||||
}
|
||||
else {
|
||||
delete caches.index;
|
||||
delete caches.cache;
|
||||
}
|
||||
for (const [type, { name, path, key }] of Object.entries(caches)) {
|
||||
if (core.getState(type) === key) {
|
||||
core.info(`${name} up-to-date.`);
|
||||
continue;
|
||||
}
|
||||
const start = Date.now();
|
||||
core.startGroup(`Saving ${name}…`);
|
||||
core.info(`Saving path "${path}".`);
|
||||
core.info(`Using key "${key}".`);
|
||||
try {
|
||||
await cache.saveCache([path], key);
|
||||
}
|
||||
catch (e) {
|
||||
core.info(`[warning] ${e.message}`);
|
||||
}
|
||||
const duration = Math.round((Date.now() - start) / 1000);
|
||||
if (duration) {
|
||||
core.info(`Took ${duration}s.`);
|
||||
}
|
||||
core.endGroup();
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
core.info(`[warning] ${e.message}`);
|
||||
}
|
||||
}
|
||||
run();
|
||||
async function getIndexRef(registryName) {
|
||||
const cwd = external_path_default().join(paths.index, registryName);
|
||||
return (await getCmdOutput("git", ["rev-parse", "--short", "origin/master"], { cwd })).trim();
|
||||
}
|
||||
async function getPackages() {
|
||||
const meta = JSON.parse(await getCmdOutput("cargo", ["metadata", "--all-features", "--format-version", "1"]));
|
||||
return meta.packages.map(({ name, version }) => ({ name, version }));
|
||||
}
|
||||
async function pruneRegistryCache(registryName, packages) {
|
||||
var e_1, _a;
|
||||
const pkgSet = new Set(packages.map((p) => `${p.name}-${p.version}.crate`));
|
||||
const dir = await external_fs_default().promises.opendir(external_path_default().join(paths.cache, registryName));
|
||||
try {
|
||||
for (var dir_1 = save_asyncValues(dir), dir_1_1; dir_1_1 = await dir_1.next(), !dir_1_1.done;) {
|
||||
const dirent = dir_1_1.value;
|
||||
if (dirent.isFile() && !pkgSet.has(dirent.name)) {
|
||||
const fileName = external_path_default().join(dir.path, dirent.name);
|
||||
await external_fs_default().promises.unlink(fileName);
|
||||
core.debug(`deleting "${fileName}"`);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (dir_1_1 && !dir_1_1.done && (_a = dir_1.return)) await _a.call(dir_1);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
}
|
||||
async function pruneTarget(packages) {
|
||||
var e_2, _a;
|
||||
await external_fs_default().promises.unlink("./target/.rustc_info.json");
|
||||
await io.rmRF("./target/debug/examples");
|
||||
await io.rmRF("./target/debug/incremental");
|
||||
let dir;
|
||||
// remove all *files* from debug
|
||||
dir = await external_fs_default().promises.opendir("./target/debug");
|
||||
try {
|
||||
for (var dir_2 = save_asyncValues(dir), dir_2_1; dir_2_1 = await dir_2.next(), !dir_2_1.done;) {
|
||||
const dirent = dir_2_1.value;
|
||||
if (dirent.isFile()) {
|
||||
const fileName = external_path_default().join(dir.path, dirent.name);
|
||||
await external_fs_default().promises.unlink(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (dir_2_1 && !dir_2_1.done && (_a = dir_2.return)) await _a.call(dir_2);
|
||||
}
|
||||
finally { if (e_2) throw e_2.error; }
|
||||
}
|
||||
const keepPkg = new Set(packages.map((p) => p.name));
|
||||
await rmExcept("./target/debug/build", keepPkg);
|
||||
await rmExcept("./target/debug/.fingerprint", keepPkg);
|
||||
const keepDeps = new Set(packages.flatMap((p) => {
|
||||
const name = p.name.replace(/-/g, "_");
|
||||
return [name, `lib${name}`];
|
||||
}));
|
||||
await rmExcept("./target/debug/deps", keepDeps);
|
||||
}
|
||||
const twoWeeks = 14 * 24 * 3600 * 1000;
|
||||
async function rmExcept(dirName, keepPrefix) {
|
||||
var e_3, _a;
|
||||
const dir = await external_fs_default().promises.opendir(dirName);
|
||||
try {
|
||||
for (var dir_3 = save_asyncValues(dir), dir_3_1; dir_3_1 = await dir_3.next(), !dir_3_1.done;) {
|
||||
const dirent = dir_3_1.value;
|
||||
let name = dirent.name;
|
||||
const idx = name.lastIndexOf("-");
|
||||
if (idx !== -1) {
|
||||
name = name.slice(0, idx);
|
||||
}
|
||||
const fileName = external_path_default().join(dir.path, dirent.name);
|
||||
const { mtime } = await external_fs_default().promises.stat(fileName);
|
||||
if (!keepPrefix.has(name) || Date.now() - mtime.getTime() > twoWeeks) {
|
||||
core.debug(`deleting "${fileName}"`);
|
||||
if (dirent.isFile()) {
|
||||
await external_fs_default().promises.unlink(fileName);
|
||||
}
|
||||
else if (dirent.isDirectory()) {
|
||||
await io.rmRF(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (dir_3_1 && !dir_3_1.done && (_a = dir_3.return)) await _a.call(dir_3);
|
||||
}
|
||||
finally { if (e_3) throw e_3.error; }
|
||||
}
|
||||
}
|
||||
async function macOsWorkaround() {
|
||||
try {
|
||||
// Workaround for https://github.com/actions/cache/issues/403
|
||||
// Also see https://github.com/rust-lang/cargo/issues/8603
|
||||
await exec.exec("sudo", ["/usr/sbin/purge"]);
|
||||
}
|
||||
catch (_a) { }
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
|
Loading…
Reference in New Issue