@@ -13,13 +13,21 @@ import createStyles from '@mui/styles/createStyles';
13
13
import withStyles from '@mui/styles/withStyles' ;
14
14
import GetApp from '@mui/icons-material/GetApp' ;
15
15
import Fab from '@mui/material/Fab' ;
16
- import { TaskCommandLogsTailQuery } from './__generated__/TaskCommandLogsTailQuery.graphql' ;
17
- import { TaskCommandStatus } from './__generated__/TaskCommandList_task.graphql' ;
16
+ import {
17
+ TaskCommandLogsTailQuery ,
18
+ TaskCommandLogsTailQueryResponse ,
19
+ } from './__generated__/TaskCommandLogsTailQuery.graphql' ;
20
+ import { TaskCommandStatus , TaskCommandType } from './__generated__/TaskCommandList_task.graphql' ;
18
21
19
22
function logURL ( taskId : string , command ) {
20
23
return 'https://api.cirrus-ci.com/v1/task/' + taskId + '/logs/' + command . name + '.log' ;
21
24
}
22
25
26
+ function cacheURL ( taskId : string , executionInfo ) {
27
+ let cacheKey = executionInfo . cacheRetrievalAttempts . hits [ 0 ] . key ;
28
+ return 'https://api.cirrus-ci.com/v1/task/' + taskId + '/caches/' + cacheKey + '.tar.gz' ;
29
+ }
30
+
23
31
let styles = theme =>
24
32
createStyles ( {
25
33
actionButtons : {
@@ -36,8 +44,10 @@ interface RealTimeLogsProps extends WithStyles<typeof styles> {
36
44
command : {
37
45
name : string ;
38
46
status : TaskCommandStatus ;
47
+ type : TaskCommandType ;
39
48
} ;
40
49
initialLogLines : ReadonlyArray < string > ;
50
+ executionInfo : TaskCommandLogsTailQueryResponse [ 'task' ] [ 'executionInfo' ] ;
41
51
}
42
52
43
53
function TaskCommandRealTimeLogs ( props : RealTimeLogsProps ) {
@@ -55,14 +65,15 @@ function TaskCommandRealTimeLogs(props: RealTimeLogsProps) {
55
65
return ( ) => closable ( ) ;
56
66
} , [ realTimeLogs , props . taskId , props . command . name , additionalLogs ] ) ;
57
67
58
- let { classes, taskId, command, initialLogLines } = props ;
68
+ let { classes, taskId, command, initialLogLines, executionInfo } = props ;
69
+
59
70
let inProgress = ! isTaskCommandFinalStatus ( command . status ) ;
60
71
let downloadButton = (
61
72
< div className = { classes . actionButtons } >
62
73
< Fab
63
74
variant = "circular"
64
75
className = { classes . downloadButton }
65
- href = { logURL ( taskId , command ) }
76
+ href = { command . type === 'UPLOAD_CACHE' ? cacheURL ( taskId , executionInfo ) : logURL ( taskId , command ) }
66
77
target = "_blank"
67
78
rel = "noopener noreferrer"
68
79
>
@@ -86,6 +97,7 @@ interface TaskCommandLogsProps extends WithStyles<typeof styles> {
86
97
command : {
87
98
name : string ;
88
99
status : TaskCommandStatus ;
100
+ type : TaskCommandType ;
89
101
} ;
90
102
}
91
103
@@ -98,6 +110,14 @@ function TaskCommandLogs(props: TaskCommandLogsProps) {
98
110
query TaskCommandLogsTailQuery($taskId: ID!, $commandName: String!) {
99
111
task(id: $taskId) {
100
112
commandLogsTail(name: $commandName)
113
+ executionInfo {
114
+ cacheRetrievalAttempts {
115
+ hits {
116
+ key
117
+ valid
118
+ }
119
+ }
120
+ }
101
121
}
102
122
}
103
123
` }
@@ -109,7 +129,13 @@ function TaskCommandLogs(props: TaskCommandLogsProps) {
109
129
</ div >
110
130
) ;
111
131
}
112
- return < TaskCommandRealTimeLogs initialLogLines = { response . props . task . commandLogsTail || [ ] } { ...props } /> ;
132
+ return (
133
+ < TaskCommandRealTimeLogs
134
+ initialLogLines = { response . props . task . commandLogsTail || [ ] }
135
+ executionInfo = { response . props . task . executionInfo }
136
+ { ...props }
137
+ />
138
+ ) ;
113
139
} }
114
140
/>
115
141
) ;
0 commit comments