mirror of
https://github.com/github/codeql-action.git
synced 2026-04-29 18:30:14 +00:00
Type the upload payload object
This commit is contained in:
+10
-1
@@ -12,6 +12,7 @@ import * as api from "./api-client";
|
||||
import { getRunnerLogger, Logger } from "./logging";
|
||||
import { setupTests } from "./testing-utils";
|
||||
import * as uploadLib from "./upload-lib";
|
||||
import { UploadPayload } from "./upload-lib/types";
|
||||
import { GitHubVariant, initializeEnvironment, withTmpDir } from "./util";
|
||||
|
||||
setupTests(test);
|
||||
@@ -909,7 +910,15 @@ function createMockSarif(id?: string, tool?: string) {
|
||||
|
||||
function uploadPayloadFixtures(analysis: analyses.AnalysisConfig) {
|
||||
const mockData = {
|
||||
payload: { sarif: "base64data", commit_sha: "abc123" },
|
||||
payload: {
|
||||
commit_oid: "abc123",
|
||||
ref: "ref",
|
||||
sarif: "base64data",
|
||||
workflow_run_id: 1,
|
||||
workflow_run_attempt: 1,
|
||||
checkout_uri: "uri",
|
||||
tool_names: ["codeql"],
|
||||
} satisfies UploadPayload,
|
||||
owner: "test-owner",
|
||||
repo: "test-repo",
|
||||
response: {
|
||||
|
||||
+4
-3
@@ -21,6 +21,7 @@ import * as gitUtils from "./git-utils";
|
||||
import { initCodeQL } from "./init";
|
||||
import { Logger } from "./logging";
|
||||
import { getRepositoryNwo, RepositoryNwo } from "./repository";
|
||||
import { UploadPayload } from "./upload-lib/types";
|
||||
import * as util from "./util";
|
||||
import {
|
||||
ConfigurationError,
|
||||
@@ -326,7 +327,7 @@ function getAutomationID(
|
||||
* This is exported for testing purposes only.
|
||||
*/
|
||||
export async function uploadPayload(
|
||||
payload: any,
|
||||
payload: UploadPayload,
|
||||
repositoryNwo: RepositoryNwo,
|
||||
logger: Logger,
|
||||
analysis: analyses.AnalysisConfig,
|
||||
@@ -618,8 +619,8 @@ export function buildPayload(
|
||||
environment: string | undefined,
|
||||
toolNames: string[],
|
||||
mergeBaseCommitOid: string | undefined,
|
||||
) {
|
||||
const payloadObj = {
|
||||
): UploadPayload {
|
||||
const payloadObj: UploadPayload = {
|
||||
commit_oid: commitOid,
|
||||
ref,
|
||||
analysis_key: analysisKey,
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
export interface UploadPayload {
|
||||
commit_oid: string;
|
||||
ref: string;
|
||||
analysis_key?: string;
|
||||
analysis_name?: string;
|
||||
sarif: string;
|
||||
workflow_run_id: number;
|
||||
workflow_run_attempt: number;
|
||||
checkout_uri: string;
|
||||
environment?: string;
|
||||
started_at?: string;
|
||||
tool_names: string[];
|
||||
base_ref?: string;
|
||||
base_sha?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user