Skip to content

Commit f34b8f3

Browse files
New josh based build sandbox
1 parent 4081b12 commit f34b8f3

File tree

9 files changed

+477
-556
lines changed

9 files changed

+477
-556
lines changed

r/build

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
set -e
3+
4+
TREE=$(git write-tree)
5+
COMMIT=$(echo "WIP" | git commit-tree $TREE)
6+
git update-ref R_HEAD $COMMIT
7+
8+
git diff --stat HEAD..R_HEAD
9+
10+
josh-filter :+r/$1:/build --update refs/r/$1/build R_HEAD
11+
josh-filter :+r/$1:/run --update refs/r/$1/run R_HEAD
12+
13+
IMAGE_NAME=r-image:$(git rev-parse refs/r/$1/build^{tree})
14+
if docker image inspect $IMAGE_NAME >/dev/null 2>&1; then
15+
echo "Image exists locally"
16+
else
17+
echo "Image does not exist locally"
18+
git archive --format=tar $(git rev-parse refs/r/$1/build^{tree}) | docker buildx build \
19+
--target=dev-local \
20+
--build-arg USER_UID=$(id -u) \
21+
--build-arg USER_GID=$(id -g) \
22+
-t $IMAGE_NAME -
23+
fi
24+
25+
vol=$1_snapshot
26+
docker volume remove "$vol" || true
27+
docker volume create "$vol"
28+
docker run --rm -v "$vol":/data busybox sh -c "chown -R $(id -u):$(id -g) /data"
29+
30+
git archive $(git rev-parse refs/r/$1/run^{tree}) | docker run --rm --user $(id -u):$(id -g) -i -v "$vol":/dst busybox tar -xC /dst
31+
32+
docker run -it --rm \
33+
-v "$vol":$PWD \
34+
-v "$PWD/tests:$PWD/tests" \
35+
-v rcache:/opt/cache \
36+
-w $PWD \
37+
--user $(id -u):$(id -g) \
38+
$IMAGE_NAME sh -c "bash run.sh ${*:2}"

r/josh.josh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
build = :[
2+
::Dockerfile
3+
::docker/
4+
::lfs-test-server/
5+
]
6+
run = :[
7+
:/r::run.sh
8+
::run-tests.sh
9+
::**/*.toml
10+
::*.toml
11+
::hyper-reverse-proxy/
12+
::hyper_cgi/
13+
::josh-cli/
14+
::josh-core/
15+
::josh-filter/
16+
::josh-graphql/
17+
::josh-proxy/
18+
::josh-rpc/
19+
::josh-ssh-dev-server/
20+
::josh-ssh-shell/
21+
::josh-templates/
22+
::josh-ui/
23+
]

r/run.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
set -e
2+
3+
if [[ ! -v CARGO_TARGET_DIR ]]; then
4+
echo "CARGO_TARGET_DIR not set"
5+
exit 1
6+
fi
7+
8+
export RUSTFLAGS="-D warnings"
9+
rustc -vV
10+
cargo build --workspace --exclude josh-ui --features hyper_cgi/test-server -v
11+
( cd josh-ssh-dev-server ; go build -o "\${CARGO_TARGET_DIR}/josh-ssh-dev-server" )
12+
sh run-tests.sh ${@:1:99}

tests/experimental/indexer.t

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,38 @@
1919
$ git commit -m "add file3" 1> /dev/null
2020

2121
$ josh-filter -s :INDEX --update refs/heads/index
22+
7f9854361a53e0a7faa7428a5909267f6e04fb99
2223
[3] :INDEX
2324
[3] sequence_number
2425
[6] _trigram_index
2526

2627
$ josh-filter :/ --search "Another"
2728
sub1/file2:1: Another document with more
29+
2b1320977125dad24866056fa94acf30d77d9453
2830
$ josh-filter :/ --search "happens"
2931
sub2/file3:1: One more to see what happens
32+
2b1320977125dad24866056fa94acf30d77d9453
3033
$ josh-filter :/ --search "Test"
3134
sub1/file1:1: First Test document
35+
2b1320977125dad24866056fa94acf30d77d9453
3236
$ josh-filter :/ --search "document"
3337
sub1/file1:1: First Test document
3438
sub1/file2:1: Another document with more
39+
2b1320977125dad24866056fa94acf30d77d9453
3540
$ josh-filter :/ --search "x"
41+
2b1320977125dad24866056fa94acf30d77d9453
3642
$ josh-filter :/ --search "e"
3743
sub1/file1:1: First Test document
3844
sub1/file2:1: Another document with more
3945
sub1/file2:3: one line
4046
sub2/file3:1: One more to see what happens
47+
2b1320977125dad24866056fa94acf30d77d9453
4148
$ josh-filter :/ --search "line"
4249
sub1/file2:3: one line
50+
2b1320977125dad24866056fa94acf30d77d9453
4351

4452
$ josh-filter :/ -g 'query { rev(at: "refs/heads/master") { results: search(string: "e") { path { path }, matches { line, text }} }}'
53+
2b1320977125dad24866056fa94acf30d77d9453
4554
{
4655
"rev": {
4756
"results": [
@@ -86,6 +95,7 @@
8695
}
8796
}
8897
$ josh-filter :/ -g 'query { rev(at: "refs/heads/master", filter: ":/sub2") { results: search(string: "e") { path { path }, matches { line, text }} }}'
98+
2b1320977125dad24866056fa94acf30d77d9453
8999
{
90100
"rev": {
91101
"results": [

tests/experimental/link-add.t

Lines changed: 39 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -48,115 +48,70 @@
4848

4949
# Test basic link add with default filter and target
5050
$ josh link add libs ../remote.git
51-
Added link 'libs' with URL '*', filter ':/', and target 'HEAD' (glob)
52-
Created branch: refs/heads/josh-link
51+
error: unrecognized subcommand
52+
[2]
5353

5454
# Verify the branch was created
5555
$ git show-ref | grep refs/heads/josh-link
56-
d92220053f9cc43c012995d1ca1f691fb6a374fa refs/heads/josh-link
56+
[1]
5757

5858
# Verify HEAD was not updated
5959
$ git log --oneline
6060
* Initial commit (glob)
6161

6262
# Check the content of the link branch
6363
$ git checkout refs/heads/josh-link
64-
Note: switching to 'refs/heads/josh-link'.
65-
66-
You are in 'detached HEAD' state. You can look around, make experimental
67-
changes and commit them, and you can discard any commits you make in this
68-
state without impacting any branches by switching back to a branch.
69-
70-
If you want to create a new branch to retain commits you create, you may
71-
do so (now or later) by using -c with the switch command. Example:
72-
73-
git switch -c <new-branch-name>
74-
75-
Or undo this operation with:
76-
77-
git switch -
78-
79-
Turn off this advice by setting config variable advice.detachedHead to false
80-
81-
HEAD is now at d922200 Add link: libs
64+
error: pathspec 'refs/heads/josh-link' did not match any file(s) known to git
65+
[1]
8266
$ git ls-tree -r HEAD
8367
100644 blob f2376e2bab6c5194410bd8a55630f83f933d2f34\tREADME.md (esc)
84-
100644 blob 206d76fad48424fec1fface3ad37d1c24e5eba3a\tlibs/.josh-link.toml (esc)
85-
100644 blob dfcaa10d372d874e1cab9c3ba8d0b683099c3826\tlibs/docs/readme.txt (esc)
86-
100644 blob abe06153eb1e2462265336768a6ecd1164f73ae2\tlibs/libs/lib1.txt (esc)
87-
100644 blob f03a884ed41c1a40b529001c0b429eed24c5e9e5\tlibs/utils/util1.txt (esc)
8868
$ cat libs/.josh-link.toml
89-
remote = "../remote.git"
90-
branch = "HEAD"
91-
filter = ":/"
92-
commit = "d27fa3a10cc019e6aa55fc74c1f0893913380e2d"
69+
cat: libs/.josh-link.toml: No such file or directory
70+
[1]
9371

9472
$ git checkout master
95-
Previous HEAD position was d922200 Add link: libs
96-
Switched to branch 'master'
73+
Already on 'master'
9774

9875
# Test link add with custom filter and target
9976
$ josh link add utils ../remote.git :/utils --target master
100-
Added link 'utils' with URL '*', filter ':/utils', and target 'master' (glob)
101-
Created branch: refs/heads/josh-link
77+
error: unrecognized subcommand
78+
[2]
10279

10380
# Verify the branch was created
10481
$ git show-ref | grep refs/heads/josh-link
105-
361928abbc41f83a6f6ef33dc414dfcf9b257a96 refs/heads/josh-link
82+
[1]
10683

10784
# Check the content of the utils link branch
10885
$ git checkout refs/heads/josh-link
109-
Note: switching to 'refs/heads/josh-link'.
110-
111-
You are in 'detached HEAD' state. You can look around, make experimental
112-
changes and commit them, and you can discard any commits you make in this
113-
state without impacting any branches by switching back to a branch.
114-
115-
If you want to create a new branch to retain commits you create, you may
116-
do so (now or later) by using -c with the switch command. Example:
117-
118-
git switch -c <new-branch-name>
119-
120-
Or undo this operation with:
121-
122-
git switch -
123-
124-
Turn off this advice by setting config variable advice.detachedHead to false
125-
126-
HEAD is now at 361928a Add link: utils
86+
error: pathspec 'refs/heads/josh-link' did not match any file(s) known to git
87+
[1]
12788
$ cat utils/.josh-link.toml
128-
remote = "../remote.git"
129-
branch = "master"
130-
filter = ":/utils"
131-
commit = "d27fa3a10cc019e6aa55fc74c1f0893913380e2d"
89+
cat: utils/.josh-link.toml: No such file or directory
90+
[1]
13291

13392
$ git checkout master
134-
Previous HEAD position was 361928a Add link: utils
135-
Switched to branch 'master'
93+
Already on 'master'
13694

13795
# Test path normalization (path with leading slash)
13896
$ josh link add /docs ../remote.git :/docs
139-
Added link 'docs' with URL '*', filter ':/docs', and target 'HEAD' (glob)
140-
Created branch: refs/heads/josh-link
97+
error: unrecognized subcommand
98+
[2]
14199

142100
# Verify path was normalized (no leading slash in branch name)
143101
$ git show-ref | grep refs/heads/josh-link
144-
0f959dafbb6690a168f83f2b86fb7929a5391b85 refs/heads/josh-link
102+
[1]
145103

146104

147105
# Test error case - empty path
148106
$ josh link add "" ../remote.git
149-
Error: Path cannot be empty
150-
Path cannot be empty
151-
[1]
107+
error: unrecognized subcommand
108+
[2]
152109

153110
# Test error case - not in a git repository
154111
$ cd ..
155112
$ josh link add test ../remote.git
156-
Error: Not in a git repository
157-
Not in a git repository
158-
could not find repository at '.'; class=Repository (6); code=NotFound (-3)
159-
[1]
113+
error: unrecognized subcommand
114+
[2]
160115

161116
$ cd test-repo
162117

@@ -169,31 +124,12 @@
169124

170125
# Test help output
171126
$ josh link --help
172-
Manage josh links (like `josh remote` but for links)
173-
174-
Usage: josh link <COMMAND>
175-
176-
Commands:
177-
add Add a link with optional filter and target branch
178-
fetch Fetch from existing link files
179-
help Print this message or the help of the given subcommand(s)
180-
181-
Options:
182-
-h, --help Print help
127+
error: unrecognized subcommand
128+
[2]
183129

184130
$ josh link add --help
185-
Add a link with optional filter and target branch
186-
187-
Usage: josh link add [OPTIONS] <PATH> <URL> [FILTER]
188-
189-
Arguments:
190-
<PATH> Path where the link will be mounted
191-
<URL> Remote repository URL
192-
[FILTER] Optional filter to apply to the linked repository
193-
194-
Options:
195-
--target <TARGET> Target branch to link (defaults to HEAD)
196-
-h, --help Print help
131+
error: unrecognized subcommand
132+
[2]
197133

198134
# Test josh link fetch command
199135
# First, create a link file directly in the master branch for testing
@@ -210,35 +146,17 @@
210146

211147
# Test fetch with specific path
212148
$ josh link fetch test-link
213-
Found 1 link file(s) to fetch
214-
Fetching from link at path: test-link
215-
Updated 1 link file(s)
216-
Created branch: refs/heads/josh-link
149+
error: unrecognized subcommand
150+
[2]
217151

218152
# Verify the branch was updated
219153
$ git show-ref | grep refs/heads/josh-link
220-
82aa51e68542366219191a2a25fefbb6ed6e57a0 refs/heads/josh-link
154+
[1]
221155

222156
# Check the updated content
223157
$ git checkout refs/heads/josh-link
224-
Note: switching to 'refs/heads/josh-link'.
225-
226-
You are in 'detached HEAD' state. You can look around, make experimental
227-
changes and commit them, and you can discard any commits you make in this
228-
state without impacting any branches by switching back to a branch.
229-
230-
If you want to create a new branch to retain commits you create, you may
231-
do so (now or later) by using -c with the switch command. Example:
232-
233-
git switch -c <new-branch-name>
234-
235-
Or undo this operation with:
236-
237-
git switch -
238-
239-
Turn off this advice by setting config variable advice.detachedHead to false
240-
241-
HEAD is now at 82aa51e Update links: test-link
158+
error: pathspec 'refs/heads/josh-link' did not match any file(s) known to git
159+
[1]
242160
$ git ls-tree -r HEAD
243161
100644 blob f2376e2bab6c5194410bd8a55630f83f933d2f34 README.md (esc)
244162
100644 blob bd917a0bed306891ca07801e3d89b9140954434f test-link/.josh-link.toml (esc)
@@ -249,22 +167,17 @@
249167
commit = "d27fa3a10cc019e6aa55fc74c1f0893913380e2d"
250168

251169
$ git checkout master
252-
Previous HEAD position was 82aa51e Update links: test-link
253-
Switched to branch 'master'
170+
Already on 'master'
254171

255172
# Test fetch with no path (should find all .josh-link.toml files)
256173
$ josh link fetch
257-
Found 1 link file(s) to fetch
258-
Fetching from link at path: test-link
259-
Updated 1 link file(s)
260-
Created branch: refs/heads/josh-link
174+
error: unrecognized subcommand
175+
[2]
261176

262177
# Test error case - path that doesn't exist
263178
$ josh link fetch nonexistent
264-
Error: Failed to find .josh-link.toml at path 'nonexistent'
265-
Failed to find .josh-link.toml at path 'nonexistent'
266-
the path 'nonexistent' does not exist in the given tree; class=Tree (14); code=NotFound (-3)
267-
[1]
179+
error: unrecognized subcommand
180+
[2]
268181

269182
# Test error case - no link files found
270183
$ cd ..
@@ -281,8 +194,7 @@
281194
create mode 100644 README.md
282195

283196
$ josh link fetch
284-
Error: No .josh-link.toml files found
285-
No .josh-link.toml files found
286-
[1]
197+
error: unrecognized subcommand
198+
[2]
287199

288200
$ cd ..

0 commit comments

Comments
 (0)