feat(sbt): add SBT (Scala Build Tool) support - #752
Conversation
fd6de19 to
f6c44ec
Compare
|
Hey We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes No logic changes — only file moves and import path updates. What you need to doRebase your branch on git fetch origin && git rebase origin/developGit detects renames automatically. If you get import conflicts, update the paths: use crate::git; // now: use crate::cmds::git::git;
use crate::tracking; // now: use crate::core::tracking;
use crate::config; // now: use crate::core::config;
use crate::init; // now: use crate::hooks::init;
use crate::gain; // now: use crate::analytics::gain;Need help rebasing? Tag @aeppling |
f6c44ec to
c985d7b
Compare
|
Hey, thanks for the heads-up! @aeppling , I've rebased on |
f7dc838 to
10ff209
Compare
f650ab6 to
86c89f5
Compare
86c89f5 to
1722d50
Compare
|
hey @aeppling any update on this ? do you think it can be merged ? |
|
Please merge before my wallet getting empty due to our scala project :D |
|
Hi @randomBrainstormer! Re-ran CI on the rebased branch and it hit two regressions from
Could you push a quick fix? After that CI should go green and we can merge. Full job log: https://github.com/rtk-ai/rtk/actions/runs/24583551517/job/76078806371 |
2b89d93 to
b360283
Compare
|
@pszymkowiak Done! Rebased onto develop and pushed a fix for both:
CI should be green now. Let me know if anything else comes up before merge. |
|
Thanks for the quick rebase fix — CI is green now (verified, 11 checks pass on all 3 OS). I built the branch and tested
Two suggestions:
Minor:
|
|
@pszymkowiak good catch on munit , it's the default in Scala 3 templates so definitely not an edge case. Fix was small enough to fold in here:
|
7619c61 to
327a4e1
Compare
|
@pszymkowiak hey, just checking in — munit fix is in, CI is green. Any blockers on your end before this can be merged? |
Adds `rtk sbt` command with three subcommands:
- `rtk sbt test` — ScalaTest output filtering (90% token reduction):
compact single-line on pass, failure details on fail
- `rtk sbt compile` — Strips SBT noise, keeps errors (75% token reduction):
success summary with source count + time
- `rtk sbt run` — Light filtering, strips SBT preamble, keeps program output
- `rtk sbt <other>` — Passthrough for unsupported subcommands
Implementation follows the established go_cmd.rs pattern with lazy_static
regex, tee output recovery on failure, and exit code propagation for CI/CD.
Includes 3 real-output fixtures (pass, fail, compile error) and 11 unit tests
with token savings assertions. Discovery rules updated with 80% savings estimate.
Signed-off-by: Ivan Severino <4858703+randomBrainstormer@users.noreply.github.com>
…dle Mockito/ScalaMock - filter_sbt_test now uses a state machine to capture [info] detail lines that follow a *** FAILED *** marker — covers native ScalaTest assertion messages, Mockito Scala verification failures (WantedButNotInvoked, TooManyActualInvocations), and ScalaMock expectation failures (Unexpected call, Unsatisfied expectation) - run_other detects integration test commands (it:test, IntegrationTest/test, integration-test/test, and any *:test / */test variant) and applies filter_sbt_test instead of raw passthrough - sbt boilerplate cleaned from failure output: TestsFailedException, Total time, and compileIncremental noise removed; failed suite class names retained for navigation - add fixtures: sbt_test_mockito_fail.txt, sbt_test_scalamock_fail.txt, sbt_it_test_pass.txt - 18 tests (was 11), all passing Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…quirement Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add MUNIT_SUMMARY_RE to recognize the munit/discipline-munit summary format: [info] Passed: Total N, Failed N, Errors N, Passed N [info] Failed: Total N, Failed N, Errors N, Passed N munit is the default test framework in Scala 3 templates and is used by major libraries (typelevel/cats via discipline-munit). Without this, filter_sbt_test fell through to the error-recovery path for every munit project, which also printed a misleading "sbt test: parse error" header. Changes: - Add MUNIT_SUMMARY_RE regex and parse branch in filter_sbt_test - Change fallback label from "sbt test: parse error" to "sbt test: errors" - Add munit pass/fail fixtures and tests covering both Scala 2 (ScalaTest) and Scala 3 (munit) output formats
f272aee to
189409b
Compare
|
Thanks for this PR! I am a heavy Scala/SBT user and would really like to finally get this feature. |
|
Hi @pszymkowiak @aeppling , bumping this one. All your review points are addressed (munit fix in, last CI green). Anything still blocking, or is it good to merge? |
…cala-build-tool-support # Conflicts: # src/main.rs
pszymkowiak
left a comment
There was a problem hiding this comment.
Re-approving on the current head (a521234) after a full local verification — the earlier approval predated later commits, so I wanted to confirm the code as it stands now.
Verified locally:
cargo build✅,cargo test(30 sbt tests) ✅- The 8
unwrap()calls are alllazy_static! { Regex::new(...).unwrap() }— the sanctioned RTK pattern, not production panics. - End-to-end on a real Scala/SBT project (installed SBT, ran a project with one passing + one failing ScalaTest):
rtk sbt testcorrectly summarized1 passed, 1 failed, surfaced the failing test (add is broken on purpose/CalcSpec), propagated the non-zero exit code, and wrote the full output to the tee log. Token savings ~88% (154 → 18 words).
Clean, well-tested, real fixtures, no scope creep. LGTM.
Minor non-blocking follow-up idea: including the assertion detail (e.g. 4 did not equal 5) alongside the failing test name would help agents debug without opening the tee log — but the log covers it, so not a blocker.
|
Thanks for the review and approval! @pszymkowiak |
KuSh
left a comment
There was a problem hiding this comment.
Please follow CONTRIBUTING.md, especially the Transparency section.
Also, two tests (test_filter_sbt_compile_empty_input and test_filter_sbt_test_empty_input) appear to conflict with guard.rs’s own test suite (never_worse("", "0 matches") returns ""), so empty input must yield empty output
|
Following up on pszymkowiak’s real-project testing, I also tested Each command was run once directly with SBT and once through RTK. The filtered outputs and reduction figures below are produced by the SBT filter implemented in this PR. Results:
I also ran the SBT-related unit tests, and they all passed. Once the changes requested by @KuSh are addressed, LGTM. |
…code - filter_sbt_test/compile now return empty output for empty input, and all run_* handlers emit via runner::print_with_hint (guard::never_worse), so RTK never emits tokens the underlying command didn't produce (CONTRIBUTING Transparency rule). Flip the two empty-input edge-case tests accordingly. - run_run now preserves scoped tasks (e.g. `exampleJVM/run`) like run_test/ run_compile, instead of forcing `sbt run <task>`. - Anchor the discover/rewrite sbt rule with `(?:\s|$)` so it no longer matches beyond the intended subcommands (e.g. `sbt testify`). - Remove preprocess_sbt_args + helpers and their tests: the rewrite rule never produces `sbt <global-flag> <task>`, so that path was unreachable. - Drop the manually-added CHANGELOG entry (generated at release).
|
Thanks for the careful review @KuSh, and @TaKO8Ki for the scoped-task catch! All fixed in ef38103. Everything passes locally: Back to you when you get a chance, mind kicking off the CI run (it needs a maintainer to approve it) and taking another look? |
|
Following up on the Transparency point KuSh raised, here are some point to address for better standardization, otherwise LGTM :)
runner::run_filtered(cmd, "sbt test", &args.join(" "), filter_sbt_test, RunOptions::with_tee("sbt_test"))
Refer to CONTRIBUTING.md and CODING_PRACTICES.md for the transparence guidelines |
Address the standardization follow-up: replace the manual .output() + track + process::exit blocks in run_test/run_compile/run_run with runner::run_filtered (a small run_task helper), matching go_cmd.rs. The runner applies the never_worse cap, tee hint, tracking, and exit-code propagation centrally. - run_other's it:test branch now goes through the runner too, so an unrecognized output is capped by never_worse instead of being reprinted verbatim plus the tee hint (more than the raw command produced). The passthrough branch uses runner::run_passthrough. - Handlers now return Result<i32> and the exit code is propagated to main instead of calling std::process::exit directly.
|
Thanks @aeppling, all three addressed in 59b604b:
The net result is ~190 fewer lines in the SBT module 🚀 , also all green locally: |
|
Thanks for contributing to RTK @randomBrainstormer ! |
|
Minor problem - single test execution via |
Summary
rtk sbt test— ScalaTest output filtering with 90% token reduction (compact single-line on pass, failure details on fail)rtk sbt compile— strips SBT noise, keeps errors with 75% token reduction (source count + time on success)rtk sbt run— light filtering, strips SBT preamble, passes through program outputrtk sbt <other>— passthrough for any unsupported subcommandImplementation
Follows the established
go_cmd.rspattern:lazy_static!regex for noise/summary/error line detectioncrate::tee::tee_and_hintfor full output recovery on failuresrc/discover/rules.rs) with 80% savings estimateTest plan
sbt_test_pass.txt,sbt_test_fail.txt,sbt_compile_error.txtcargo fmt --all --check— cleancargo clippy --all-targets— cleancargo test --all— 990 passed, 0 failedrtk sbt testin a real Scala project — pending, will validate on a Scala workspaceDocumentation
README.md— addedrtk sbtto build commands section and command rewrite tableCHANGELOG.md— added entry under[Unreleased]Signed-off-by: Ivan Severino 4858703+randomBrainstormer@users.noreply.github.com