mirror of
https://github.com/github/codeql-action.git
synced 2026-04-29 18:30:14 +00:00
Refactor generic part of uploadDebugArtifacts into uploadArtifacts
This commit is contained in:
+32
-9
@@ -273,6 +273,12 @@ export function getArtifactSuffix(matrix: string | undefined): string {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
// Enumerates different, possible outcomes for artifact uploads.
|
||||
export type UploadArtifactsResult =
|
||||
| "no-artifacts-to-upload"
|
||||
| "upload-successful"
|
||||
| "upload-failed";
|
||||
|
||||
export async function uploadDebugArtifacts(
|
||||
logger: Logger,
|
||||
toUpload: string[],
|
||||
@@ -280,15 +286,7 @@ export async function uploadDebugArtifacts(
|
||||
artifactName: string,
|
||||
ghVariant: GitHubVariant,
|
||||
codeQlVersion: string | undefined,
|
||||
): Promise<
|
||||
| "no-artifacts-to-upload"
|
||||
| "upload-successful"
|
||||
| "upload-failed"
|
||||
| "upload-not-supported"
|
||||
> {
|
||||
if (toUpload.length === 0) {
|
||||
return "no-artifacts-to-upload";
|
||||
}
|
||||
): Promise<UploadArtifactsResult | "upload-not-supported"> {
|
||||
const uploadSupported = isSafeArtifactUpload(codeQlVersion);
|
||||
|
||||
if (!uploadSupported) {
|
||||
@@ -298,6 +296,31 @@ export async function uploadDebugArtifacts(
|
||||
return "upload-not-supported";
|
||||
}
|
||||
|
||||
return uploadArtifacts(logger, toUpload, rootDir, artifactName, ghVariant);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads the specified files as a single workflow artifact.
|
||||
*
|
||||
* @param logger The logger to use.
|
||||
* @param toUpload The list of paths to include in the artifact.
|
||||
* @param rootDir The root directory of the paths to include.
|
||||
* @param artifactName The base name for the artifact.
|
||||
* @param ghVariant The GitHub variant.
|
||||
*
|
||||
* @returns The outcome of the attempt to create and upload the artifact.
|
||||
*/
|
||||
export async function uploadArtifacts(
|
||||
logger: Logger,
|
||||
toUpload: string[],
|
||||
rootDir: string,
|
||||
artifactName: string,
|
||||
ghVariant: GitHubVariant,
|
||||
): Promise<UploadArtifactsResult> {
|
||||
if (toUpload.length === 0) {
|
||||
return "no-artifacts-to-upload";
|
||||
}
|
||||
|
||||
// When running in test mode, perform a best effort scan of the debug artifacts. The artifact
|
||||
// scanner is basic and not reliable or fast enough for production use, but it can help catch
|
||||
// some issues early.
|
||||
|
||||
Reference in New Issue
Block a user