Skip to content

Commit

Permalink
Merge pull request #196 from gitpod-io/wv/fix-transitive-dependency-c…
Browse files Browse the repository at this point in the history
…ache-miss

Build dependencies of cached packages
  • Loading branch information
WVerlaek authored Dec 19, 2024
2 parents 63f77ba + b31a04f commit 25dc424
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
19 changes: 10 additions & 9 deletions pkg/leeway/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,15 +605,6 @@ func (p *Package) buildDependencies(buildctx *buildContext) (err error) {
}

func (p *Package) build(buildctx *buildContext) (err error) {
_, alreadyBuilt := buildctx.LocalCache.Location(p)

if p.Ephemeral {
// ephemeral packages always require a rebuild
} else if alreadyBuilt {
log.WithField("package", p.FullName()).Debug("already built")
return nil
}

doBuild := buildctx.ObtainBuildLock(p)
if !doBuild {
return nil
Expand All @@ -630,6 +621,16 @@ func (p *Package) build(buildctx *buildContext) (err error) {
return err
}

// Return early if the package is already built. We're explicitly performing this check after having built all the dependencies.
// 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
_, alreadyBuilt := buildctx.LocalCache.Location(p)
if p.Ephemeral {
// ephemeral packages always require a rebuild
} else if alreadyBuilt {
log.WithField("package", p.FullName()).Debug("already built")
return nil
}

pkgRep := &PackageBuildReport{
phaseEnter: make(map[PackageBuildPhase]time.Time),
phaseDone: make(map[PackageBuildPhase]time.Time),
Expand Down
2 changes: 1 addition & 1 deletion pkg/leeway/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package leeway

// Version is the version of this leeway build
var Version string = "unkown"
var Version string = "unknown"
8 changes: 7 additions & 1 deletion pkg/leeway/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,13 @@ func loadWorkspace(ctx context.Context, path string, args Arguments, variant str
if err != nil {
return Workspace{}, err
}
ignores = strings.Split(string(fc), "\n")
split := strings.Split(string(fc), "\n")
for _, s := range split {
if s == "" {
continue
}
ignores = append(ignores, s)
}
}
otherWS, err := doublestar.Glob(workspace.Origin, "**/WORKSPACE.yaml", workspace.ShouldIgnoreSource)
if err != nil {
Expand Down

0 comments on commit 25dc424

Please sign in to comment.