BM3: the Node build module installs a module's npm tree and publishes it as <module>:node-modules
An install ask's body runs npm ci from the lock with no install script and no link, packs the tree alone under modules/<module>/node_modules, publishes it to the artifact store as the archive <module>:node-modules under the ask's version and answers its reference, which the step's end carries. The package.json npm ci needs is written from the lock's root entry, a lock without one refused. The integration level's setup bound in code goes: half of the level's bound, which each level's script gets as MESH_TEST_LEVEL_BOUND. Builds: design 47 H2 §800; H-A-399 (2), H-A-403, H-A-427
This commit is contained in:
@@ -26,13 +26,28 @@ import (
|
||||
"git.novox.be/novox/mesh-sdk/go/forgekey"
|
||||
)
|
||||
|
||||
// The bounds of a level (ADR 0445 §4).
|
||||
// The bounds of a level (ADR 0445 §4). The integration level's setup bound is half of its bound, never a value of its
|
||||
// own (design 47 H2 §800: the setup bound in code goes), as mesh-sdk's test helpers take theirs from LevelBoundEnv.
|
||||
const (
|
||||
UnitBound = 5 * time.Second
|
||||
IntegrationSetupBound = 30 * time.Second
|
||||
IntegrationRunBound = 60 * time.Second
|
||||
UnitBound = 5 * time.Second
|
||||
IntegrationRunBound = 60 * time.Second
|
||||
)
|
||||
|
||||
// LevelBoundEnv is the word each level's tests get its bound in, as a duration ("1m0s"; design 47 H2 §800): mesh-sdk's
|
||||
// test helpers take a setup bound of half of it.
|
||||
const LevelBoundEnv = "MESH_TEST_LEVEL_BOUND"
|
||||
|
||||
// levelBound is a level's bound.
|
||||
func levelBound(level string) time.Duration {
|
||||
if level == "unit" {
|
||||
return UnitBound
|
||||
}
|
||||
return IntegrationRunBound
|
||||
}
|
||||
|
||||
// integrationSetupBound is the integration level's setup bound: half of its bound (§800).
|
||||
func integrationSetupBound() time.Duration { return IntegrationRunBound / 2 }
|
||||
|
||||
// TestResult is what a test step passes with, with the field names of mesh-build-go's (issue 1290). The step ends
|
||||
// passed whenever the level ran, whatever its verdict, and Passed is the verdict; it ends failed only when the tests
|
||||
// could not be run (no toolchain, a command that cannot start, a workspace that was never fetched).
|
||||
@@ -191,7 +206,7 @@ func (m *Module) testLevel(ctx context.Context, args map[string]any) (*TestResul
|
||||
report := filepath.Join(root, ".mesh-node-test-"+level+".tap")
|
||||
_ = os.Remove(report)
|
||||
env := []string{"PATH=" + binDir(root) + ":" + pathOrDefault(), "npm_config_cache=" + filepath.Join(m.Toolchain.Paths.Cache, "npm"),
|
||||
"NODE_OPTIONS=" + steprun.NodeTestOptions(report)}
|
||||
"NODE_OPTIONS=" + steprun.NodeTestOptions(report), LevelBoundEnv + "=" + levelBound(level).String()}
|
||||
r := m.runIn(ctx, root, false, tg.dir, env, "npm", scriptArgs(script)...)
|
||||
run += m.now().Sub(start)
|
||||
tap, _ := os.ReadFile(report)
|
||||
@@ -223,11 +238,12 @@ func (m *Module) testLevel(ctx context.Context, args map[string]any) (*TestResul
|
||||
}
|
||||
} else {
|
||||
res.Setup, res.Elapsed = check.Seconds(), run.Seconds()
|
||||
res.SetupBound, res.Bound = IntegrationSetupBound.Seconds(), IntegrationRunBound.Seconds()
|
||||
res.OverBound = check > IntegrationSetupBound || run > IntegrationRunBound
|
||||
setup := integrationSetupBound()
|
||||
res.SetupBound, res.Bound = setup.Seconds(), IntegrationRunBound.Seconds()
|
||||
res.OverBound = check > setup || run > IntegrationRunBound
|
||||
if res.OverBound {
|
||||
why = append(why, fmt.Sprintf("the integration level took %.2f s of setup and %.2f s of running, over its bounds of %s and %s",
|
||||
res.Setup, res.Elapsed, IntegrationSetupBound, IntegrationRunBound))
|
||||
res.Setup, res.Elapsed, setup, IntegrationRunBound))
|
||||
}
|
||||
}
|
||||
res.Passed = len(failed) == 0
|
||||
|
||||
Reference in New Issue
Block a user