mirror of
https://github.com/harness/drone.git
synced 2025-05-10 22:21:22 +08:00
Console output is duplicated in pull request pipelines (#663)
This commit is contained in:
parent
1c762c6802
commit
12b192cf1c
@ -74,7 +74,7 @@ export function useScheduleJob<T>({
|
|||||||
function sendDataToScheduler(item: T | T[]) {
|
function sendDataToScheduler(item: T | T[]) {
|
||||||
if (Array.isArray(item)) {
|
if (Array.isArray(item)) {
|
||||||
data.current.push(...item)
|
data.current.push(...item)
|
||||||
} else {
|
} else if (item) {
|
||||||
data.current.push(item)
|
data.current.push(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,15 +82,11 @@ const CheckPipelineStep: React.FC<CheckPipelineStepsProps & { step: TypesStep }>
|
|||||||
)
|
)
|
||||||
const lazy =
|
const lazy =
|
||||||
!expanded || isRunning || step.status === ExecutionState.PENDING || step.status === ExecutionState.SKIPPED
|
!expanded || isRunning || step.status === ExecutionState.PENDING || step.status === ExecutionState.SKIPPED
|
||||||
const {
|
const { data, error, loading, refetch } = useGet<LivelogLine[]>({
|
||||||
data: logs,
|
|
||||||
error,
|
|
||||||
loading,
|
|
||||||
refetch
|
|
||||||
} = useGet<LivelogLine[]>({
|
|
||||||
path,
|
path,
|
||||||
lazy: true
|
lazy: true
|
||||||
})
|
})
|
||||||
|
const logs = useMemo(() => data?.map(({ out = '' }) => out), [data])
|
||||||
const [isStreamingDone, setIsStreamingDone] = useState(false)
|
const [isStreamingDone, setIsStreamingDone] = useState(false)
|
||||||
const containerRef = useRef<HTMLDivElement | null>(null)
|
const containerRef = useRef<HTMLDivElement | null>(null)
|
||||||
const [autoCollapse, setAutoCollapse] = useState(false)
|
const [autoCollapse, setAutoCollapse] = useState(false)
|
||||||
@ -140,7 +136,8 @@ const CheckPipelineStep: React.FC<CheckPipelineStepsProps & { step: TypesStep }>
|
|||||||
maxProcessingBlockSize: 100
|
maxProcessingBlockSize: 100
|
||||||
})
|
})
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(
|
||||||
|
function initStreamingLogs() {
|
||||||
if (expanded && isRunning) {
|
if (expanded && isRunning) {
|
||||||
setAutoCollapse(false)
|
setAutoCollapse(false)
|
||||||
|
|
||||||
@ -168,30 +165,33 @@ const CheckPipelineStep: React.FC<CheckPipelineStepsProps & { step: TypesStep }>
|
|||||||
}
|
}
|
||||||
|
|
||||||
return closeEventStream
|
return closeEventStream
|
||||||
}, [expanded, isRunning, showError, path, step.status, closeEventStream, sendStreamLogToRenderer])
|
},
|
||||||
|
[expanded, isRunning, showError, path, step.status, closeEventStream, sendStreamLogToRenderer]
|
||||||
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(
|
||||||
|
function fetchAndRenderCompleteLogs() {
|
||||||
if (!lazy && !error && !isRunning && !isStreamingDone && expanded) {
|
if (!lazy && !error && !isRunning && !isStreamingDone && expanded) {
|
||||||
if (!logs) {
|
if (!logs) {
|
||||||
refetch()
|
refetch()
|
||||||
} else {
|
} else if (Array.isArray(logs)) {
|
||||||
sendCompleteLogsToRenderer(logs.map(({ out = '' }) => out))
|
sendCompleteLogsToRenderer(logs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [lazy, error, logs, refetch, isStreamingDone, expanded, isRunning, sendCompleteLogsToRenderer])
|
},
|
||||||
|
[lazy, error, logs, refetch, isStreamingDone, expanded, isRunning, sendCompleteLogsToRenderer]
|
||||||
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(
|
||||||
|
function autoCollapseWhenStreamingIsDone() {
|
||||||
if (autoCollapse && expanded && step.status === ExecutionState.SUCCESS) {
|
if (autoCollapse && expanded && step.status === ExecutionState.SUCCESS) {
|
||||||
|
setIsStreamingDone(false)
|
||||||
setAutoCollapse(false)
|
setAutoCollapse(false)
|
||||||
setExpanded(false)
|
setExpanded(false)
|
||||||
}
|
}
|
||||||
}, [autoCollapse, expanded, step.status])
|
},
|
||||||
|
[autoCollapse, expanded, step.status]
|
||||||
useEffect(() => {
|
)
|
||||||
if (!isRunning && logs?.length) {
|
|
||||||
sendCompleteLogsToRenderer(logs.map(({ out = '' }) => out))
|
|
||||||
}
|
|
||||||
}, [isRunning, logs, sendCompleteLogsToRenderer])
|
|
||||||
|
|
||||||
useShowRequestError(error, 0)
|
useShowRequestError(error, 0)
|
||||||
|
|
||||||
@ -202,9 +202,6 @@ const CheckPipelineStep: React.FC<CheckPipelineStepsProps & { step: TypesStep }>
|
|||||||
className={cx(css.stepHeader, { [css.expanded]: expanded, [css.selected]: expanded })}
|
className={cx(css.stepHeader, { [css.expanded]: expanded, [css.selected]: expanded })}
|
||||||
{...ButtonRoleProps}
|
{...ButtonRoleProps}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (expanded && isStreamingDone) {
|
|
||||||
setIsStreamingDone(false)
|
|
||||||
}
|
|
||||||
setExpanded(!expanded)
|
setExpanded(!expanded)
|
||||||
}}>
|
}}>
|
||||||
<NavArrowRight color={Utils.getRealCSSColor(Color.GREY_500)} className={cx(css.noShrink, css.chevron)} />
|
<NavArrowRight color={Utils.getRealCSSColor(Color.GREY_500)} className={cx(css.noShrink, css.chevron)} />
|
||||||
|
Loading…
Reference in New Issue
Block a user