Merge pull request #196 from dagger/fetchgit-cache-fix

pipeline: FetchGit: make a copy of the content to avoid caching issues
This commit is contained in:
Andrea Luzzardi 2021-03-18 14:48:34 -07:00 committed by GitHub
commit 53e98e8ef5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -312,11 +312,7 @@ func (p *Pipeline) Local(ctx context.Context, op *compiler.Value, st llb.State)
// FIXME: Remove the `Copy` and use `Local` directly.
//
// Copy'ing is a costly operation which should be unnecessary.
// However, for a mysterious reason, `llb.Local` is returning a different
// digest at every run, therefore invalidating the cache.
//
// By wrapping `llb.Local` inside `llb.Copy`, we get the same digest for
// the same content.
// However, using llb.Local directly breaks caching sometimes for unknown reasons.
return st.File(
llb.Copy(
llb.Local(
@ -624,10 +620,22 @@ func (p *Pipeline) FetchGit(ctx context.Context, op *compiler.Value, st llb.Stat
if err != nil {
return st, err
}
return llb.Git(
remote,
ref,
llb.WithCustomName(p.vertexNamef("FetchGit %s@%s", remote, ref)),
// FIXME: Remove the `Copy` and use `Git` directly.
//
// Copy'ing is a costly operation which should be unnecessary.
// However, using llb.Git directly breaks caching sometimes for unknown reasons.
return st.File(
llb.Copy(
llb.Git(
remote,
ref,
llb.WithCustomName(p.vertexNamef("FetchGit %s@%s", remote, ref)),
),
"/",
"/",
),
llb.WithCustomName(p.vertexNamef("FetchGit %s@%s [copy]", remote, ref)),
), nil
}