From b06ffae57c8c2a6613421ce5ea81ce659244a3cb Mon Sep 17 00:00:00 2001 From: Catherine Lee Date: Fri, 11 Jul 2025 10:57:39 -0700 Subject: [PATCH 1/2] tc --- .../commit_jobs_query/params.json | 6 ++- .../commit_jobs_query/query.sql | 8 +++ torchci/components/commit/CommitStatus.tsx | 6 +++ torchci/components/commit/WorkflowBox.tsx | 47 +++++++++++++++-- torchci/lib/fetchCommit.ts | 50 +++++++++++++++++-- .../[repoOwner]/[repoName]/commit/[sha].ts | 5 +- 6 files changed, 111 insertions(+), 11 deletions(-) diff --git a/torchci/clickhouse_queries/commit_jobs_query/params.json b/torchci/clickhouse_queries/commit_jobs_query/params.json index 270d08eaf7..36cf80d8ee 100644 --- a/torchci/clickhouse_queries/commit_jobs_query/params.json +++ b/torchci/clickhouse_queries/commit_jobs_query/params.json @@ -1,12 +1,14 @@ { "params": { "repo": "String", - "sha": "String" + "sha": "String", + "workflowId": "Int64" }, "tests": [ { "repo": "pytorch/pytorch", - "sha": "85df746892d9b0e87e7a5dfa78ef81a84aec6de0" + "sha": "85df746892d9b0e87e7a5dfa78ef81a84aec6de0", + "workflow_id": 0 } ] } diff --git a/torchci/clickhouse_queries/commit_jobs_query/query.sql b/torchci/clickhouse_queries/commit_jobs_query/query.sql index 8c84e8f106..d0440b0d06 100644 --- a/torchci/clickhouse_queries/commit_jobs_query/query.sql +++ b/torchci/clickhouse_queries/commit_jobs_query/query.sql @@ -46,6 +46,10 @@ WITH job AS ( AND workflow.event != 'workflow_run' -- Filter out workflow_run-triggered jobs, which have nothing to do with the SHA AND workflow.event != 'repository_dispatch' -- Filter out repository_dispatch-triggered jobs, which have nothing to do with the SHA AND workflow.id in (select id from materialized_views.workflow_run_by_head_sha where head_sha = {sha: String}) + AND ( + {workflowId: Int64} = 0 + OR workflow.id = {workflowId: Int64} -- If a specific workflow ID is provided, filter by it + ) AND job.id in (select id from materialized_views.workflow_job_by_head_sha where head_sha = {sha: String}) AND workflow.repository. 'full_name' = {repo: String } -- UNION AND workflow.name != 'Upload test stats while running' -- Continuously running cron job that cancels itself to avoid running concurrently @@ -84,6 +88,10 @@ WITH job AS ( workflow.event != 'workflow_run' -- Filter out workflow_run-triggered jobs, which have nothing to do with the SHA AND workflow.event != 'repository_dispatch' -- Filter out repository_dispatch-triggered jobs, which have nothing to do with the SHA AND workflow.id in (select id from materialized_views.workflow_run_by_head_sha where head_sha = {sha: String}) + AND ( + {workflowId: Int64} = 0 + OR workflow.id = {workflowId: Int64} -- If a specific workflow ID is provided, filter by it + ) AND workflow.repository.full_name = {repo: String } AND workflow.name != 'Upload test stats while running' -- Continuously running cron job that cancels itself to avoid running concurrently ) diff --git a/torchci/components/commit/CommitStatus.tsx b/torchci/components/commit/CommitStatus.tsx index 1fdcb35a31..7487afe4c3 100644 --- a/torchci/components/commit/CommitStatus.tsx +++ b/torchci/components/commit/CommitStatus.tsx @@ -54,10 +54,12 @@ function getBoxOrdering(jobs: JobData[], wideBoxes: Set) { function WorkflowsContainer({ jobs, unstableIssues, + workflowIdsByName, repoFullName, }: { jobs: JobData[]; unstableIssues: IssueData[]; + workflowIdsByName: Record; repoFullName: string; }) { useScrollTo(); @@ -81,6 +83,7 @@ function WorkflowsContainer({ repoFullName={repoFullName} key={workflowName} workflowName={workflowName} + allWorkflowIds={workflowIdsByName[workflowName] || []} jobs={jobs} unstableIssues={unstableIssues} wide={wideBoxes.has(workflowName)} @@ -106,6 +109,7 @@ export default function CommitStatus({ repoName, commit, jobs, + workflowIdsByName, isCommitPage, unstableIssues, }: { @@ -113,6 +117,7 @@ export default function CommitStatus({ repoName: string; commit: CommitData; jobs: JobData[]; + workflowIdsByName: Record; isCommitPage: boolean; unstableIssues: IssueData[]; }) { @@ -174,6 +179,7 @@ export default function CommitStatus({ /> diff --git a/torchci/components/commit/WorkflowBox.tsx b/torchci/components/commit/WorkflowBox.tsx index e49d67f61e..a83eff54c5 100644 --- a/torchci/components/commit/WorkflowBox.tsx +++ b/torchci/components/commit/WorkflowBox.tsx @@ -1,4 +1,4 @@ -import { Button, Stack, styled, Typography } from "@mui/material"; +import { Button, Stack, styled, Tooltip, Typography } from "@mui/material"; import { TestInfo } from "components/additionalTestInfo/TestInfo"; import styles from "components/commit/commit.module.css"; import LogViewer, { SearchLogViewer } from "components/common/log/LogViewer"; @@ -14,7 +14,10 @@ import { ListUtilizationMetadataInfoAPIResponse, UtilizationMetadataInfo, } from "lib/utilization/types"; +import { CommitApiResponse } from "pages/api/[repoOwner]/[repoName]/commit/[sha]"; import React, { useEffect, useState } from "react"; +import { FaInfoCircle } from "react-icons/fa"; +import useSWR from "swr"; import useSWRImmutable from "swr/immutable"; function sortJobsByConclusion(jobA: JobData, jobB: JobData): number { @@ -140,16 +143,32 @@ export default function WorkflowBox({ unstableIssues, wide, setWide, + allWorkflowIds, repoFullName, }: { workflowName: string; jobs: JobData[]; unstableIssues: IssueData[]; wide: boolean; + allWorkflowIds: number[]; setWide: any; repoFullName: string; }) { - const workflowId = jobs[0].workflowId; + const [selectedWorkflowId, setSelectedWorkflowId] = useState< + string | undefined + >(undefined); + const workflowId = selectedWorkflowId || jobs[0].workflowId; + + const { data: jobsFromSelectedWorkflowId } = useSWR( + selectedWorkflowId && + `/api/${repoFullName}/commit/${jobs[0].sha}?workflowId=${selectedWorkflowId}`, + fetcher + ); + + if (selectedWorkflowId) { + jobs = jobsFromSelectedWorkflowId?.jobs || []; + } + const isFailed = jobs.some(isFailedJob) !== false; const workflowClass = isFailed ? styles.workflowBoxFail @@ -163,6 +182,7 @@ export default function WorkflowBox({ const { artifacts, error } = useArtifacts(jobs.map((job) => job.workflowId)); const [artifactsToShow, setArtifactsToShow] = useState(new Set()); const groupedArtifacts = groupArtifacts(jobs, artifacts); + const [searchString, setSearchString] = useState(""); const [searchRes, setSearchRes] = useState<{ results: Map; @@ -196,7 +216,28 @@ export default function WorkflowBox({ Job Status - + + + + + + + + +
{repoFullName == "pytorch/pytorch" && (