Resolve deps before compiling

This commit is contained in:
Ettore Di Giacinto
2019-11-12 08:48:07 +01:00
parent e0aa92efa4
commit 4c1c7451e7
4 changed files with 12 additions and 3 deletions

View File

@@ -189,6 +189,11 @@ func (cs *LuetCompiler) compileWithImage(image, buildertaggedImage, packageImage
func (cs *LuetCompiler) Compile(concurrency int, keepPermissions bool, p CompilationSpec) (Artifact, error) { func (cs *LuetCompiler) Compile(concurrency int, keepPermissions bool, p CompilationSpec) (Artifact, error) {
Debug("Compiling " + p.GetPackage().GetName()) Debug("Compiling " + p.GetPackage().GetName())
err := cs.Tree().ResolveDeps(concurrency) // FIXME: This should be cached in CompileParallel, and not done for each compilation
if err != nil {
return nil, errors.Wrap(err, "While resoolving tree world deps")
}
if len(p.GetPackage().GetRequires()) == 0 && p.GetImage() == "" { if len(p.GetPackage().GetRequires()) == 0 && p.GetImage() == "" {
Error("Package with no deps and no seed image supplied, bailing out") Error("Package with no deps and no seed image supplied, bailing out")
return nil, errors.New("Package " + p.GetPackage().GetFingerPrint() + "with no deps and no seed image supplied, bailing out") return nil, errors.New("Package " + p.GetPackage().GetFingerPrint() + "with no deps and no seed image supplied, bailing out")

View File

@@ -106,7 +106,7 @@ var _ = Describe("Compiler", func() {
}) })
Context("Reconstruct image tree", func() { Context("Reconstruct image tree", func() {
FIt("Compiles it", func() { It("Compiles it", func() {
generalRecipe := tree.NewCompilerRecipe() generalRecipe := tree.NewCompilerRecipe()
tmpdir, err := ioutil.TempDir("", "package") tmpdir, err := ioutil.TempDir("", "package")
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
@@ -125,12 +125,12 @@ var _ = Describe("Compiler", func() {
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
spec3, err := compiler.FromPackage(&pkg.DefaultPackage{Name: "d", Category: "test", Version: "1.0"}) spec3, err := compiler.FromPackage(&pkg.DefaultPackage{Name: "d", Category: "test", Version: "1.0"})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(spec3.GetPackage().GetRequires()[0].GetName()).To(Equal("c"))
Expect(spec.GetPackage().GetPath()).ToNot(Equal(""))
spec.SetOutputPath(tmpdir) spec.SetOutputPath(tmpdir)
spec2.SetOutputPath(tmpdir) spec2.SetOutputPath(tmpdir)
spec3.SetOutputPath(tmpdir) spec3.SetOutputPath(tmpdir)
artifacts, errs := compiler.CompileParallel(2, false, []CompilationSpec{spec, spec2, spec3}) artifacts, errs := compiler.CompileParallel(2, false, []CompilationSpec{spec, spec2, spec3})
Expect(errs).To(BeNil()) Expect(errs).To(BeNil())
Expect(len(artifacts)).To(Equal(3)) Expect(len(artifacts)).To(Equal(3))

View File

@@ -32,6 +32,9 @@ func Spinner(i int) {
func SpinnerText(suffix, prefix string) { func SpinnerText(suffix, prefix string) {
m.Lock() m.Lock()
defer m.Unlock() defer m.Unlock()
if s == nil {
s = spinner.New(spinner.CharSets[22], 100*time.Millisecond) // Build our new spinner
}
s.Suffix = Bold(Magenta(suffix)).BgBlack().String() s.Suffix = Bold(Magenta(suffix)).BgBlack().String()
s.Prefix = Bold(Cyan(prefix)).String() s.Prefix = Bold(Cyan(prefix)).String()
} }

View File

@@ -77,6 +77,7 @@ type Tree interface {
SetPackageSet(s PackageSet) SetPackageSet(s PackageSet)
World() ([]Package, error) World() ([]Package, error)
FindPackage(Package) (Package, error) FindPackage(Package) (Package, error)
ResolveDeps(int) error
} }
// >> Unmarshallers // >> Unmarshallers