Skip to content

Commit 1718510

Browse files
committed
Add docs
Signed-off-by: David Pordomingo <[email protected]>
1 parent 627d967 commit 1718510

File tree

4 files changed

+175
-30
lines changed

4 files changed

+175
-30
lines changed

.github/screenshot.png

87.8 KB
Loading

README.md

+42-30
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,61 @@
1-
## Development
1+
[![Build Status](https://travis-ci.org/src-d/gitbase-playground.svg)](https://travis-ci.org/src-d/gitbase-playground)
2+
[![codecov.io](https://codecov.io/github/src-d/gitbase-playground/coverage.svg)](https://codecov.io/github/src-d/gitbase-playground)
3+
![unstable](https://svg-badge.appspot.com/badge/stability/unstable?a)
24

3-
### Dependencies
5+
# Gitbase Playground
46

5-
Launch [bblfshd](https://github.com/bblfsh/bblfshd) and install the drivers. More info in the [bblfshd documentation](https://doc.bblf.sh/user/getting-started.html).
7+
Web application to query git repositories using SQL. Powered by [gitbase](https://github.com/src-d/gitbase).
68

7-
```bash
8-
docker run -d --name bblfshd --privileged -p 9432:9432 -v /var/lib/bblfshd:/var/lib/bblfshd bblfsh/bblfshd
9-
docker exec -it bblfshd bblfshctl driver install --all
10-
```
9+
![Screenshot](.github/screenshot.png?raw=true)
1110

12-
Install [gitbase](https://github.com/src-d/gitbase), populate a repository directory, and start it.
1311

14-
```bash
15-
go get github.com/src-d/gitbase/...
16-
cd $GOPATH/src/github.com/src-d/gitbase
17-
make dependencies
18-
mkdir repos
19-
git clone https://github.com/src-d/gitbase-playground.git repos/gitbase-playground
20-
go run cli/gitbase/main.go server -v --git=repos
21-
```
12+
# Usage
2213

23-
### Build
14+
## Dependencies
2415

25-
```bash
26-
go build -o gitbase-playground cmd/server/main.go
27-
```
16+
The playground will run the queries against a [gitbase](https://github.com/src-d/gitbase) server, and will request UASTs to a [bblfsh](https://doc.bblf.sh/) server; both should be accessible for the playground; you can check its default [configuration values](docs/CONTRIBUTING.md#configuration).
2817

29-
### Run
3018

31-
Use `GITBASEPG_ENV=dev` for extra logs information.
19+
## Run the Playground
3220

33-
Development:
21+
You can run the app from a docker image, a released binary or installing and building the project.
3422

35-
```bash
36-
GITBASEPG_ENV=dev go run cmd/server/main.go
37-
```
23+
Once the server is running &ndash;with its default values&ndash;, it will be accessible through: http://localhost:8080
3824

39-
Built binary:
25+
Read [more about how to run bblfsh and gitbase dependencies](docs/quickstart.md).
26+
27+
### Run with Docker
4028

4129
```bash
42-
GITBASEPG_ENV=dev ./gitbase-playground
30+
$ docker run -d
31+
--publish 8080:8080
32+
--link gitbase
33+
--env GITBASEPG_ENV=dev
34+
--env GITBASEPG_DB_CONNECTION="gitbase@tcp(gitbase:3306)/none?maxAllowedPacket=4194304"
35+
--name gitbasePlayground
36+
src-d/gitbase-playground:latest
4337
```
4438

45-
### Run the Tests
39+
40+
### Run the Binary
41+
42+
Download a binary from our [releases section](https://github.com/src-d/gitbase-playground/releases), and run it:
4643

4744
```bash
48-
go test -v server/handler/*
45+
$ /download/path/gitbase-playground
4946
```
47+
48+
49+
# Contribute
50+
51+
[Contributions](https://github.com/src-d/gitbase-playground/issues) are more than welcome, if you are interested please take a look to our [Contributing Guidelines](docs/CONTRIBUTING.md). You have more information on how to run it locally for [development purposes here](docs/CONTRIBUTING.md#development).
52+
53+
54+
# Code of Conduct
55+
56+
All activities under source{d} projects are governed by the [source{d} code of conduct](https://github.com/src-d/guide/blob/master/.github/CODE_OF_CONDUCT.md).
57+
58+
59+
## License
60+
61+
GPL v3.0, see [LICENSE](LICENSE)

docs/CONTRIBUTING.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Contribution Guidelines
2+
3+
As all source{d} projects, this project follows the
4+
[source{d} Contributing Guidelines](https://github.com/src-d/guide/blob/master/engineering/documents/CONTRIBUTING.md).
5+
6+
7+
## Additional Contribution Guidelines
8+
9+
In addition to the [source{d} Contributing Guidelines](https://github.com/src-d/guide/blob/master/engineering/documents/CONTRIBUTING.md),
10+
this project follows the guidelines described below.
11+
12+
13+
# Architecture
14+
15+
The application is a go binnary that serves the statics and the API used for the UI.
16+
17+
The statics (`html`, `js` and `css`) are generated by `yarn`, embedded in the go binary using bindata, and served from the binary itself.
18+
19+
There are two main different ways to run the app:
20+
21+
- using released artifacts, as [listed in the README.md](../README.md#run-the-playground)
22+
- serving the app for development purposes, [building and running it from sources](#run-from-sources)
23+
24+
25+
# Configuration
26+
27+
| Variable | Required | Default value | Meaning |
28+
| -- | -- | -- | -- |
29+
| `GITBASEPG_HOST` | | `0.0.0.0` | IP address to bind the HTTP server |
30+
| `GITBASEPG_PORT` | | `8080` | Port address to bind the HTTP server |
31+
| `GITBASEPG_SERVER_URL` | | `<GITBASEPG_HOST>:<GITBASEPG_PORT>` | URL used to access the application (i.e. public hostname) |
32+
| `GITBASEPG_DB_CONNECTION` | | `gitbase@tcp(localhost:3306)/none?maxAllowedPacket=4194304` | gitbase connection string |
33+
| `GITBASEPG_BBLFSHD_URL` | | `127.0.0.1:9432` | Address where bblfsh server is listening |
34+
| `GITBASEPG_ENV` | | `production` | Sets the log level. Use `dev` to enable debug log messages |
35+
36+
37+
# Development
38+
39+
## Requirements
40+
41+
You should already have [Go installed](https://golang.org/doc/install#install), and properly [configured the $GOPATH](https://github.com/golang/go/wiki/SettingGOPATH)
42+
43+
```
44+
go version; # prints your go version
45+
go env GOPATH; # prints your $GOPATH path
46+
```
47+
48+
The project must be under $GOPATH, as required by the Go tooling.
49+
You should be able to navigate into the source code by running:
50+
51+
```
52+
cd $GOPATH/src/github.com/src-d/gitbase-playground
53+
```
54+
55+
You need also [Yarn v1.x.x installed](https://yarnpkg.com/en/docs/install)
56+
57+
```
58+
yarn --version; # prints your Yarn version
59+
```
60+
61+
62+
## Run from Sources
63+
64+
You need to satisfy all [project requirements](#requirements), and then run:
65+
66+
```bash
67+
$ go get -d -u github.com/src-d/gitbase-playground/...
68+
$ cd $GOPATH/github.com/src-d/gitbase-playground
69+
$ make dependencies
70+
$ make serve
71+
```
72+
73+
This will start a server locally, which you can access on [http://localhost:8080](http://localhost:8080)

docs/quickstart.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Quickstart
2+
3+
## Run bblfsh and gitbase Dependencies
4+
5+
It is recommended to read about `bblfsh` and `gitbase` from its own documentation, but here is a small guide about how to run both easily:
6+
7+
Launch [bblfshd](https://github.com/bblfsh/bblfshd) and install the drivers. More info in the [bblfshd documentation](https://doc.bblf.sh/user/getting-started.html):
8+
9+
```bash
10+
$ docker run --privileged
11+
--publish 9432:9432
12+
--volume /var/lib/bblfshd:/var/lib/bblfshd
13+
--name bblfsh
14+
bblfsh/bblfshd
15+
$ docker exec -it bblfsh
16+
bblfshctl driver install --recommended
17+
```
18+
19+
[gitbase](https://github.com/src-d/gitbase) will serve git repositories, so it is needed to populate a directory with them:
20+
21+
```bash
22+
$ mkdir -p ~/gitbase/repos
23+
$ git clone [email protected]:src-d/go-git-fixtures.git ~/gitbase/repos/go-git-fixtures
24+
```
25+
26+
Install and run [gitbase](https://github.com/src-d/gitbase):
27+
28+
```bash
29+
$ docker run
30+
--publish 3306:3306
31+
--link bblfsh
32+
--volume ~/gitbase/repos:/opt/repos
33+
--env BBLFSH_ENDPOINT=bblfsh:9432
34+
--name gitbase
35+
srcd/gitbase:latest
36+
```
37+
38+
39+
## Run gitbase-playground
40+
41+
Once bblfsh and gitbase are running and accessible, you can serve the playground:
42+
43+
```bash
44+
$ docker run -d
45+
--publish 8080:8080
46+
--link gitbase
47+
--env GITBASEPG_ENV=dev
48+
--env GITBASEPG_DB_CONNECTION="gitbase@tcp(gitbase:3306)/none?maxAllowedPacket=4194304"
49+
--name gitbase_playground
50+
srcd/gitbase-playground:latest
51+
```
52+
53+
Once the server is running &ndash;with its default values&ndash;, it will be accessible through: http://localhost:8080
54+
55+
You have more information about the [playground architecture](CONTRIBUTING.md#architecture), [development guides](CONTRIBUTING.md#development) and [configuration options](CONTRIBUTING.md#configuration) in the [CONTRIBUTING.md](CONTRIBUTING.md).
56+
57+
58+
## Run a Query
59+
60+
You will find more info about how to run queries using the playground API on the [rest-api guide](rest-api.md)

0 commit comments

Comments
 (0)