Skip to content

Commit 25dc424

Browse files
authored
Merge pull request #196 from gitpod-io/wv/fix-transitive-dependency-cache-miss
Build dependencies of cached packages
2 parents 63f77ba + b31a04f commit 25dc424

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

pkg/leeway/build.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -605,15 +605,6 @@ func (p *Package) buildDependencies(buildctx *buildContext) (err error) {
605605
}
606606

607607
func (p *Package) build(buildctx *buildContext) (err error) {
608-
_, alreadyBuilt := buildctx.LocalCache.Location(p)
609-
610-
if p.Ephemeral {
611-
// ephemeral packages always require a rebuild
612-
} else if alreadyBuilt {
613-
log.WithField("package", p.FullName()).Debug("already built")
614-
return nil
615-
}
616-
617608
doBuild := buildctx.ObtainBuildLock(p)
618609
if !doBuild {
619610
return nil
@@ -630,6 +621,16 @@ func (p *Package) build(buildctx *buildContext) (err error) {
630621
return err
631622
}
632623

624+
// Return early if the package is already built. We're explicitly performing this check after having built all the dependencies.
625+
// Previously we had it before, but that resulted in failed builds as there's no guarantee that the cache will contain transitive dependencies; in our case they were sometimes evicted from the cache due to S3 lifecycle rules
626+
_, alreadyBuilt := buildctx.LocalCache.Location(p)
627+
if p.Ephemeral {
628+
// ephemeral packages always require a rebuild
629+
} else if alreadyBuilt {
630+
log.WithField("package", p.FullName()).Debug("already built")
631+
return nil
632+
}
633+
633634
pkgRep := &PackageBuildReport{
634635
phaseEnter: make(map[PackageBuildPhase]time.Time),
635636
phaseDone: make(map[PackageBuildPhase]time.Time),

pkg/leeway/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
package leeway
22

33
// Version is the version of this leeway build
4-
var Version string = "unkown"
4+
var Version string = "unknown"

pkg/leeway/workspace.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,13 @@ func loadWorkspace(ctx context.Context, path string, args Arguments, variant str
230230
if err != nil {
231231
return Workspace{}, err
232232
}
233-
ignores = strings.Split(string(fc), "\n")
233+
split := strings.Split(string(fc), "\n")
234+
for _, s := range split {
235+
if s == "" {
236+
continue
237+
}
238+
ignores = append(ignores, s)
239+
}
234240
}
235241
otherWS, err := doublestar.Glob(workspace.Origin, "**/WORKSPACE.yaml", workspace.ShouldIgnoreSource)
236242
if err != nil {

0 commit comments

Comments
 (0)