Skip to content

Commit

Permalink
Update for new conclusion enumeration type
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrisbin committed Jan 30, 2024
1 parent e85e2d9 commit 1051aa7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
19 changes: 14 additions & 5 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,21 @@ export type Annotation = {

export type AnnotationLevel = "notice" | "warning" | "failure";

export type Conclusion =
| "failure"
| "action_required"
| "cancelled"
| "neutral"
| "success"
| "skipped"
| "stale"
| "timed_out";

export async function createCheck(
client: ClientType,
name: string,
annotations: Annotation[],
conclusion: string
conclusion: Conclusion,
): Promise<void> {
const pullRequest = github.context.payload.pull_request;
const head_sha = pullRequest?.head.sha ?? github.context.sha;
Expand Down Expand Up @@ -78,16 +88,15 @@ type ListFilesResponse =
RestEndpointMethodTypes["pulls"]["listFiles"]["response"]["data"];

export async function listPullRequestFiles(
client: ClientType
client: ClientType,
): Promise<string[]> {
const listFilesOptions = client.rest.pulls.listFiles.endpoint.merge({
...github.context.repo,
pull_number: github.context.issue.number,
});

const listFilesResponse: ListFilesResponse = await client.paginate(
listFilesOptions
);
const listFilesResponse: ListFilesResponse =
await client.paginate(listFilesOptions);

return listFilesResponse.map((f) => f.filename);
}
8 changes: 4 additions & 4 deletions src/reporter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as core from "@actions/core";
import * as gh from "@actions/github";

import type { Annotation, AnnotationLevel } from "./github";
import type { Annotation, AnnotationLevel, Conclusion } from "./github";
import * as github from "./github";
import type { GrepResult } from "./grep";
import type { Pattern } from "./config";
Expand All @@ -12,7 +12,7 @@ export class Reporter {
createNewCheck: boolean;
failureThreshold: AnnotationLevel;
annotations: Annotation[];
conclusion: string;
conclusion: Conclusion;

constructor(createNewCheck: boolean, failureThreshold: AnnotationLevel) {
this.createNewCheck = createNewCheck;
Expand Down Expand Up @@ -86,13 +86,13 @@ export class Reporter {
}

core.info(
`Creating Check result with ${this.annotations.length} annotation(s)`
`Creating Check result with ${this.annotations.length} annotation(s)`,
);
return await github.createCheck(
client,
"Grep results",
this.annotations,
this.conclusion
this.conclusion,
);
}
}

0 comments on commit 1051aa7

Please sign in to comment.