Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

[DO NOT MERGE, need fix verification] manifest: skip ProjectRoot validation for alt source #1527

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions gps/solver.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,17 @@ func (e DeductionErrs) Error() string {

// ValidateParams validates the solver parameters to ensure solving can be completed.
func ValidateParams(params SolveParameters, sm SourceManager) error {
// Create a list of projects to skip project root deduction. This is
// required for projects with an alternate source.
altSrc := make(map[string]bool)
if params.Manifest != nil {
for proj, prop := range params.Manifest.DependencyConstraints() {
if prop.Source != "" {
altSrc[string(proj)] = true
}
}
}

// Ensure that all packages are deducible without issues.
var deducePkgsGroup sync.WaitGroup
deductionErrs := make(DeductionErrs)
Expand All @@ -420,6 +431,10 @@ func ValidateParams(params SolveParameters, sm SourceManager) error {
}

for _, ip := range rd.externalImportList(paths.IsStandardImportPath) {
if altSrc[ip] {
// Skip project root deduction for project with alternate source.
continue
}
deducePkgsGroup.Add(1)
go deducePkg(ip, sm)
}
Expand Down
26 changes: 24 additions & 2 deletions manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,37 @@ func ValidateProjectRoots(c *Ctx, m *Manifest, sm gps.SourceManager) error {
}
}

for pr := range m.Constraints {
// A map to register projects with alternate source.
projectsWithAltSrc := make(map[gps.ProjectRoot]bool)

for pr, pp := range m.Constraints {
// If an alternate source is specified, it could be to bypass some network
// reachability issue. Trying to deduce ProjectRoot would fail if the
// the project isn't reachable. Do not validate such ProjectRoots.
if pp.Source != "" {
projectsWithAltSrc[pr] = true
continue
}

wg.Add(1)
go validate(pr)
}
for pr := range m.Ovr {
for pr, pp := range m.Ovr {
// Skip validation for alternate source.
if pp.Source != "" {
projectsWithAltSrc[pr] = true
continue
}

wg.Add(1)
go validate(pr)
}
for pr := range m.PruneOptions.PerProjectOptions {
// Skip validation for alternate source.
if projectsWithAltSrc[pr] {
continue
}

wg.Add(1)
go validate(pr)
}
Expand Down
14 changes: 14 additions & 0 deletions manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,20 @@ func TestValidateProjectRoots(t *testing.T) {
wantError: errInvalidProjectRoot,
wantWarn: []string{},
},
{
name: "skip project root deduction for alternate source",
manifest: Manifest{
Constraints: map[gps.ProjectRoot]gps.ProjectProperties{
// bad ProjectRoot
gps.ProjectRoot("golang.org/x"): {
Constraint: gps.NewBranch("master"),
Source: "github.com/golang/text",
},
},
},
wantError: nil,
wantWarn: []string{},
},
}

h := test.NewHelper(t)
Expand Down