mirror of
https://github.com/github/codeql-action.git
synced 2025-12-24 08:10:06 +08:00
Improve documentation
This commit is contained in:
26
lib/debug-artifacts.js
generated
26
lib/debug-artifacts.js
generated
@@ -26,9 +26,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sanitizeArifactName = sanitizeArifactName;
|
||||
exports.sanitizeArtifactName = sanitizeArtifactName;
|
||||
exports.uploadCombinedSarifArtifacts = uploadCombinedSarifArtifacts;
|
||||
exports.uploadAllAvailableDebugArtifacts = uploadAllAvailableDebugArtifacts;
|
||||
exports.tryUploadAllAvailableDebugArtifacts = tryUploadAllAvailableDebugArtifacts;
|
||||
exports.uploadDebugArtifacts = uploadDebugArtifacts;
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
@@ -41,7 +41,7 @@ const analyze_1 = require("./analyze");
|
||||
const codeql_1 = require("./codeql");
|
||||
const environment_1 = require("./environment");
|
||||
const util_1 = require("./util");
|
||||
function sanitizeArifactName(name) {
|
||||
function sanitizeArtifactName(name) {
|
||||
return name.replace(/[^a-zA-Z0-9_\\-]+/g, "");
|
||||
}
|
||||
/**
|
||||
@@ -71,6 +71,11 @@ async function uploadCombinedSarifArtifacts() {
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Try to get the SARIF result path for the given language.
|
||||
*
|
||||
* If an error occurs, log it and return an empty list.
|
||||
*/
|
||||
function tryGetSarifResultPath(config, language, logger) {
|
||||
try {
|
||||
const analyzeActionOutputDir = process.env[environment_1.EnvVar.SARIF_RESULTS_OUTPUT_DIR];
|
||||
@@ -91,6 +96,12 @@ function tryGetSarifResultPath(config, language, logger) {
|
||||
}
|
||||
return [];
|
||||
}
|
||||
/**
|
||||
* Try to bundle the database for the given language. Return a list containing
|
||||
* the path to the database bundle.
|
||||
*
|
||||
* If an error occurs, log it and return an empty list.
|
||||
*/
|
||||
async function tryBundleDatabase(config, language, logger) {
|
||||
try {
|
||||
if ((0, analyze_1.dbIsFinalized)(config, language, logger)) {
|
||||
@@ -109,7 +120,12 @@ async function tryBundleDatabase(config, language, logger) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
async function uploadAllAvailableDebugArtifacts(config, logger) {
|
||||
/**
|
||||
* Attempt to upload all available debug artifacts.
|
||||
*
|
||||
* Logs and suppresses any errors that occur.
|
||||
*/
|
||||
async function tryUploadAllAvailableDebugArtifacts(config, logger) {
|
||||
try {
|
||||
const filesToUpload = [];
|
||||
for (const language of config.languages) {
|
||||
@@ -150,7 +166,7 @@ async function uploadDebugArtifacts(toUpload, rootDir, artifactName) {
|
||||
}
|
||||
}
|
||||
try {
|
||||
await artifact.create().uploadArtifact(sanitizeArifactName(`${artifactName}${suffix}`), toUpload.map((file) => path.normalize(file)), path.normalize(rootDir), {
|
||||
await artifact.create().uploadArtifact(sanitizeArtifactName(`${artifactName}${suffix}`), toUpload.map((file) => path.normalize(file)), path.normalize(rootDir), {
|
||||
continueOnError: true,
|
||||
// ensure we don't keep the debug artifacts around for too long since they can be large.
|
||||
retentionDays: 7,
|
||||
|
||||
Reference in New Issue
Block a user