@@ -8,7 +8,7 @@ import * as uuidv4 from 'uuid/v4';
8
8
import { WorkspaceFactory } from "../../../src/workspace/workspace-factory" ;
9
9
import { injectable , inject } from "inversify" ;
10
10
import { TraceContext } from "@gitpod/gitpod-protocol/lib/util/tracing" ;
11
- import { User , StartPrebuildContext , Workspace , CommitContext , PrebuiltWorkspaceContext , WorkspaceContext , WithSnapshot , WithPrebuild } from "@gitpod/gitpod-protocol" ;
11
+ import { User , StartPrebuildContext , Workspace , CommitContext , PrebuiltWorkspaceContext , WorkspaceContext , WithSnapshot , WithPrebuild , TaskConfig } from "@gitpod/gitpod-protocol" ;
12
12
import { log } from '@gitpod/gitpod-protocol/lib/util/logging' ;
13
13
import { LicenseEvaluator } from '@gitpod/licensor/lib' ;
14
14
import { Feature } from '@gitpod/licensor/lib/api' ;
@@ -66,21 +66,37 @@ export class WorkspaceFactoryEE extends WorkspaceFactory {
66
66
if ( ! parentPrebuild ) {
67
67
continue ;
68
68
}
69
- log . debug ( `Considering parent prebuild for ${ commitContext . revision } ` , parentPrebuild ) ;
70
69
if ( parentPrebuild . state !== 'available' ) {
71
70
continue ;
72
71
}
72
+ log . debug ( `Considering parent prebuild for ${ commitContext . revision } ` , parentPrebuild ) ;
73
73
const buildWorkspace = await this . db . trace ( { span} ) . findById ( parentPrebuild . buildWorkspaceId ) ;
74
74
if ( ! buildWorkspace ) {
75
75
continue ;
76
76
}
77
77
if ( ! ! buildWorkspace . basedOnPrebuildId ) {
78
78
continue ;
79
79
}
80
- if ( buildWorkspace . imageSource !== imageSource ) {
80
+ if ( JSON . stringify ( imageSource ) !== JSON . stringify ( buildWorkspace . imageSource ) ) {
81
+ log . debug ( `Skipping parent prebuild: Outdated image` , {
82
+ imageSource,
83
+ parentImageSource : buildWorkspace . imageSource ,
84
+ } ) ;
81
85
continue ;
82
86
}
83
- if ( buildWorkspace . config . tasks !== config . tasks ) {
87
+ const filterPrebuildTasks = ( tasks : TaskConfig [ ] = [ ] ) => ( tasks
88
+ . map ( task => Object . keys ( task )
89
+ . filter ( key => [ 'before' , 'init' , 'prebuild' ] . includes ( key ) )
90
+ // @ts -ignore
91
+ . reduce ( ( obj , key ) => ( { ...obj , [ key ] : task [ key ] } ) , { } ) )
92
+ . filter ( task => Object . keys ( task ) . length > 0 ) ) ;
93
+ const prebuildTasks = filterPrebuildTasks ( config . tasks ) ;
94
+ const parentPrebuildTasks = filterPrebuildTasks ( buildWorkspace . config . tasks ) ;
95
+ if ( JSON . stringify ( prebuildTasks ) !== JSON . stringify ( parentPrebuildTasks ) ) {
96
+ log . debug ( `Skipping parent prebuild: Outdated prebuild tasks` , {
97
+ prebuildTasks,
98
+ parentPrebuildTasks,
99
+ } ) ;
84
100
continue ;
85
101
}
86
102
const incrementalPrebuildContext : PrebuiltWorkspaceContext = {
0 commit comments