Files
mesh-catalog/modules/mesh-build-node/cmd/mesh-build-node/lint.go
T
jschoubben 0b834bbca7 mesh-build-node-narrowed-packages: a package narrowed out of a step's workspace is no module of it
A step of one TypeScript package of a module with several (mesh-contracts' root:
ts-meshbroker beside ts-meshrecovery, pipeline main.3 of 2026-11-20) fetches a workspace
narrowed to that package's path. The fetch and the lint and test levels read every package
artifact of the manifest, and one whose path the narrowing left out fell back to the
module's directory, which holds no lock: every TypeScript step of mesh-contracts ended
"could not run: the package in . has no package-lock.json". Such a package is now left
out of the fetch's install and of the levels' targets; an unnarrowed tree is read as before.

Builds: design 47 H H-A-136 (a step's workspace holds the artifact's paths; nothing else is fetched), ADR 0499 clause 4
2026-11-20 16:01:19 +01:00

57 lines
2.3 KiB
Go

package main
import (
"context"
"fmt"
"path/filepath"
sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun"
)
// **The type-check is a TypeScript artifact's pipeline step lint** (design 47 G §328 *Lint per language*: Go's lint is the Go
// build module's linter, TypeScript's the type-check; §22: lint is a step the build seats serve; §24: asked on a work queue,
// its end said as an event). It takes {"workspace", "dir"} as the lint step of mesh-build-go does and runs tsc over each
// TypeScript package of the module's directory (testTargets, the way the unit level finds them), without emitting: a package
// with no .ts file has nothing to lint, and nothing at all ends the step `nothing to run`. A failure is the step's, naming
// the tsc output as the unit level names it; a tsc that could not start is an error, never a verdict.
func (m *Module) lintStep(ctx context.Context, args map[string]any) (any, error) {
workspace, _ := args["workspace"].(string)
dir, _ := args["dir"].(string)
root, mdir, err := m.moduleDirOf(workspace, dir)
if err != nil {
return nil, err
}
targets, err := testTargets(mdir, filepath.ToSlash(filepath.Clean(dir)), narrowed(filepath.Join(root, "tree")))
if err != nil {
return nil, err
}
var failed []Failure
linted := false
for _, tg := range targets {
sources, err := typeScriptFiles(tg.dir)
if err != nil {
return nil, err
}
if len(sources) == 0 {
continue
}
linted = true
if err := m.provide(root); err != nil {
return nil, fmt.Errorf("providing the toolchain's packages to the workspace: %w", err)
}
r := m.runIn(ctx, root, false, tg.dir, nil, "node", m.typeCheck(tg.dir, sources)...)
if r.Err != "" {
return nil, fmt.Errorf("type-check could not be run: status %d %s: %s", r.Status, r.Err, firstLine(r.Stderr))
}
if r.Status != 0 {
failed = append(failed, testFailures(tg.where, "type-check", tg.dir, r, "")...)
}
}
return steprun.LintAnswer{Failed: failed, Nothing: !linted}, nil
}
// A-489b: Has says whether this node has a need a package's tests name (sdkstep.AskNeeds): the need node-build-node is this module's own
// (a TypeScript package's tests run through it); any other it lacks.
func (m *Module) Has(need string) bool { return need == sdkstep.NeedNodeBuildNode }