Skip to content

Commit fb177ae

Browse files
authored
Merge pull request #15 from dpordomingo/master
Add CI, docs and fix integration tests
2 parents 4034054 + 2f13518 commit fb177ae

21 files changed

+686
-207
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/node_modules
2+
/vendor
3+
/repos

.github/CODE_OF_CONDUCT.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Code of Conduct
2+
3+
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).

.github/DCO

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Developer Certificate of Origin
2+
Version 1.1
3+
4+
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
5+
660 York Street, Suite 102,
6+
San Francisco, CA 94110 USA
7+
8+
Everyone is permitted to copy and distribute verbatim copies of this
9+
license document, but changing it is not allowed.
10+
11+
12+
Developer's Certificate of Origin 1.1
13+
14+
By making a contribution to this project, I certify that:
15+
16+
(a) The contribution was created in whole or in part by me and I
17+
have the right to submit it under the open source license
18+
indicated in the file; or
19+
20+
(b) The contribution is based upon previous work that, to the best
21+
of my knowledge, is covered under an appropriate open source
22+
license and I have the right under that license to submit that
23+
work with modifications, whether created in whole or in part
24+
by me, under the same open source license (unless I am
25+
permitted to submit under a different license), as indicated
26+
in the file; or
27+
28+
(c) The contribution was provided directly to me by some other
29+
person who certified (a), (b) or (c) and I have not modified
30+
it.
31+
32+
(d) I understand and agree that this project and the contribution
33+
are public and that a record of the contribution (including all
34+
personal information I submit with it, including my sign-off) is
35+
maintained indefinitely and may be redistributed consistent with
36+
this project or the open source license(s) involved.

.github/screenshot.png

87.8 KB
Loading

.travis.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
language: go
2+
3+
services:
4+
- docker
5+
6+
go:
7+
- "1.10.x"
8+
9+
before_install:
10+
- . $HOME/.nvm/nvm.sh
11+
- nvm install 8
12+
- nvm use 8
13+
- npm install -g yarn
14+
15+
install:
16+
- make dependencies
17+
18+
stages:
19+
- name: validate and build
20+
- name: release to github
21+
if: tag IS present
22+
- name: push to dockerhub
23+
if: tag IS present
24+
25+
jobs:
26+
include:
27+
# validate and build
28+
- stage: validate and build
29+
script:
30+
- make test
31+
- make lint
32+
- make coverage
33+
- make validate-commit
34+
- script:
35+
- make packages
36+
# release to github
37+
- stage: release to github
38+
script:
39+
- make packages
40+
deploy:
41+
provider: releases
42+
api_key: $GITHUB_TOKEN
43+
file_glob: true
44+
file: build/*.tar.gz
45+
skip_cleanup: true
46+
on:
47+
all_branches: true
48+
# push to dockerhub
49+
- stage: push to dockerhub
50+
script:
51+
- PKG_OS=linux make build
52+
- DOCKER_PUSH_LATEST=true make docker-push

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM alpine:3.7
2+
ADD ./build/bin /bin
3+
4+
RUN apk --update upgrade && \
5+
apk add --no-cache ca-certificates
6+
7+
ENTRYPOINT ["/bin/gitbase-playground"]

Makefile

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Package configuration
2+
PROJECT := gitbase-playground
3+
COMMANDS := cmd/gitbase-playground
4+
DOCKER_ORG := src-d
5+
DEPENDENCIES := \
6+
github.com/golang/dep/cmd/dep \
7+
github.com/jteeuwen/go-bindata \
8+
github.com/golang/lint/golint
9+
GO_LINTABLE_PACKAGES := $(shell go list ./... | grep -v '/vendor/')
10+
GO_BUILD_ENV := CGO_ENABLED=0
11+
12+
# Tools
13+
GODEP := dep
14+
GOLINT := golint
15+
GOVET := go vet
16+
BINDATA := go-bindata
17+
DIFF := diff
18+
19+
# Default rule
20+
all:
21+
22+
# Including ci Makefile
23+
CI_REPOSITORY ?= https://github.com/dpordomingo/ci.git
24+
CI_BRANCH ?= v1
25+
CI_PATH ?= $(shell pwd)/.ci
26+
MAKEFILE := $(CI_PATH)/Makefile.main
27+
$(MAKEFILE):
28+
@git clone --quiet --depth 1 -b $(CI_BRANCH) $(CI_REPOSITORY) $(CI_PATH);
29+
-include $(MAKEFILE)
30+
31+
# Makefile.main::dependencies -> Makefile.main::$(DEPENDENCIES) -> this::dependencies
32+
# The `exit` is needed to prevent running `Makefile.main::dependencies` commands.
33+
dependencies: | front-dependencies back-dependencies exit
34+
35+
# Makefile.main::test -> this::test
36+
test: front-test
37+
38+
# this::build -> Makefile.main::build -> Makefile.main::$(COMMANDS)
39+
# The @echo forces this prerequisites to be run before `Makefile.main::build` ones.
40+
build: front-build back-build
41+
@echo
42+
43+
coverage: | test-coverage codecov
44+
45+
lint: back-lint front-lint
46+
47+
validate-commit: | \
48+
back-dependencies \
49+
back-ensure-assets-proxy \
50+
front-fix-lint-errors \
51+
no-changes-in-commit
52+
53+
exit:
54+
exit 0;
55+
56+
57+
## Compiles the assets, and serve the tool through its API
58+
59+
serve: | front-build back-start
60+
61+
62+
# Backend
63+
64+
assets := ./server/assets/asset.go
65+
assets_back := $(assets).bak
66+
67+
back-dependencies:
68+
$(GODEP) ensure
69+
70+
back-build: back-bindata
71+
72+
back-bindata:
73+
$(BINDATA) \
74+
-pkg assets \
75+
-o $(assets) \
76+
build/public/*
77+
78+
back-lint: $(GO_LINTABLE_PACKAGES)
79+
$(GO_LINTABLE_PACKAGES):
80+
$(GOLINT) $@
81+
$(GOVET) $@
82+
83+
back-start:
84+
GITBASEPG_ENV=dev go run cmd/gitbase-playground/main.go
85+
86+
back-ensure-assets-proxy:
87+
$(DIFF) $(assets) $(assets_back) || exit 1
88+
89+
go-test-integration-packages := ./server/handler
90+
go-test-integration-flags := -v -args -test.integration.gitbase -test.integration.bblfshd
91+
back-test-integration:
92+
go test $(go-test-integration-packages) $(go-test-integration-flags)
93+
94+
95+
# Frontend
96+
97+
front-dependencies:
98+
echo 'SKIP. no frontend dependencies to install'
99+
100+
front-test:
101+
echo 'SKIP. no frontend tests to run'
102+
103+
front-lint:
104+
echo 'SKIP. no frontend linters to run'
105+
106+
front-build:
107+
mkdir -p build/public
108+
cp public/index.html build/public/index.html
109+
cp public/secondary.html build/public/secondary.html
110+
111+
front-fix-lint-errors:
112+
echo 'SKIP. no fixable code'
113+
114+

README.md

Lines changed: 42 additions & 30 deletions
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 –with its default values–, 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)

cmd/gitbase-playground/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type appConfig struct {
2727
Host string `envconfig:"HOST" default:"0.0.0.0"`
2828
Port int `envconfig:"PORT" default:"8080"`
2929
ServerURL string `envconfig:"SERVER_URL"`
30-
DBConn string `envconfig:"DB_CONNECTION" default:"root@tcp(localhost:3306)/none?maxAllowedPacket=4194304"`
30+
DBConn string `envconfig:"DB_CONNECTION" default:"gitbase@tcp(localhost:3306)/none?maxAllowedPacket=4194304"`
3131
}
3232

3333
func main() {

0 commit comments

Comments
 (0)