Skip to content

Commit 125226e

Browse files
feat: migrate grove from typescript to rust (#56)
* feat: migrate grove from typescript to rust Rewrite the entire grove CLI from TypeScript/Bun to Rust. - Port all 10 commands: add, go, init, list, pr, prune, remove, self-update, shell-init, sync - Port WorktreeManager git operations using std::process::Command - Port all utility functions (discovery, formatting, config, etc.) - Port 73 unit tests as inline #[cfg(test)] modules - Update CI workflows (ci.yml, release.yml, pr-publish.yml) for Rust cross-compilation targeting Linux and macOS (x64 + arm64) - Remove Windows support (not a supported platform) - Remove all TypeScript artifacts (package.json, tsconfig.json, etc.) - Update README.md development section for Rust/cargo - Update AGENTS.md for Rust-based project setup - Update .gitignore for Rust project structure Co-Authored-By: Warp <agent@warp.dev> * fix: return exit code 1 for invalid commands Customize clap error handling so invalid subcommands return exit code 1 with 'Invalid command' in stderr, matching the behavior expected by integration tests. Co-Authored-By: Warp <agent@warp.dev> * feat: add platform helpers for shell and self-update * chore: refactor git worktree API and add fmt checks * chore: switch pr build to pull_request * feat: move cli validation into clap parsers * chore: restore windows builds and docs * fix: harden windows version update step * fix: avoid non-tty go recursion * fix: harden handling for shell_init methods * chore: switch back to pull_request_target --------- Co-authored-by: Warp <agent@warp.dev>
1 parent 0c71116 commit 125226e

48 files changed

Lines changed: 4688 additions & 4919 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.entire/logs/entire.log

Whitespace-only changes.

.github/workflows/ci.yml

Lines changed: 66 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,66 +5,89 @@ on:
55
branches: [ main ]
66
pull_request:
77
branches: [ main ]
8-
schedule:
9-
- cron: '0 0 * * 1' # Run weekly on Mondays for security checks
108

119
permissions:
1210
security-events: write
1311
contents: read
1412

1513
jobs:
1614
quality:
17-
name: Type Check & Build
15+
name: Check, Test & Build
1816
runs-on: ubuntu-latest
1917
steps:
2018
- name: Checkout
2119
uses: actions/checkout@v4
2220

23-
- name: Set up Bun
24-
uses: oven-sh/setup-bun@v2
21+
- name: Install Rust
22+
uses: dtolnay/rust-toolchain@stable
2523
with:
26-
bun-version: latest
24+
components: rustfmt
2725

28-
- name: Install dependencies
29-
run: bun install
26+
- name: Cache cargo registry & build
27+
uses: actions/cache@v4
28+
with:
29+
path: |
30+
~/.cargo/registry
31+
~/.cargo/git
32+
target
33+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
3034

31-
- name: Type check
32-
run: bun run typecheck
35+
- name: Check
36+
run: cargo check
3337

34-
- name: Run unit tests
35-
run: bun test test/unit
38+
- name: Format check
39+
run: cargo fmt --all -- --check
3640

37-
- name: Build
38-
run: bun run build
41+
- name: Run unit tests
42+
run: cargo test
3943

40-
- name: Build single-file executable
41-
run: bun run build:compile
44+
- name: Build release binary
45+
run: cargo build --release
4246

4347
- name: Upload build artifacts
4448
uses: actions/upload-artifact@v4
4549
with:
4650
name: grove-build
47-
path: |
48-
dist/
49-
grove
51+
path: target/release/grove
5052

51-
security:
52-
name: Security Audit
53-
runs-on: ubuntu-latest
53+
quality-windows:
54+
name: Check, Test & Build (Windows)
55+
runs-on: windows-latest
5456
steps:
5557
- name: Checkout
5658
uses: actions/checkout@v4
5759

58-
- name: Set up Bun
59-
uses: oven-sh/setup-bun@v2
60+
- name: Install Rust
61+
uses: dtolnay/rust-toolchain@stable
6062
with:
61-
bun-version: latest
63+
components: rustfmt
6264

63-
- name: Install dependencies
64-
run: bun install
65+
- name: Cache cargo registry & build
66+
uses: actions/cache@v4
67+
with:
68+
path: |
69+
~/.cargo/registry
70+
~/.cargo/git
71+
target
72+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
73+
74+
- name: Check
75+
run: cargo check
6576

66-
- name: Check for outdated dependencies
67-
run: bun outdated || true
77+
- name: Format check
78+
run: cargo fmt --all -- --check
79+
80+
- name: Run unit tests
81+
run: cargo test
82+
83+
- name: Build release binary
84+
run: cargo build --release
85+
86+
- name: Upload build artifacts
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: grove-build-windows
90+
path: target/release/grove.exe
6891

6992
integration:
7093
name: Integration Tests
@@ -73,22 +96,26 @@ jobs:
7396
- name: Checkout
7497
uses: actions/checkout@v4
7598

76-
- name: Set up Bun
77-
uses: oven-sh/setup-bun@v2
78-
with:
79-
bun-version: latest
99+
- name: Install Rust
100+
uses: dtolnay/rust-toolchain@stable
80101

81-
- name: Install dependencies
82-
run: bun install
102+
- name: Cache cargo registry & build
103+
uses: actions/cache@v4
104+
with:
105+
path: |
106+
~/.cargo/registry
107+
~/.cargo/git
108+
target
109+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
83110

84-
- name: Build single-file executable
85-
run: bun run build:compile
111+
- name: Build release binary
112+
run: cargo build --release
86113

87114
- name: Add grove to PATH
88-
run: echo "${{ github.workspace }}" >> $GITHUB_PATH
115+
run: cp target/release/grove grove && echo "${{ github.workspace }}" >> $GITHUB_PATH
89116

90117
- name: Run integration tests
91118
uses: captainsafia/hone/hone-github-action@main
92119
with:
93120
version: 'preview'
94-
tests: 'test/integration/*.hone'
121+
tests: 'test/integration/*.hone'

.github/workflows/pr-publish.yml

Lines changed: 72 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,45 @@ jobs:
1717
with:
1818
ref: ${{ github.event.pull_request.head.sha }}
1919

20-
- name: Set up Bun
21-
uses: oven-sh/setup-bun@v2
20+
- name: Install Rust
21+
uses: dtolnay/rust-toolchain@stable
2222
with:
23-
bun-version: latest
23+
components: rustfmt
24+
targets: x86_64-unknown-linux-gnu,aarch64-unknown-linux-gnu
2425

25-
- name: Install dependencies
26-
run: bun install
26+
- name: Install cross-compilation tools
27+
run: |
28+
sudo apt-get update
29+
sudo apt-get install -y gcc-aarch64-linux-gnu
2730
2831
- name: Set PR version
2932
id: version
3033
run: |
3134
PR_NUMBER=${{ github.event.pull_request.number }}
3235
COMMIT_SHA=${{ github.event.pull_request.head.sha }}
3336
COMMIT_SHA=${COMMIT_SHA::7}
34-
PACKAGE_VERSION=$(jq -r '.version' package.json)
35-
PR_VERSION="${PACKAGE_VERSION}-pr.${PR_NUMBER}.${COMMIT_SHA}"
37+
CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')
38+
PR_VERSION="${CARGO_VERSION}-pr.${PR_NUMBER}.${COMMIT_SHA}"
3639
echo "VERSION=$PR_VERSION" >> $GITHUB_OUTPUT
3740
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
3841
echo "Generated PR version: ${PR_VERSION}"
42+
sed -i "s/^version = \".*\"/version = \"${PR_VERSION}\"/" Cargo.toml
3943
40-
- name: Update package.json version
41-
run: npm version ${{ steps.version.outputs.VERSION }} --no-git-tag-version --allow-same-version
44+
- name: Format check
45+
run: cargo fmt --all -- --check
4246

4347
- name: Build for Linux x64
44-
run: bun build --compile --minify --sourcemap --target=bun-linux-x64 ./src/index.ts --outfile grove-linux-x64
48+
run: cargo build --release --target x86_64-unknown-linux-gnu
4549

4650
- name: Build for Linux ARM64
47-
run: bun build --compile --minify --sourcemap --target=bun-linux-arm64 ./src/index.ts --outfile grove-linux-arm64
51+
env:
52+
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
53+
run: cargo build --release --target aarch64-unknown-linux-gnu
4854

49-
- name: Build for Windows x64
50-
run: bun build --compile --minify --sourcemap --target=bun-windows-x64 ./src/index.ts --outfile grove-windows-x64.exe
55+
- name: Prepare artifacts
56+
run: |
57+
cp target/x86_64-unknown-linux-gnu/release/grove grove-linux-x64
58+
cp target/aarch64-unknown-linux-gnu/release/grove grove-linux-arm64
5159
5260
- name: Upload Linux executables
5361
uses: actions/upload-artifact@v4
@@ -58,14 +66,6 @@ jobs:
5866
grove-linux-arm64
5967
retention-days: 1
6068

61-
- name: Upload Windows executables
62-
uses: actions/upload-artifact@v4
63-
with:
64-
name: grove-windows-executables
65-
path: |
66-
grove-windows-x64.exe
67-
retention-days: 1
68-
6969
build-macos:
7070
runs-on: macos-latest
7171
needs: build-linux
@@ -76,22 +76,24 @@ jobs:
7676
with:
7777
ref: ${{ github.event.pull_request.head.sha }}
7878

79-
- name: Set up Bun
80-
uses: oven-sh/setup-bun@v2
79+
- name: Install Rust
80+
uses: dtolnay/rust-toolchain@stable
8181
with:
82-
bun-version: latest
83-
84-
- name: Install dependencies
85-
run: bun install
82+
targets: x86_64-apple-darwin,aarch64-apple-darwin
8683

87-
- name: Update package.json version
88-
run: npm version ${{ needs.build-linux.outputs.version }} --no-git-tag-version --allow-same-version
84+
- name: Set version
85+
run: sed -i '' "s/^version = \".*\"/version = \"${{ needs.build-linux.outputs.version }}\"/" Cargo.toml
8986

9087
- name: Build for macOS x64
91-
run: bun build --compile --minify --sourcemap --target=bun-darwin-x64 ./src/index.ts --outfile grove-darwin-x64
88+
run: cargo build --release --target x86_64-apple-darwin
9289

9390
- name: Build for macOS ARM64
94-
run: bun build --compile --minify --sourcemap --target=bun-darwin-arm64 ./src/index.ts --outfile grove-darwin-arm64
91+
run: cargo build --release --target aarch64-apple-darwin
92+
93+
- name: Prepare artifacts
94+
run: |
95+
cp target/x86_64-apple-darwin/release/grove grove-darwin-x64
96+
cp target/aarch64-apple-darwin/release/grove grove-darwin-arm64
9597
9698
- name: Import Code Signing Certificate
9799
env:
@@ -170,9 +172,45 @@ jobs:
170172
grove-darwin-arm64
171173
retention-days: 1
172174

175+
build-windows:
176+
runs-on: windows-latest
177+
needs: build-linux
178+
179+
steps:
180+
- name: Checkout repository
181+
uses: actions/checkout@v4
182+
with:
183+
ref: ${{ github.event.pull_request.head.sha }}
184+
185+
- name: Install Rust
186+
uses: dtolnay/rust-toolchain@stable
187+
188+
- name: Set version
189+
shell: pwsh
190+
run: |
191+
$version = '${{ needs.build-linux.outputs.version }}'
192+
(Get-Content Cargo.toml -Raw) `
193+
-replace '^(version = ").*(")$', "`$1$version`$2" |
194+
Set-Content Cargo.toml
195+
196+
- name: Build for Windows x64
197+
run: cargo build --release --target x86_64-pc-windows-msvc
198+
199+
- name: Prepare artifacts
200+
run: |
201+
copy target\x86_64-pc-windows-msvc\release\grove.exe grove-windows-x64.exe
202+
203+
- name: Upload Windows executable
204+
uses: actions/upload-artifact@v4
205+
with:
206+
name: grove-windows-executable
207+
path: |
208+
grove-windows-x64.exe
209+
retention-days: 1
210+
173211
publish-pr:
174212
runs-on: ubuntu-latest
175-
needs: [build-linux, build-macos] # Windows is built in build-linux job
213+
needs: [build-linux, build-macos, build-windows]
176214
permissions:
177215
contents: read
178216
pull-requests: write
@@ -194,7 +232,7 @@ jobs:
194232
- name: Download Windows executables
195233
uses: actions/download-artifact@v4
196234
with:
197-
name: grove-windows-executables
235+
name: grove-windows-executable
198236
path: ./executables
199237

200238
- name: Upload combined PR executables
@@ -210,7 +248,7 @@ jobs:
210248
name: |
211249
grove-linux-executables
212250
grove-macos-executables
213-
grove-windows-executables
251+
grove-windows-executable
214252
215253
- name: Comment on PR
216254
uses: actions/github-script@v7

0 commit comments

Comments
 (0)