pull/503/head
Rob Herley 2024-01-19 17:52:40 -05:00
parent fc784dd79b
commit c8d1cdcfdc
No known key found for this signature in database
GPG Key ID: D1602042C3543B06
2 changed files with 223 additions and 156 deletions

197
dist/merge/index.js vendored
View File

@ -129441,90 +129441,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod);
return result;
};
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) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.chunk = void 0;
const path = __importStar(__nccwpck_require__(71017));
const promises_1 = __nccwpck_require__(73292);
const core = __importStar(__nccwpck_require__(42186));
const minimatch_1 = __nccwpck_require__(61953);
const artifact_1 = __importDefault(__nccwpck_require__(79450));
const input_helper_1 = __nccwpck_require__(17661);
const upload_artifact_1 = __nccwpck_require__(56680);
const search_1 = __nccwpck_require__(8725);
const PARALLEL_DOWNLOADS = 5;
const chunk = (arr, n) => arr.reduce((acc, cur, i) => {
const index = Math.floor(i / n);
acc[index] = [...(acc[index] || []), cur];
return acc;
}, []);
exports.chunk = chunk;
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const inputs = (0, input_helper_1.getInputs)();
const tmpDir = yield (0, promises_1.mkdtemp)('merge-artifact');
const listArtifactResponse = yield artifact_1.default.listArtifacts({
latest: true
});
const matcher = new minimatch_1.Minimatch(inputs.pattern);
const artifacts = listArtifactResponse.artifacts.filter(artifact => matcher.match(artifact.name));
core.debug(`Filtered from ${listArtifactResponse.artifacts.length} to ${artifacts.length} artifacts`);
if (artifacts.length === 0) {
throw new Error(`No artifacts found matching pattern '${inputs.pattern}'`);
}
core.info(`Preparing to download the following artifacts:`);
artifacts.forEach(artifact => {
core.info(`- ${artifact.name} (ID: ${artifact.id}, Size: ${artifact.size})`);
});
const downloadPromises = artifacts.map(artifact => artifact_1.default.downloadArtifact(artifact.id, {
path: inputs.separateDirectories
? path.join(tmpDir, artifact.name)
: tmpDir
}));
const chunkedPromises = (0, exports.chunk)(downloadPromises, PARALLEL_DOWNLOADS);
for (const chunk of chunkedPromises) {
yield Promise.all(chunk);
}
const options = {};
if (inputs.retentionDays) {
options.retentionDays = inputs.retentionDays;
}
if (typeof inputs.compressionLevel !== 'undefined') {
options.compressionLevel = inputs.compressionLevel;
}
const searchResult = yield (0, search_1.findFilesToUpload)(tmpDir);
yield (0, upload_artifact_1.uploadArtifact)(inputs.into, searchResult.filesToUpload, searchResult.rootDirectory, options);
core.info(`The ${artifacts.length} artifact(s) have been successfully merged!`);
if (inputs.deleteMerged) {
const deletePromises = artifacts.map(artifact => artifact_1.default.deleteArtifact(artifact.name));
yield Promise.all(deletePromises);
core.info(`The ${artifacts.length} artifact(s) have been deleted`);
}
try {
yield (0, promises_1.rm)(tmpDir, { recursive: true });
}
catch (error) {
core.warning(`Unable to remove temporary directory: ${error.message}`);
}
}
catch (error) {
core.setFailed(error.message);
}
});
}
run();
const merge_artifact_1 = __nccwpck_require__(30863);
(0, merge_artifact_1.run)().catch(error => {
core.setFailed(error.message);
});
/***/ }),
@ -129599,6 +129521,117 @@ function getInputs() {
exports.getInputs = getInputs;
/***/ }),
/***/ 30863:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
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) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.run = exports.chunk = void 0;
const path = __importStar(__nccwpck_require__(71017));
const promises_1 = __nccwpck_require__(73292);
const core = __importStar(__nccwpck_require__(42186));
const minimatch_1 = __nccwpck_require__(61953);
const artifact_1 = __importDefault(__nccwpck_require__(79450));
const input_helper_1 = __nccwpck_require__(17661);
const upload_artifact_1 = __nccwpck_require__(56680);
const search_1 = __nccwpck_require__(8725);
const PARALLEL_DOWNLOADS = 5;
const chunk = (arr, n) => arr.reduce((acc, cur, i) => {
const index = Math.floor(i / n);
acc[index] = [...(acc[index] || []), cur];
return acc;
}, []);
exports.chunk = chunk;
function run() {
return __awaiter(this, void 0, void 0, function* () {
const inputs = (0, input_helper_1.getInputs)();
const tmpDir = yield (0, promises_1.mkdtemp)('merge-artifact');
const listArtifactResponse = yield artifact_1.default.listArtifacts({
latest: true
});
const matcher = new minimatch_1.Minimatch(inputs.pattern);
const artifacts = listArtifactResponse.artifacts.filter(artifact => matcher.match(artifact.name));
core.debug(`Filtered from ${listArtifactResponse.artifacts.length} to ${artifacts.length} artifacts`);
if (artifacts.length === 0) {
throw new Error(`No artifacts found matching pattern '${inputs.pattern}'`);
}
core.info(`Preparing to download the following artifacts:`);
artifacts.forEach(artifact => {
core.info(`- ${artifact.name} (ID: ${artifact.id}, Size: ${artifact.size})`);
});
const downloadPromises = artifacts.map(artifact => artifact_1.default.downloadArtifact(artifact.id, {
path: inputs.separateDirectories
? path.join(tmpDir, artifact.name)
: tmpDir
}));
const chunkedPromises = (0, exports.chunk)(downloadPromises, PARALLEL_DOWNLOADS);
for (const chunk of chunkedPromises) {
yield Promise.all(chunk);
}
const options = {};
if (inputs.retentionDays) {
options.retentionDays = inputs.retentionDays;
}
if (typeof inputs.compressionLevel !== 'undefined') {
options.compressionLevel = inputs.compressionLevel;
}
const searchResult = yield (0, search_1.findFilesToUpload)(tmpDir);
yield (0, upload_artifact_1.uploadArtifact)(inputs.into, searchResult.filesToUpload, searchResult.rootDirectory, options);
core.info(`The ${artifacts.length} artifact(s) have been successfully merged!`);
if (inputs.deleteMerged) {
const deletePromises = artifacts.map(artifact => artifact_1.default.deleteArtifact(artifact.name));
yield Promise.all(deletePromises);
core.info(`The ${artifacts.length} artifact(s) have been deleted`);
}
try {
yield (0, promises_1.rm)(tmpDir, { recursive: true });
}
catch (error) {
core.warning(`Unable to remove temporary directory: ${error.message}`);
}
});
}
exports.run = run;
/***/ }),
/***/ 8725:

182
dist/upload/index.js vendored
View File

@ -129685,82 +129685,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod);
return result;
};
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) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__nccwpck_require__(42186));
const artifact_1 = __importStar(__nccwpck_require__(79450));
const search_1 = __nccwpck_require__(8725);
const input_helper_1 = __nccwpck_require__(67022);
const constants_1 = __nccwpck_require__(86154);
const upload_artifact_1 = __nccwpck_require__(56680);
function deleteArtifactIfExists(artifactName) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield artifact_1.default.deleteArtifact(artifactName);
}
catch (error) {
if (error instanceof artifact_1.ArtifactNotFoundError) {
core.debug(`Skipping deletion of '${artifactName}', it does not exist`);
return;
}
// Best effort, we don't want to fail the action if this fails
core.debug(`Unable to delete artifact: ${error.message}`);
}
});
}
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const inputs = (0, input_helper_1.getInputs)();
const searchResult = yield (0, search_1.findFilesToUpload)(inputs.searchPath);
if (searchResult.filesToUpload.length === 0) {
// No files were found, different use cases warrant different types of behavior if nothing is found
switch (inputs.ifNoFilesFound) {
case constants_1.NoFileOptions.warn: {
core.warning(`No files were found with the provided path: ${inputs.searchPath}. No artifacts will be uploaded.`);
break;
}
case constants_1.NoFileOptions.error: {
core.setFailed(`No files were found with the provided path: ${inputs.searchPath}. No artifacts will be uploaded.`);
break;
}
case constants_1.NoFileOptions.ignore: {
core.info(`No files were found with the provided path: ${inputs.searchPath}. No artifacts will be uploaded.`);
break;
}
}
}
else {
const s = searchResult.filesToUpload.length === 1 ? '' : 's';
core.info(`With the provided path, there will be ${searchResult.filesToUpload.length} file${s} uploaded`);
core.debug(`Root artifact directory is ${searchResult.rootDirectory}`);
if (inputs.overwrite) {
yield deleteArtifactIfExists(inputs.artifactName);
}
const options = {};
if (inputs.retentionDays) {
options.retentionDays = inputs.retentionDays;
}
if (typeof inputs.compressionLevel !== 'undefined') {
options.compressionLevel = inputs.compressionLevel;
}
yield (0, upload_artifact_1.uploadArtifact)(inputs.artifactName, searchResult.filesToUpload, searchResult.rootDirectory, options);
}
}
catch (error) {
core.setFailed(error.message);
}
});
}
run();
const upload_artifact_1 = __nccwpck_require__(18569);
(0, upload_artifact_1.run)().catch(error => {
core.setFailed(error.message);
});
/***/ }),
@ -129837,6 +129767,110 @@ function getInputs() {
exports.getInputs = getInputs;
/***/ }),
/***/ 18569:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
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) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.run = void 0;
const core = __importStar(__nccwpck_require__(42186));
const artifact_1 = __importStar(__nccwpck_require__(79450));
const search_1 = __nccwpck_require__(8725);
const input_helper_1 = __nccwpck_require__(67022);
const constants_1 = __nccwpck_require__(86154);
const upload_artifact_1 = __nccwpck_require__(56680);
function deleteArtifactIfExists(artifactName) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield artifact_1.default.deleteArtifact(artifactName);
}
catch (error) {
if (error instanceof artifact_1.ArtifactNotFoundError) {
core.debug(`Skipping deletion of '${artifactName}', it does not exist`);
return;
}
// Best effort, we don't want to fail the action if this fails
core.debug(`Unable to delete artifact: ${error.message}`);
}
});
}
function run() {
return __awaiter(this, void 0, void 0, function* () {
const inputs = (0, input_helper_1.getInputs)();
const searchResult = yield (0, search_1.findFilesToUpload)(inputs.searchPath);
if (searchResult.filesToUpload.length === 0) {
// No files were found, different use cases warrant different types of behavior if nothing is found
switch (inputs.ifNoFilesFound) {
case constants_1.NoFileOptions.warn: {
core.warning(`No files were found with the provided path: ${inputs.searchPath}. No artifacts will be uploaded.`);
break;
}
case constants_1.NoFileOptions.error: {
core.setFailed(`No files were found with the provided path: ${inputs.searchPath}. No artifacts will be uploaded.`);
break;
}
case constants_1.NoFileOptions.ignore: {
core.info(`No files were found with the provided path: ${inputs.searchPath}. No artifacts will be uploaded.`);
break;
}
}
}
else {
const s = searchResult.filesToUpload.length === 1 ? '' : 's';
core.info(`With the provided path, there will be ${searchResult.filesToUpload.length} file${s} uploaded`);
core.debug(`Root artifact directory is ${searchResult.rootDirectory}`);
if (inputs.overwrite) {
yield deleteArtifactIfExists(inputs.artifactName);
}
const options = {};
if (inputs.retentionDays) {
options.retentionDays = inputs.retentionDays;
}
if (typeof inputs.compressionLevel !== 'undefined') {
options.compressionLevel = inputs.compressionLevel;
}
yield (0, upload_artifact_1.uploadArtifact)(inputs.artifactName, searchResult.filesToUpload, searchResult.rootDirectory, options);
}
});
}
exports.run = run;
/***/ }),
/***/ 22877: