Bundles go through oci-artifact-registry and answer the seat's reference; a trunk package is packed under the builder's version and published through npm-package-registry, so the holder can check it with the builder. Reads are anonymous, so the write pair, the sealed secret and the store's address go. The one-part sender moves into buildstep for both build modules, so the move to the registry clients is made in one place. Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
64 lines
2.5 KiB
Go
64 lines
2.5 KiB
Go
//go:build integration
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/forgekey"
|
|
)
|
|
|
|
// 1587-S20 (ADR 0498 §5), CAT-BN3 (design 51 *Publishing*): the real npm packs a trunk build's package under the
|
|
// version the builder gave it, and the module publishes that packed file through npm-package-registry's verbs, with no
|
|
// credential and no npm publish; the workspace's package.json is put back. A candidate publishes nothing at all.
|
|
func TestARealTrunkPackageIsPublishedOnce(t *testing.T) {
|
|
needBubblewrap(t)
|
|
for _, tool := range []string{"node", "npm"} {
|
|
if _, err := exec.LookPath(tool); err != nil {
|
|
t.Skipf("NOT RUN: no %s where this check runs; every build node has it", tool)
|
|
}
|
|
}
|
|
m, _, work := newMachine(t)
|
|
m.Run = forgekey.ExecRunner
|
|
store := withStore(t, m)
|
|
files := map[string]string{}
|
|
for n, c := range sdkFixture {
|
|
files[n] = c
|
|
}
|
|
workspaceWith(t, work, files)
|
|
dir := filepath.Join(work, "w1", "tree")
|
|
before, _ := os.ReadFile(filepath.Join(dir, "package.json"))
|
|
if err := m.installDev(context.Background(), filepath.Join(work, "w1"), dir, "."); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
args := map[string]any{"workspace": "w1", "module": ".", "artifact": "lib"}
|
|
if out, err := m.build(context.Background(), args); err != nil || out.(BuildResult).Reference != "" || len(store.published) != 0 {
|
|
t.Fatalf("a candidate: %+v %v, %d published", out, err, len(store.published))
|
|
}
|
|
args["publish"], args["version"], args["seat"] = true, "9.9.10", "npm-package-registry"
|
|
out, err := m.build(context.Background(), args)
|
|
if err != nil || out.(BuildResult).Reference != "@novox/mesh-sdk@9.9.10" || len(store.published) != 1 {
|
|
t.Fatalf("a trunk build: %+v %v, %d published", out, err, len(store.published))
|
|
}
|
|
p := store.published[0]
|
|
tgz := store.blobs[p.Name+"@"+p.Digest]
|
|
if p.Name != "@novox/mesh-sdk" || p.Version != "9.9.10" || p.Kind != "package" || digestOf(tgz) != out.(BuildResult).Digest {
|
|
t.Errorf("published %+v (%d bytes), the build packed %s", p, len(tgz), out.(BuildResult).Digest)
|
|
}
|
|
into := t.TempDir()
|
|
if err := unpackPackage(tgz, into); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if raw, _ := os.ReadFile(filepath.Join(into, "package.json")); !strings.Contains(string(raw), `"version": "9.9.10"`) {
|
|
t.Errorf("the packed package.json is %s, want the builder's version", raw)
|
|
}
|
|
if after, _ := os.ReadFile(filepath.Join(dir, "package.json")); string(after) != string(before) {
|
|
t.Errorf("the workspace's package.json was not put back: %s", after)
|
|
}
|
|
}
|