Merge branch 'fix/447-builder-names-dir' into prep/delivery
This commit is contained in:
@@ -227,7 +227,7 @@ func (e EngineCompositions) inSandbox(ctx context.Context, c *Case, head, node s
|
|||||||
return a, err
|
return a, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
job := buildstep.ComposeJob{Fetch: buildstep.Fetch{Repository: nodeEngineRepo, Commit: head, Packages: packagesFor(e.Published, c, nodeEngineRepo)}, Dir: meshcatalogclient.RootPath,
|
job := buildstep.ComposeJob{Fetch: buildstep.Fetch{Repository: nodeEngineRepo, Commit: head, Dir: meshcatalogclient.RootPath, Packages: packagesFor(e.Published, c, nodeEngineRepo)}, Dir: meshcatalogclient.RootPath,
|
||||||
Package: composer.Package, Request: raw, Reader: "the node-engine head of " + c.Group}
|
Package: composer.Package, Request: raw, Reader: "the node-engine head of " + c.Group}
|
||||||
// The ask travels on the bus, whose message limit a whole request passes (1.2 MB for a large node): it goes packed.
|
// The ask travels on the bus, whose message limit a whole request passes (1.2 MB for a large node): it goes packed.
|
||||||
if err := job.PackRequest(raw); err != nil {
|
if err := job.PackRequest(raw); err != nil {
|
||||||
|
|||||||
@@ -219,6 +219,9 @@ func TestTheCompositionIsMadeFromTheEnginesAnswers(t *testing.T) {
|
|||||||
t.Fatalf("asked %+v, jobs %+v: want the input asked and one job", e.asked, sb.jobs)
|
t.Fatalf("asked %+v, jobs %+v: want the input asked and one job", e.asked, sb.jobs)
|
||||||
}
|
}
|
||||||
job := sb.jobs[0]
|
job := sb.jobs[0]
|
||||||
|
if job.Fetch.Dir == "" || job.Fetch.Dir != job.Dir { // a build is for one module: its fetch names the directory (A-447b)
|
||||||
|
t.Errorf("the compose job's fetch names the directory %q, want its module's %q", job.Fetch.Dir, job.Dir)
|
||||||
|
}
|
||||||
var req composer.Request
|
var req composer.Request
|
||||||
if len(job.Request) == 0 || job.Request[0] != '"' {
|
if len(job.Request) == 0 || job.Request[0] != '"' {
|
||||||
t.Errorf("the request went whole, not packed (issue 1966): %.60s", job.Request)
|
t.Errorf("the request went whole, not packed (issue 1966): %.60s", job.Request)
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ func (st *state) runJudge(ctx context.Context, req composer.Request, touched []s
|
|||||||
st.fail(st.goModule(), err.Error())
|
st.fail(st.goModule(), err.Error())
|
||||||
return change, trunk, false
|
return change, trunk, false
|
||||||
}
|
}
|
||||||
job := buildstep.ComposeJob{Fetch: buildstep.Fetch{Repository: DeliveryRepository, Commit: commit, Packages: versions}, Dir: JudgeDir,
|
job := buildstep.ComposeJob{Fetch: buildstep.Fetch{Repository: DeliveryRepository, Commit: commit, Dir: JudgeDir, Packages: versions}, Dir: JudgeDir,
|
||||||
Package: JudgePackage, Request: raw, Reader: "the indexer's judge at " + at}
|
Package: JudgePackage, Request: raw, Reader: "the indexer's judge at " + at}
|
||||||
a := buildstep.StepAsk{ID: buildstep.NewID(), Kind: buildstep.AskCheck, Language: buildstep.AskGo, Asker: st.j.Module,
|
a := buildstep.StepAsk{ID: buildstep.NewID(), Kind: buildstep.AskCheck, Language: buildstep.AskGo, Asker: st.j.Module,
|
||||||
At: st.j.now().UTC(), Compose: &job}
|
At: st.j.now().UTC(), Compose: &job}
|
||||||
|
|||||||
@@ -374,7 +374,7 @@ func (s AskSteps) level(ctx context.Context, job sdkstep.CheckJob, level string,
|
|||||||
if s.Digest == nil {
|
if s.Digest == nil {
|
||||||
// A module with no digest (Node) tests each module directory of the tree, those whose tests changed first.
|
// A module with no digest (Node) tests each module directory of the tree, those whose tests changed first.
|
||||||
for _, priority := range []bool{true, false} {
|
for _, priority := range []bool{true, false} {
|
||||||
for _, dir := range f.Modules {
|
for _, dir := range modulesOf(f.Modules, job.Fetch.Dir) {
|
||||||
if changesTestIn(f.Changed, dir) != priority {
|
if changesTestIn(f.Changed, dir) != priority {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -424,6 +424,23 @@ func (s AskSteps) level(ctx context.Context, job sdkstep.CheckJob, level string,
|
|||||||
return all, nil
|
return all, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// modulesOf are the module directories a fetch answered that a step for the module in dir tests: that directory's and
|
||||||
|
// those under it, never another module's of the repository (design 47 G, A-447c); all of them when the ask names no
|
||||||
|
// directory, or the root.
|
||||||
|
func modulesOf(modules []string, dir string) []string {
|
||||||
|
dir = strings.Trim(path.Clean(dir), "/")
|
||||||
|
if dir == "" || dir == "." {
|
||||||
|
return modules
|
||||||
|
}
|
||||||
|
var out []string
|
||||||
|
for _, m := range modules {
|
||||||
|
if m == dir || strings.HasPrefix(m, dir+"/") {
|
||||||
|
out = append(out, m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
// release removes an ask's workspace, saying a failure: the module's sweep removes it later.
|
// release removes an ask's workspace, saying a failure: the module's sweep removes it later.
|
||||||
func (s AskSteps) release(workspace string) {
|
func (s AskSteps) release(workspace string) {
|
||||||
if workspace == "" || s.Release == nil {
|
if workspace == "" || s.Release == nil {
|
||||||
|
|||||||
@@ -296,6 +296,16 @@ func TestRunAskChecksNodeModulesAndConflicts(t *testing.T) {
|
|||||||
if fmt.Sprint(r.calls[1:]) != `[test {"level":"unit","module":"b","workspace":"/w"} test {"level":"unit","module":"a","workspace":"/w"}]` {
|
if fmt.Sprint(r.calls[1:]) != `[test {"level":"unit","module":"b","workspace":"/w"} test {"level":"unit","module":"a","workspace":"/w"}]` {
|
||||||
t.Fatalf("calls %v", r.calls)
|
t.Fatalf("calls %v", r.calls)
|
||||||
}
|
}
|
||||||
|
// A check asked for the module in a directory tests that directory's modules alone (A-447c).
|
||||||
|
r = &recorder{fetch: map[string]any{"workspace": "/w", "modules": []string{"a", "b", "b/c"}}, tests: map[string]bool{"b": true, "b/c": true}}
|
||||||
|
s = r.steps()
|
||||||
|
s.Digest = nil
|
||||||
|
if _, err := RunAsk(context.Background(), s, ask(sdkstep.CheckJob{Levels: []string{sdkstep.LevelUnit}, Fetch: sdkstep.Fetch{Repository: "novox/x", Commit: runCommit, Dir: "b"}})); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if fmt.Sprint(r.calls[1:]) != `[test {"level":"unit","module":"b","workspace":"/w"} test {"level":"unit","module":"b/c","workspace":"/w"}]` {
|
||||||
|
t.Fatalf("a check for the module b: calls %v", r.calls)
|
||||||
|
}
|
||||||
r = &recorder{fetch: map[string]any{"workspace": "/w", "conflicts": []string{"go.mod"}}}
|
r = &recorder{fetch: map[string]any{"workspace": "/w", "conflicts": []string{"go.mod"}}}
|
||||||
out, err := RunAsk(context.Background(), r.steps(), ask(sdkstep.CheckJob{Levels: []string{sdkstep.LevelUnit}, Fetch: sdkstep.Fetch{Repository: "novox/x", Commit: runCommit}}))
|
out, err := RunAsk(context.Background(), r.steps(), ask(sdkstep.CheckJob{Levels: []string{sdkstep.LevelUnit}, Fetch: sdkstep.Fetch{Repository: "novox/x", Commit: runCommit}}))
|
||||||
if err != nil || len(r.calls) != 1 || len(out.(sdkstep.CheckAnswer).Levels) != 0 {
|
if err != nil || len(r.calls) != 1 || len(out.(sdkstep.CheckAnswer).Levels) != 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user