Skip to content

Commit d08eef5

Browse files
LMGchristian-schilling
authored andcommitted
Rework documentation
Rework outline Add getting started with interactive example
1 parent 9dd6ea6 commit d08eef5

File tree

7 files changed

+251
-8
lines changed

7 files changed

+251
-8
lines changed

docs/book.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[book]
2-
authors = ["Christian Schilling"]
2+
authors = ["Christian Schilling", "Louis-Marie Givel"]
33
language = "en"
44
multilingual = false
55
src = "src"

docs/src/.usecases.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Use cases

docs/src/SUMMARY.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
22

33
- [Intro](./intro.md)
44
- [Use cases](./usecases.md)
5+
# Guide
6+
- [Getting started](./gettingstarted.md)
7+
- [Working with workspaces]()
8+
- [Importing projects]()
9+
- [Integrating with CI]()
10+
# Reference
511
- [Filter syntax](./filters.md)
6-
- [Command Line usage](./cli.md)
712
- [Proxy](./proxy.md)
813
- [Workspaces](./workspace.md)
14+
- [Command line tools](./cli.md)
15+
- [Graphql API]()
16+
- [Handlebar generator]()
17+
- [The josh UI]()
18+
# Contributing
19+
- [Development tools]()
20+
- [Tracing]()

docs/src/gettingstarted.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Getting Started
2+
3+
This book will guide you into setting up the josh
4+
proxy to serve your own git repository.
5+
6+
---
7+
***NOTE***
8+
9+
All the commands in this book are included from the file `tutorial.t`
10+
which can be run with `cram tutorial.t`.
11+
12+
---
13+
14+
## Setting up the proxy
15+
16+
Josh is distributed via [docker hub](https://hub.docker.com/r/esrlabs/josh-proxy),
17+
and is installed and started with the following command:
18+
19+
```shell
20+
{{#include tutorial.t:docker_github}}
21+
```
22+
23+
This starts josh as a proxy to github.com, in a docker container,
24+
mounting the ./git\_data folder to the image for use by josh.
25+
26+
## Cloning a repository
27+
28+
Once josh is running, we can clone a repository through it.
29+
For example, let's clone josh:
30+
31+
```shell
32+
{{#include tutorial.t:clone_full}}
33+
```
34+
35+
As we can see, this repository is simply the normal josh one:
36+
37+
```shell
38+
{{#include tutorial.t:ls_full}}
39+
```
40+
41+
## Extracting a module
42+
43+
Josh becomes interesting when we want to extract a module.
44+
Let's check out the josh repository again, but this time let's filter
45+
only the documentation out:
46+
47+
```shell
48+
{{#include tutorial.t:clone_doc}}
49+
```
50+
51+
Note the addition of `:/docs` at the end of the url.
52+
This is called a filter, and it instructs josh to only check out the
53+
given folder.
54+
55+
Looking inside the repository, we now see that the history is quite
56+
different. Indeed, it contains only the commits pertaining to the
57+
subfolder that we checked out.
58+
59+
```shell
60+
{{#include tutorial.t:ls_doc}}
61+
```
62+
63+
This repository is a real repository in which we can pull, commit, push,
64+
as with a regular one. Josh will take care of synchronizing it with
65+
the main one in a transparent fashion.

docs/src/intro.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
# Just One Single History
1+
![Just One Single History](../banner.png)
22

33
Josh combines the advantages of monorepos with those of multirepos by leveraging a blazingly-fast,
44
incremental, and reversible implementation of git history filtering.
55

6-
This documentation describes the filtering mechanism, as well as
7-
the tools provided by Josh: the josh library, `josh-proxy` and `josh-filter`.
8-
96
## Concept
107

118
Traditionally, history filtering has been viewed as an expensive operation that should only be

docs/src/tutorial.t

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
$ export TESTTMP=${PWD}
2+
$ mkdir git_data
3+
4+
# starting josh
5+
ANCHOR: docker_github
6+
$ docker run -d -p 8000:8000 -e JOSH_REMOTE=https://github.com -v josh-vol:$(pwd)/git_data esrlabs/josh-proxy:latest > josh.out
7+
ANCHOR_END: docker_github
8+
9+
# waiting for josh to be running
10+
$ until curl -s http://localhost:8000/
11+
> do
12+
> sleep 0.1
13+
> done
14+
15+
# cloning josh
16+
ANCHOR: clone_full
17+
$ git clone http://localhost:8000/esrlabs/josh.git
18+
Cloning into 'josh'...
19+
$ cd josh
20+
ANCHOR_END: clone_full
21+
22+
# checking out a release tag to make the output dependable
23+
$ git checkout r21.03.19.1 1>/dev/null 2>/dev/null
24+
ANCHOR: ls_full
25+
$ ls
26+
Cargo.lock
27+
Cargo.toml
28+
Dockerfile
29+
Dockerfile.tests
30+
LICENSE
31+
Makefile
32+
README.md
33+
docs
34+
josh-proxy
35+
run-josh.sh
36+
run-tests.sh
37+
rustfmt.toml
38+
scripts
39+
src
40+
static
41+
tests
42+
$ git log -2
43+
commit fc6af1e10c865f790bff7135d02b1fa82ddebe29
44+
Author: Christian Schilling <[email protected]>
45+
Date: Fri Mar 19 11:15:57 2021 +0100
46+
47+
Update release.yml
48+
49+
commit 975581064fa21b3a3d6871a4e888fd6dc1129a13
50+
Author: Christian Schilling <[email protected]>
51+
Date: Fri Mar 19 11:11:45 2021 +0100
52+
53+
Update release.yml
54+
ANCHOR_END: ls_full
55+
56+
# cloning doc
57+
ANCHOR: clone_doc
58+
$ cd ..
59+
$ git clone http://localhost:8000/esrlabs/josh.git:/docs.git
60+
Cloning into 'docs'...
61+
$ cd docs
62+
ANCHOR_END: clone_doc
63+
64+
# checking out a release tag to make the output dependable
65+
$ git checkout r21.03.19.1 1>/dev/null 2>/dev/null
66+
ANCHOR: ls_doc
67+
$ ls
68+
book.toml
69+
src
70+
$ git log -2
71+
commit dd26c506f6d6a218903b9f42a4869184fbbeb940
72+
Author: Christian Schilling <[email protected]>
73+
Date: Mon Mar 8 09:22:21 2021 +0100
74+
75+
Update docs to use docker for default setup
76+
77+
commit ee6abba0fed9b99c9426f5224ff93cfee2813edc
78+
Author: Louis-Marie Givel <[email protected]>
79+
Date: Fri Feb 26 11:41:37 2021 +0100
80+
81+
Update proxy.md
82+
ANCHOR_END: ls_doc
83+
84+
# cleanup
85+
$ cd ${TESTTMP}
86+
$ docker stop $(cat josh.out) >/dev/null

docs/src/usecases.md

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,36 @@
11

22
# Use cases
33

4-
## Workspaces in a mono-repo
4+
### Partial cloning
55

6-
Multiple projects, depending on a shared set of libraries, can live together in a single repository.
6+
Reduce scope and size of clones by treating subdirectories of the monorepo
7+
as individual repositories.
8+
9+
```
10+
$ git clone http://josh/monorepo.git:/path/to/library.git
11+
```
12+
13+
The partial repo will act as a normal git repository but only contain the files
14+
found in the subdirectory and only commits affecting those files.
15+
The partial repo supports both fetch as well as push operation.
16+
17+
This helps not just to improve performace on the client due to having fever files in
18+
the tree,
19+
it also enables collaboration on parts of the monorepo with other parties
20+
utilizing git's normal distributed development features.
21+
For example, this makes it easy to mirror just selected parts of your
22+
repo to public github repositories or specific customers.
23+
24+
### Project composition / Workspaces
25+
26+
Simplify code sharing and dependency management. Beyond just subdirectories,
27+
Josh supports filtering, re-mapping and composition of arbitrary virtual repositories
28+
from the content found in the monorepo.
29+
30+
The mapping itself is also stored in the repository and therefore versioned alongside
31+
the code.
32+
33+
Multiple projects, depending on a shared set of libraries, can thus live together in a single repository.
734
This approach is commonly referred to as “monorepo”, and was popularized by
835
[Google](https://people.engr.ncsu.edu/ermurph3/papers/seip18.pdf), Facebook or Twitter to name a
936
few.
@@ -38,10 +65,65 @@ dependencies = :/modules:[
3865
</tbody>
3966
</table>
4067

68+
Workspaces act as normal git repos:
69+
70+
```
71+
$ git clone http://josh/central.git:workspace=workspaces/project1.git
72+
```
73+
4174
Each of the subprojects defines a `workspace.josh` file, defining the mapping between the original central.git repository and the hierarchy in use inside of the project.
4275

4376
In this setup, project1 and project2 can seemlessly depend on the latest version of library1, while only checking out the part of the central monorepo that's needed for their purpose.
4477
What's more, any changes to a shared module will be synced in both directions.
4578

4679
If a developper of the library1 pushed a new update, both projects will get the new version, and the developper will be able to check if they broke any test.
4780
If a developper of project1 needs to update the library, the changes will be automatically shared back into central, and project2.
81+
82+
### Simplified CI/CD
83+
84+
With everything stored in one repo, CI/CD systems only need to look into one source for each particular
85+
deliverable.
86+
However in traditional monorepo environments dependency mangement is handled by the build system.
87+
Build systems are usually taylored to specific languages and need their input already checked
88+
out on the filesystem.
89+
So the question:
90+
91+
> "What deliverables are affected by a given commit and need to be rebuild?"
92+
93+
cannot be answered without cloning the entire repository and understanding how the languages
94+
used handle dependencies.
95+
96+
In particular when using C familiy languages, hidden dependencies on header files are easy to miss.
97+
For this reason limiting the visibility of files to the compiler by sandboxing is pretty much a requirement
98+
for reproducible builds.
99+
100+
With Josh, each deliverable gets it's own virtual git repository with dependencies declared in the `workspace.josh`
101+
file. This means answering the above question becomes as simple as comparing commit ids.
102+
Furthermore due to the tree filtering each build is guaranteed to be perfectly sandboxed
103+
and only sees those parts of the monorepo that have actually been mapped.
104+
105+
This also means the deliverables to be re-built can be determined without cloning any repos like
106+
typically necessary with normal build tools.
107+
108+
### GraphQL API
109+
110+
It is often desireable to access content stored in git without requiring a clone of the repository.
111+
This is usefull for CI/CD systems or web frontends such as dashboards.
112+
113+
Josh exposes a GraphQL API for that purpose. For example, it can be used to find all workspaces currently
114+
present in the tree:
115+
116+
```
117+
query {
118+
rev(at:"refs/heads/master", filter:"::**/workspace.josh") {
119+
files { path }
120+
}
121+
}
122+
```
123+
124+
### Caching proxy
125+
126+
Even without using the more advanced features like partial cloning or workspaces,
127+
`josh-proxy` can act as a cache to reduce traffic between locations or keep your CI from
128+
performing many requests to the main git host.
129+

0 commit comments

Comments
 (0)