Repository navigation
fix(github): ci_logs explains why a check has no log #40156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -876,6 +876,29 @@ const decodeRunJobs = Schema.decodeEffect( | |
| }), | ||
| ), | ||
| ); | ||
| const decodeCheckRun = Schema.decodeEffect( | ||
| Schema.fromJsonString( | ||
| Schema.Struct({ | ||
| conclusion: Schema.optional(Schema.NullOr(Schema.String)), | ||
| output: Schema.optional( | ||
| Schema.Struct({ | ||
| title: Schema.optional(Schema.NullOr(Schema.String)), | ||
| summary: Schema.optional(Schema.NullOr(Schema.String)), | ||
| }), | ||
| ), | ||
| }), | ||
| ), | ||
| ); | ||
| const decodeCheckRunAnnotations = Schema.decodeEffect( | ||
| Schema.fromJsonString( | ||
| Schema.Array( | ||
| Schema.Struct({ | ||
| annotation_level: Schema.optional(Schema.NullOr(Schema.String)), | ||
| message: Schema.String, | ||
| }), | ||
| ), | ||
| ), | ||
| ); | ||
| const FAILED_CONCLUSIONS = new Set(["failure", "cancelled", "timed_out", "startup_failure"]); | ||
| const ONE_JOB_AT_A_TIME = | ||
| "GitHub re-runs one job of a run at a time. Re-run this one after the other finishes."; | ||
|
|
@@ -2912,6 +2935,43 @@ export const make = Effect.gen(function* () { | |
|
|
||
| readCheckLogs: Effect.fn("GitHubPullRequestApi.readCheckLogs")(function* (input) { | ||
| const { owner, name } = parseRepositorySelector(input.repository); | ||
| const readCheckRun = <A, E>(path: string, decode: (body: string) => Effect.Effect<A, E>) => | ||
| api | ||
| .rest({ host: input.host, operation: "readCheckRun", path }) | ||
| .pipe(Effect.flatMap((response) => decode(response.body))); | ||
| // A job that never started (billing block, skipped) or whose log expired has no log; | ||
| // its check run (an Actions job id is its check run id) says why. | ||
| const missingLog = (check: ProviderCheckReference, jobId: string, fallback: string) => | ||
| Effect.all( | ||
| [ | ||
| readCheckRun(`repos/${owner}/${name}/check-runs/${jobId}`, decodeCheckRun), | ||
| readCheckRun( | ||
| `repos/${owner}/${name}/check-runs/${jobId}/annotations?per_page=50`, | ||
| decodeCheckRunAnnotations, | ||
| ), | ||
| ], | ||
| { concurrency: 2 }, | ||
| ).pipe( | ||
| Effect.map(([run, annotations]) => | ||
| [ | ||
| `GitHub returned no log for this job${run.conclusion ? `; it concluded ${run.conclusion}` : ""}.`, | ||
| run.output?.title, | ||
| run.output?.summary, | ||
| ...annotations.map( | ||
| (annotation) => | ||
| `${annotation.annotation_level ? `${annotation.annotation_level}: ` : ""}${annotation.message}`, | ||
| ), | ||
| ] | ||
| .filter((line) => typeof line === "string" && line.trim() !== "") | ||
| .join("\n"), | ||
| ), | ||
| Effect.catchTags({ | ||
| GitHubApiNotFoundError: () => Effect.succeed(fallback), | ||
| GitHubApiResponseError: () => Effect.succeed(fallback), | ||
| SchemaError: () => Effect.succeed(fallback), | ||
|
Comment on lines
+2968
to
+2971
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Preserve the fallback for supplemental request failures. If the log request returns NotFound and the supplemental read returns Recover supplemental request failures with the original fallback. Preserve the explicit authentication and rate-limit failure policy.
|
||
| }), | ||
| Effect.map((detail) => ({ ...check, log: null, truncated: false, detail })), | ||
| ); | ||
| return yield* Effect.forEach( | ||
| input.checks, | ||
| (check) => { | ||
|
|
@@ -2947,10 +3007,8 @@ export const make = Effect.gen(function* () { | |
| }), | ||
| // Sign-in and rate-limit failures fail the call; the rest are this check's. | ||
| Effect.catchTags({ | ||
| GitHubApiNotFoundError: (error) => | ||
| Effect.succeed({ ...check, log: null, truncated: false, detail: error.message }), | ||
| GitHubApiResponseError: (error) => | ||
| Effect.succeed({ ...check, log: null, truncated: false, detail: error.message }), | ||
| GitHubApiNotFoundError: (error) => missingLog(check, jobId, error.message), | ||
| GitHubApiResponseError: (error) => missingLog(check, jobId, error.message), | ||
| }), | ||
| ); | ||
| }, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep readable check-run details when annotations fail.
If the check-run read succeeds but the annotations read returns
GitHubApiResponseError,Effect.allfails before formatting. The handler then replaces the readable conclusion and summary with the original generic error. (raw.githubusercontent.com)Recover the tolerated annotation errors independently with an empty annotation list. Keep the run-level fallback for a failed check-run read. Extend the existing test with this partial-success case.