Repository navigation
Surface per-PR CI status in sidebar #6983
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
Closed
austinywang
wants to merge
19
commits into
main
from
issue-5748-surface-per-pr-ci-cd-check-status-in-the-side
Closed
Changes from 7 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
0fbbf41
Surface PR CI status in sidebar
e11b3cf
Update Swift file length budget
ae62cca
Merge origin/main into issue 5748
c4a8a98
Address PR CI status review feedback
1162ccd
Merge remote-tracking branch 'origin/main' into issue-5748-surface-pe…
austinywang 038eabf
Address PR CI review nits: drop unused branch-keyed rollup helper
austinywang 17f11c6
Add failing test: branch-lookup PRs should receive fetched CI status
austinywang ecf9c0e
Fetch CI rollups for branch-lookup PRs; restore bounded test waiter t…
austinywang 8faf7ae
Degrade unknown resolved CI status to neutral instead of dropping the…
austinywang 910af2e
Merge remote-tracking branch 'origin/main' into issue-5748-surface-pe…
austinywang 11b393d
Merge remote-tracking branch 'origin/main' into issue-5748-surface-pe…
austinywang 575d38e
Keep best-effort CI rollup off the critical PR-badge refresh path
austinywang a4895b5
Merge remote-tracking branch 'origin/main' into issue-5748-surface-pe…
austinywang 396be69
Merge remote-tracking branch 'origin/main' into issue-5748-surface-pe…
austinywang a8857a4
Merge remote-tracking branch 'origin/main' into issue-5748-surface-pe…
austinywang 9f00aa2
Add CI status decoder regression tests
austinywang 4eec84b
Handle future CI status payloads
austinywang 62199eb
Limit PR CI status lookups to candidates
austinywang 414ed64
Merge remote-tracking branch 'origin/main' into issue-5748-surface-pe…
austinywang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
Packages/macOS/CmuxGit/Sources/CmuxGit/Model/PullRequestCheckStatus.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import Foundation | ||
|
|
||
| /// Rollup state for a pull request's CI checks. | ||
| public enum PullRequestCheckStatus: String, Sendable, Equatable, Decodable { | ||
| /// Checks are absent, queued, in progress, or unavailable. | ||
| case neutral | ||
| /// The check rollup passed. | ||
| case success | ||
| /// The check rollup failed or errored. | ||
| case failure | ||
|
|
||
| /// Maps GitHub GraphQL `statusCheckRollup.state` values to sidebar states. | ||
| public init(githubStatusCheckRollupState rawState: String?) { | ||
| switch rawState?.trimmingCharacters(in: .whitespacesAndNewlines).uppercased() { | ||
| case "SUCCESS": | ||
| self = .success | ||
| case "FAILURE", "ERROR": | ||
| self = .failure | ||
| default: | ||
| self = .neutral | ||
| } | ||
| } | ||
| } |
5 changes: 5 additions & 0 deletions
5
Packages/macOS/CmuxGit/Sources/CmuxGit/Model/WorkspacePullRequestGraphQLCommit.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import Foundation | ||
|
|
||
| struct WorkspacePullRequestGraphQLCommit: Decodable, Sendable { | ||
| let statusCheckRollup: WorkspacePullRequestGraphQLStatusCheckRollup? | ||
| } |
5 changes: 5 additions & 0 deletions
5
...ges/macOS/CmuxGit/Sources/CmuxGit/Model/WorkspacePullRequestGraphQLCommitConnection.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import Foundation | ||
|
|
||
| struct WorkspacePullRequestGraphQLCommitConnection: Decodable, Sendable { | ||
| let nodes: [WorkspacePullRequestGraphQLCommitNode?]? | ||
| } |
5 changes: 5 additions & 0 deletions
5
Packages/macOS/CmuxGit/Sources/CmuxGit/Model/WorkspacePullRequestGraphQLCommitNode.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import Foundation | ||
|
|
||
| struct WorkspacePullRequestGraphQLCommitNode: Decodable, Sendable { | ||
| let commit: WorkspacePullRequestGraphQLCommit | ||
| } |
5 changes: 5 additions & 0 deletions
5
Packages/macOS/CmuxGit/Sources/CmuxGit/Model/WorkspacePullRequestGraphQLData.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import Foundation | ||
|
|
||
| struct WorkspacePullRequestGraphQLData: Decodable, Sendable { | ||
| let repository: WorkspacePullRequestGraphQLRepository? | ||
| } |
5 changes: 5 additions & 0 deletions
5
...acOS/CmuxGit/Sources/CmuxGit/Model/WorkspacePullRequestGraphQLPullRequestConnection.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import Foundation | ||
|
|
||
| struct WorkspacePullRequestGraphQLPullRequestConnection: Decodable, Sendable { | ||
| let nodes: [WorkspacePullRequestGraphQLPullRequestNode?]? | ||
| } |
12 changes: 12 additions & 0 deletions
12
...ages/macOS/CmuxGit/Sources/CmuxGit/Model/WorkspacePullRequestGraphQLPullRequestNode.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import Foundation | ||
|
|
||
| struct WorkspacePullRequestGraphQLPullRequestNode: Decodable, Sendable { | ||
| let number: Int | ||
| let headRefName: String? | ||
| let commits: WorkspacePullRequestGraphQLCommitConnection? | ||
|
|
||
| var ciStatus: PullRequestCheckStatus { | ||
| let state = commits?.nodes?.compactMap { $0?.commit.statusCheckRollup?.state }.last | ||
| return PullRequestCheckStatus(githubStatusCheckRollupState: state) | ||
| } | ||
| } |
50 changes: 50 additions & 0 deletions
50
Packages/macOS/CmuxGit/Sources/CmuxGit/Model/WorkspacePullRequestGraphQLRepository.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import Foundation | ||
|
|
||
| struct WorkspacePullRequestGraphQLRepository: Decodable, Sendable { | ||
| let pullRequests: WorkspacePullRequestGraphQLPullRequestConnection? | ||
| let aliasedPullRequests: [WorkspacePullRequestGraphQLPullRequestNode] | ||
|
|
||
| var nodes: [WorkspacePullRequestGraphQLPullRequestNode?] { | ||
| (pullRequests?.nodes ?? []) + aliasedPullRequests.map(Optional.some) | ||
| } | ||
|
|
||
| private struct DynamicCodingKey: CodingKey { | ||
| let stringValue: String | ||
| let intValue: Int? | ||
|
|
||
| init?(stringValue: String) { | ||
| self.stringValue = stringValue | ||
| self.intValue = nil | ||
| } | ||
|
|
||
| init?(intValue: Int) { | ||
| return nil | ||
| } | ||
| } | ||
|
|
||
| private enum CodingKeys: String, CodingKey { | ||
| case pullRequests | ||
| } | ||
|
|
||
| init(from decoder: any Decoder) throws { | ||
| let fixedContainer = try decoder.container(keyedBy: CodingKeys.self) | ||
| self.pullRequests = try fixedContainer.decodeIfPresent( | ||
| WorkspacePullRequestGraphQLPullRequestConnection.self, | ||
| forKey: .pullRequests | ||
| ) | ||
| let container = try decoder.container(keyedBy: DynamicCodingKey.self) | ||
| self.aliasedPullRequests = container.allKeys.compactMap { key in | ||
| guard key.stringValue.hasPrefix("pr"), | ||
| key.stringValue.dropFirst(2).allSatisfy(\.isNumber) else { | ||
| return nil | ||
| } | ||
| // Tolerate a single malformed alias (e.g. a PR closed or renamed | ||
| // mid-fetch returns `null`) so one bad node doesn't drop CI status | ||
| // for the rest of the batch; the affected PR falls back to `.neutral`. | ||
| return try? container.decodeIfPresent( | ||
|
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
|
||
| WorkspacePullRequestGraphQLPullRequestNode.self, | ||
| forKey: key | ||
| ) | ||
| } | ||
| } | ||
| } | ||
6 changes: 6 additions & 0 deletions
6
Packages/macOS/CmuxGit/Sources/CmuxGit/Model/WorkspacePullRequestGraphQLRequestBody.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import Foundation | ||
|
|
||
| struct WorkspacePullRequestGraphQLRequestBody: Encodable, Sendable { | ||
| let query: String | ||
| let variables: WorkspacePullRequestGraphQLVariables | ||
| } |
5 changes: 5 additions & 0 deletions
5
Packages/macOS/CmuxGit/Sources/CmuxGit/Model/WorkspacePullRequestGraphQLResponse.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import Foundation | ||
|
|
||
| struct WorkspacePullRequestGraphQLResponse: Decodable, Sendable { | ||
| let data: WorkspacePullRequestGraphQLData? | ||
| } |
5 changes: 5 additions & 0 deletions
5
...es/macOS/CmuxGit/Sources/CmuxGit/Model/WorkspacePullRequestGraphQLStatusCheckRollup.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import Foundation | ||
|
|
||
| struct WorkspacePullRequestGraphQLStatusCheckRollup: Decodable, Sendable { | ||
| let state: String? | ||
| } |
6 changes: 6 additions & 0 deletions
6
Packages/macOS/CmuxGit/Sources/CmuxGit/Model/WorkspacePullRequestGraphQLVariables.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import Foundation | ||
|
|
||
| struct WorkspacePullRequestGraphQLVariables: Encodable, Sendable { | ||
| let owner: String | ||
| let name: String | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.