Skip to content
Merged
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
3 changes: 2 additions & 1 deletion CLI-IMPLEMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Status: implementation sequence, updated 2026-11-11. Native Go profiling and binding
commands are implemented, with CI coverage for the relocated CLI and shared YAML resources.
The TypeScript add-on runs from PATH (`rc profile typescript`, `rc plugins list`). Add-on descriptors, `rc doctor`,
The TypeScript and Java add-ons run from PATH (`rc profile typescript`, `rc profile java`, `rc plugins list`). Add-on descriptors, `rc doctor`,
other languages, system-package distribution, and upstream workflow migration remain planned.
Repository: github.com/runtimeconditions/rc-cli; executable and command name: `rc`.
System package and Homebrew formula name: `rc-cli`; releases use independent `vMAJOR.MINOR.PATCH` tags.
Expand Down Expand Up @@ -61,6 +61,7 @@ rc profile generate --dir ./service --out profile.yaml
rc profile go generate --dir ./service --out profile.yaml
rc profile go validate-extensions --dir ./service
rc profile typescript generate --project ./service --name orders --workload-uri https://example.com/orders
rc profile java generate --project ./service --classpath bindings.jar --name orders --workload-uri https://example.com/orders
rc profile python profile generate --project ./service
rc plugins list [--output yaml]
rc doctor [--language go|python|java|...] [--output yaml]
Expand Down
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,27 @@ generation leaves an existing `--out` file unchanged.
Other languages run a separate add-on that `rc` finds on `PATH`. It can come from the
language's own tooling or from a system package, and `rc` does not care which. The
TypeScript profiler is on npm for developers who want it in their npm scripts:
`npm install --global @runtimeconditions/typescript-profiler`. System packages for Homebrew,
`npm install --global @runtimeconditions/typescript-profiler`. The Java profiler is a jar that its
launcher, `rc-profiler-java`, runs; download it from the
[releases](https://github.com/runtimeconditions/java-rc-profiler/releases) of
`runtimeconditions/java-rc-profiler` and put the launcher on `PATH`. System packages for Homebrew,
apt, and yum, so that `rc` and its add-ons install the same way on a build server, are planned.

| Command | Purpose |
| --- | --- |
| `rc profile typescript <command> [flags]` | Run the installed TypeScript profiler. |
| `rc profile java <command> [flags]` | Run the installed Java profiler. |
| `rc plugins list [--output yaml]` | Show the Go profiler and each add-on's status, version, and path. |

Everything after `typescript` goes to the add-on unchanged, so it keeps its own flags
(for example `--project` instead of `--dir`). `rc` looks for `rc-profiler-typescript`, then
`runtimeconditions-typescript-profiler`, on `PATH`; `RC_TYPESCRIPT_PROFILER` can name an
absolute path instead. It runs the add-on only if `--version --json` lists the core profile
schema `rc` targets (0.4.0). The add-on's output and exit status pass through.
Everything after `typescript` or `java` goes to the add-on unchanged, so it keeps its own flags
(for example `--project` instead of `--dir`, and `--classpath` for Java). `rc` looks for
`rc-profiler-typescript`, then `runtimeconditions-typescript-profiler`, or `rc-profiler-java`, on `PATH`;
`RC_TYPESCRIPT_PROFILER` or `RC_JAVA_PROFILER` can name an absolute path instead. It runs the add-on only
if `--version --json` lists the core profile schema `rc` targets (0.4.0). The add-on's output and exit
status pass through.

The Java launcher chooses the JDK, not `rc`: `RC_JAVA_HOME`, then `JAVA_HOME`, then the runtime bundled
in its system package, then `java` on `PATH`. It needs JDK 17 or newer and says so when none is found.

## Binding commands

Expand Down
1 change: 1 addition & 0 deletions distribution/nfpm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ homepage: https://github.com/runtimeconditions/rc-cli
license: MIT
suggests:
- rc-profiler-typescript
- rc-profiler-java
contents:
- src: usr
dst: /usr
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/go_profiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestGoValidationLibraryCalls(t *testing.T) {
func TestGoUsageAndHelp(t *testing.T) {
for _, args := range [][]string{
{"profile", "generate", "--unknown"}, {"profile", "generate", "-dir", "."},
{"profile", "go", "generate", "extra"}, {"profile", "java", "generate"},
{"profile", "go", "generate", "extra"}, {"profile", "ruby", "generate"},
{"profile", "validate-extension"}, {"profile", "go", "validate-extension", "--package", ""},
} {
code, out, errOut := invoke(t, args...)
Expand Down
54 changes: 49 additions & 5 deletions internal/cli/plugins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func (f *fakeRunner) Run(_ context.Context, spec process.Spec) (int, error) {

const readyVersion = `{"name":"@runtimeconditions/typescript-profiler","version":"0.2.0","coreSchemas":["0.4.0"]}`

const javaVersion = `{"name":"runtimeconditions-java-profiler","version":"0.1.0","coreSchemas":["0.4.0"]}`

func deps(runner process.Runner, installed ...string) Dependencies {
present := map[string]bool{}
for _, name := range installed {
Expand Down Expand Up @@ -159,11 +161,20 @@ func TestPluginsListReportsEveryStatus(t *testing.T) {
t.Fatalf("an add-on with its own runtime is ready without node: %+v", packaged[1])
}
ready := read(deps(&fakeRunner{version: readyVersion}, "rc-profiler-typescript", "node"))
if len(ready) != 2 || ready[0].Language != "go" || ready[0].Status != "built-in" ||
if len(ready) != 3 || ready[0].Language != "go" || ready[0].Status != "built-in" ||
ready[1].Language != "typescript" || ready[1].Status != "ready" || ready[1].Version != "0.2.0" ||
ready[1].Path != "/usr/bin/rc-profiler-typescript" || ready[1].Origin != "path" {
ready[1].Path != "/usr/bin/rc-profiler-typescript" || ready[1].Origin != "path" ||
ready[2].Language != "java" || ready[2].Status != "missing" {
t.Fatalf("%+v", ready)
}
java := read(deps(&fakeRunner{version: javaVersion}, "rc-profiler-java"))
if java[2].Language != "java" || java[2].Status != "ready" || java[2].Version != "0.1.0" ||
java[2].Path != "/usr/bin/rc-profiler-java" || java[2].Origin != "path" {
t.Fatalf("a Java launcher on PATH is ready without java on PATH: %+v", java[2])
}
if incompatible := read(deps(&fakeRunner{version: `{"name":"x","version":"1","coreSchemas":["0.3.0"]}`}, "rc-profiler-java")); incompatible[2].Status != "incompatible" {
t.Fatalf("%+v", incompatible[2])
}
for status, d := range map[string]Dependencies{
"missing": deps(&fakeRunner{}),
"runtime-missing": deps(&fakeRunner{}, "rc-profiler-typescript"),
Expand All @@ -179,15 +190,16 @@ func TestPluginsListReportsEveryStatus(t *testing.T) {
func TestPluginsListTextAndHelp(t *testing.T) {
code, out, _ := run(t, deps(&fakeRunner{version: readyVersion}, "rc-profiler-typescript", "node"), "plugins", "list")
lines := strings.Split(strings.TrimSpace(out), "\n")
if code != 0 || len(lines) != 3 || !strings.HasPrefix(lines[0], "LANGUAGE") ||
!slices.Equal(strings.Fields(lines[2]), []string{"typescript", "ready", "0.2.0", "/usr/bin/rc-profiler-typescript"}) {
if code != 0 || len(lines) != 4 || !strings.HasPrefix(lines[0], "LANGUAGE") ||
!slices.Equal(strings.Fields(lines[2]), []string{"typescript", "ready", "0.2.0", "/usr/bin/rc-profiler-typescript"}) ||
!slices.Equal(strings.Fields(lines[3]), []string{"java", "missing"}) {
t.Fatalf("code=%d %q", code, out)
}
if code, _, errOut := run(t, deps(&fakeRunner{}), "plugins", "list", "--output", "json"); code != 2 || !strings.Contains(errOut, "unsupported output format") {
t.Fatalf("code=%d %q", code, errOut)
}
code, out, _ = run(t, deps(&fakeRunner{}), "profile", "--help")
if code != 0 || !strings.Contains(out, "typescript") || !strings.Contains(out, "go ") {
if code != 0 || !strings.Contains(out, "typescript") || !strings.Contains(out, "java") || !strings.Contains(out, "go ") {
t.Fatalf("profile help %q", out)
}
}
Expand All @@ -208,3 +220,35 @@ func TestCoreSchemaVersionMatchesTheComponentLock(t *testing.T) {
t.Fatalf("lock says %q, rc targets %q (%v)", lock.GoProfiler.CoreSchema.Version, coreSchemaVersion, err)
}
}

func TestJavaAddOnReceivesItsArgumentsUnchangedAndItsOutputPassesThrough(t *testing.T) {
runner := &fakeRunner{version: javaVersion, output: "profile: yaml\n"}
args := []string{"generate", "--project", "./svc", "--classpath", "a.jar:b.jar", "--name", "orders", "--workload-uri", "https://example.com/o", "--", "--odd", "a b"}
code, out, errOut := run(t, deps(runner, "rc-profiler-java"), append([]string{"profile", "java"}, args...)...)
if code != 0 || out != "profile: yaml\n" || errOut != "" {
t.Fatalf("code=%d out=%q err=%q", code, out, errOut)
}
if len(runner.calls) != 1 || runner.calls[0].Path != "/usr/bin/rc-profiler-java" || !slices.Equal(runner.calls[0].Args, args) {
t.Fatalf("calls: %+v", runner.calls)
}
}

func TestJavaAddOnThatIsNotInstalledSaysHowToGetIt(t *testing.T) {
runner := &fakeRunner{}
code, _, errOut := run(t, deps(runner, "node"), "profile", "java", "generate")
if code != 1 || strings.Count(errOut, "rc:") != 1 || !strings.Contains(errOut, "Java profiler is not installed") ||
!strings.Contains(errOut, "https://github.com/runtimeconditions/java-rc-profiler/releases") || strings.Contains(errOut, "Usage:") {
t.Fatalf("code=%d %q", code, errOut)
}
if len(runner.calls) != 0 {
t.Fatalf("the add-on ran: %+v", runner.calls)
}
}

func TestJavaAddOnForAnotherCoreSchemaIsNotRun(t *testing.T) {
runner := &fakeRunner{version: `{"name":"runtimeconditions-java-profiler","version":"0.1.0","coreSchemas":["0.3.0"]}`}
code, _, errOut := run(t, deps(runner, "rc-profiler-java"), "profile", "java", "generate")
if code != 1 || !strings.Contains(errOut, "0.4.0") || len(runner.calls) != 0 {
t.Fatalf("code=%d %q calls=%+v", code, errOut, runner.calls)
}
}
13 changes: 12 additions & 1 deletion internal/plugins/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,19 @@ var TypeScript = Language{
InstallHint: "npm install --global @runtimeconditions/typescript-profiler",
}

// Java is the Java profiler, a jar that the rc-profiler-java launcher runs on the JDK named by RC_JAVA_HOME or
// JAVA_HOME, or the one bundled in its system package, or java on PATH. It lists no runtime, because the launcher
// looks for the JDK itself and says what is missing, so rc cannot tell from PATH alone whether one is there.
var Java = Language{
ID: "java",
Display: "Java",
Executables: []string{"rc-profiler-java"},
OverrideEnv: "RC_JAVA_PROFILER",
InstallHint: "download rc-profiler-java from https://github.com/runtimeconditions/java-rc-profiler/releases and put it on PATH",
}

// Languages returns the optional languages rc supports.
func Languages() []Language { return []Language{TypeScript} }
func Languages() []Language { return []Language{TypeScript, Java} }

// Finder looks up executables. Tests replace both functions.
type Finder struct {
Expand Down
35 changes: 35 additions & 0 deletions internal/plugins/plugins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,38 @@ func TestDescribeRunsARealExecutable(t *testing.T) {
t.Fatalf("%+v %v", info, err)
}
}

func TestJavaIsFoundByItsLauncherAndNeedsNoRuntimeOnPath(t *testing.T) {
// The launcher picks the JDK itself, so java need not be on PATH for rc to run it.
found, err := finder(map[string]string{"rc-profiler-java": "/usr/bin/rc-profiler-java"}, nil).Find(Java)
if err != nil || found.Path != "/usr/bin/rc-profiler-java" || found.Origin != "path" {
t.Fatalf("%+v %v", found, err)
}
if got := finder(map[string]string{"rc-profiler-java": "/usr/bin/rc-profiler-java"}, nil).MissingRuntime(Java); got != "" {
t.Fatalf("Java lists no runtime, got %q", got)
}
// Only the launcher counts; the jar's own name is not an executable.
if _, err := finder(map[string]string{"runtimeconditions-java-profiler": "/usr/bin/x"}, nil).Find(Java); err == nil {
t.Fatal("found an add-on that is not the launcher")
}
}

func TestJavaMissingSaysHowToInstallIt(t *testing.T) {
_, err := finder(map[string]string{}, nil).Find(Java)
if err == nil {
t.Fatal("expected an error")
}
for _, want := range []string{"Java profiler is not installed", "rc-profiler-java", "install it with: " + Java.InstallHint, "RC_JAVA_PROFILER"} {
if !strings.Contains(err.Error(), want) {
t.Errorf("%q is missing from %q", want, err)
}
}
}

func TestJavaOverrideNamesAnAbsoluteExecutable(t *testing.T) {
installed := map[string]string{"/opt/java/rc-profiler-java": "/opt/java/rc-profiler-java"}
found, err := finder(installed, map[string]string{Java.OverrideEnv: "/opt/java/rc-profiler-java"}).Find(Java)
if err != nil || found.Path != "/opt/java/rc-profiler-java" || found.Origin != "override" {
t.Fatalf("%+v %v", found, err)
}
}
Loading