Skip to content

Commit

Permalink
Merge pull request #18650 from saurabh-git-dev/fix-issue-18648
Browse files Browse the repository at this point in the history
fix the check run filter by id
  • Loading branch information
tidy-dev committed May 23, 2024
2 parents b80f540 + 0f19cde commit 6945d86
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 42 deletions.
14 changes: 7 additions & 7 deletions app/src/lib/ci-checks/ci-checks.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Account } from '../../models/account'
import { GitHubRepository } from '../../models/github-repository'
import {
APICheckStatus,
API,
APICheckConclusion,
IAPIWorkflowJobStep,
APICheckStatus,
IAPIRefCheckRun,
IAPIRefStatusItem,
API,
IAPIWorkflowJobStep,
IAPIWorkflowJobs,
IAPIWorkflowRun,
} from '../api'
import { GitHubRepository } from '../../models/github-repository'
import { Account } from '../../models/account'
import { supportsRetrieveActionWorkflowByCheckSuiteId } from '../endpoint-capabilities'
import {
formatLongPreciseDuration,
Expand Down Expand Up @@ -286,7 +286,7 @@ export function isSuccess(check: IRefCheck) {
* We use the check suite id as a proxy for determining what's
* the "latest" of two check runs with the same name.
*/
export function getLatestCheckRunsByName(
export function getLatestCheckRunsById(
checkRuns: ReadonlyArray<IAPIRefCheckRun>
): ReadonlyArray<IAPIRefCheckRun> {
const latestCheckRunsByName = new Map<string, IAPIRefCheckRun>()
Expand All @@ -301,7 +301,7 @@ export function getLatestCheckRunsByName(
// feels hacky... but we don't have any other meta data on a check run that
// differieates these.
const nameAndHasPRs =
checkRun.name +
checkRun.id +
(checkRun.pull_requests.length > 0
? 'isPullRequestCheckRun'
: 'isPushCheckRun')
Expand Down
20 changes: 9 additions & 11 deletions app/src/lib/stores/commit-status-store.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import pLimit from 'p-limit'
import QuickLRU from 'quick-lru'

import { Disposable, DisposableLike } from 'event-kit'
import xor from 'lodash/xor'
import { Account } from '../../models/account'
import { AccountsStore } from './accounts-store'
import { GitHubRepository } from '../../models/github-repository'
import { API, getAccountForEndpoint, IAPICheckSuite } from '../api'
import { DisposableLike, Disposable } from 'event-kit'
import {
ICombinedRefCheck,
IRefCheck,
createCombinedCheckFromChecks,
apiCheckRunToRefCheck,
getLatestCheckRunsByName,
apiStatusToRefCheck,
getLatestPRWorkflowRunsLogsForCheckRun,
createCombinedCheckFromChecks,
getCheckRunActionsWorkflowRuns,
getLatestCheckRunsById,
getLatestPRWorkflowRunsLogsForCheckRun,
ICombinedRefCheck,
IRefCheck,
manuallySetChecksToPending,
} from '../ci-checks/ci-checks'
import xor from 'lodash/xor'
import { offsetFromNow } from '../offset-from'
import { AccountsStore } from './accounts-store'

interface ICommitStatusCacheEntry {
/**
Expand Down Expand Up @@ -310,9 +310,7 @@ export class CommitStatusStore {
}

if (checkRuns !== null) {
const latestCheckRunsByName = getLatestCheckRunsByName(
checkRuns.check_runs
)
const latestCheckRunsByName = getLatestCheckRunsById(checkRuns.check_runs)
checks.push(...latestCheckRunsByName.map(apiCheckRunToRefCheck))
}

Expand Down
46 changes: 22 additions & 24 deletions app/src/lib/stores/notifications-store.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
import { NotificationCallback } from 'desktop-notifications/dist/notification-callback'
import { Commit, shortenSHA } from '../../models/commit'
import { GitHubRepository } from '../../models/github-repository'
import { PullRequest, getPullRequestCommitRef } from '../../models/pull-request'
import {
Repository,
isRepositoryWithGitHubRepository,
RepositoryWithGitHubRepository,
isRepositoryWithForkedGitHubRepository,
getForkContributionTarget,
isRepositoryWithForkedGitHubRepository,
isRepositoryWithGitHubRepository,
} from '../../models/repository'
import { ForkContributionTarget } from '../../models/workflow-preferences'
import { getPullRequestCommitRef, PullRequest } from '../../models/pull-request'
import { getVerbForPullRequestReview } from '../../ui/notifications/pull-request-review-helpers'
import { API, APICheckConclusion, IAPIComment } from '../api'
import {
createCombinedCheckFromChecks,
getLatestCheckRunsByName,
apiStatusToRefCheck,
apiCheckRunToRefCheck,
IRefCheck,
apiCheckRunToRefCheck,
apiStatusToRefCheck,
createCombinedCheckFromChecks,
getLatestCheckRunsById,
} from '../ci-checks/ci-checks'
import { AccountsStore } from './accounts-store'
import { getCommit } from '../git'
import { GitHubRepository } from '../../models/github-repository'
import { PullRequestCoordinator } from './pull-request-coordinator'
import { Commit, shortenSHA } from '../../models/commit'
import { getBoolean, setBoolean } from '../local-storage'
import { showNotification } from '../notifications/show-notification'
import { StatsStore } from '../stats'
import { truncateWithEllipsis } from '../truncate-with-ellipsis'
import {
ValidNotificationPullRequestReview,
isValidNotificationPullRequestReview,
} from '../valid-notification-pull-request-review'
import { AccountsStore } from './accounts-store'
import {
AliveStore,
DesktopAliveEvent,
IDesktopChecksFailedAliveEvent,
IDesktopPullRequestCommentAliveEvent,
IDesktopPullRequestReviewSubmitAliveEvent,
} from './alive-store'
import { setBoolean, getBoolean } from '../local-storage'
import { showNotification } from '../notifications/show-notification'
import { StatsStore } from '../stats'
import { truncateWithEllipsis } from '../truncate-with-ellipsis'
import { getVerbForPullRequestReview } from '../../ui/notifications/pull-request-review-helpers'
import {
isValidNotificationPullRequestReview,
ValidNotificationPullRequestReview,
} from '../valid-notification-pull-request-review'
import { NotificationCallback } from 'desktop-notifications/dist/notification-callback'
import { PullRequestCoordinator } from './pull-request-coordinator'

export type OnChecksFailedCallback = (
repository: RepositoryWithGitHubRepository,
Expand Down Expand Up @@ -537,9 +537,7 @@ export class NotificationsStore {
}

if (checkRuns !== null) {
const latestCheckRunsByName = getLatestCheckRunsByName(
checkRuns.check_runs
)
const latestCheckRunsByName = getLatestCheckRunsById(checkRuns.check_runs)
checks.push(...latestCheckRunsByName.map(apiCheckRunToRefCheck))
}

Expand Down

0 comments on commit 6945d86

Please sign in to comment.