-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
5,880 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
vendor/ | ||
coverage.txt | ||
|
||
# Junk files | ||
*~ | ||
*# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# build | ||
FROM golang:1.13-alpine as build | ||
RUN apk add --update --no-cache git gcc musl-dev make | ||
RUN GO111MODULE=off go get github.com/gobuffalo/packr/v2/packr2 | ||
WORKDIR /go/src/berty.tech/yolo | ||
ENV GO111MODULE=on | ||
COPY go.* ./ | ||
RUN go mod download | ||
COPY . ./ | ||
RUN packr2 | ||
RUN make install | ||
|
||
# minimalist runtime | ||
FROM alpine:3.11 | ||
RUN apk add --update --no-cache ca-certificates | ||
COPY --from=build /go/bin/yolo /bin/ | ||
ENTRYPOINT ["yolo"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
.PHONY: test | ||
test: generate | ||
go test -test.timeout=20s -cover -covermode=atomic -race -coverprofile=coverage.txt ./... | ||
|
||
.PHONY: install | ||
install: generate | ||
go install ./cmd/yolo | ||
|
||
## | ||
## generate | ||
## | ||
|
||
PROTOS_SRC := ./api/yolo.proto | ||
GEN_DEPS := $(PROTOS_SRC) Makefile | ||
.PHONY: generate | ||
generate: gen.sum | ||
gen.sum: $(GEN_DEPS) | ||
shasum $(GEN_DEPS) | sort > gen.sum.tmp | ||
@diff -q gen.sum gen.sum.tmp || ( \ | ||
set -xe; \ | ||
GO111MODULE=on go mod vendor; \ | ||
docker run \ | ||
--user=`id -u` \ | ||
--volume="$(PWD):/go/src/berty.tech/yolo" \ | ||
--workdir="/go/src/berty.tech/yolo" \ | ||
--entrypoint="sh" \ | ||
--rm \ | ||
bertytech/yolo-protoc:v1 \ | ||
-xec 'make generate_local'; \ | ||
make tidy \ | ||
) | ||
|
||
PROTOC_OPTS = -I ./api:./vendor:/protobuf | ||
.PHONY: generate_local | ||
generate_local: | ||
@set -e; for proto in $(PROTOS_SRC); do (set -xe; \ | ||
protoc $(PROTOC_OPTS) \ | ||
--gogofaster_out="plugins=grpc:$(GOPATH)/src" \ | ||
--grpc-gateway_out=logtostderr=true:"$(GOPATH)/src" \ | ||
"$$proto" \ | ||
); done | ||
goimports -w *.pb.go | ||
shasum $(GEN_DEPS) | sort > gen.sum.tmp | ||
mv gen.sum.tmp gen.sum | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f gen.sum $(wildcard *.pb.go) $(wildcard *.pb.gw.go) | ||
|
||
.PHONY: tidy | ||
tidy: | ||
go mod tidy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
syntax = "proto3"; | ||
|
||
package yolo; | ||
|
||
import "google/api/annotations.proto"; | ||
import "github.com/gogo/protobuf/gogoproto/gogo.proto"; | ||
import "github.com/golang/protobuf/ptypes/timestamp/timestamp.proto"; | ||
|
||
option go_package = "berty.tech/yolo;yolo"; | ||
option (gogoproto.sizer_all) = true; | ||
option (gogoproto.marshaler_all) = true; | ||
option (gogoproto.unmarshaler_all) = true; | ||
|
||
service YoloService { | ||
rpc Ping(Ping.Request) returns (Ping.Response) { option (google.api.http) = {get: "/ping"}; }; | ||
rpc Status(Status.Request) returns (Status.Response) { option (google.api.http) = {get: "/status"}; }; | ||
rpc BuildList(BuildList.Request) returns (BuildList.Response) { option (google.api.http) = {get: "/build-list"}; } | ||
rpc ArtifactList(ArtifactList.Request) returns (ArtifactList.Response) { option (google.api.http) = {get: "/artifact-list"}; } | ||
} | ||
|
||
// | ||
// RPC Requests & Responses | ||
// | ||
|
||
message Ping { | ||
message Request {} | ||
message Response {} | ||
} | ||
|
||
message Status { | ||
message Request {} | ||
message Response { | ||
int32 uptime = 1; | ||
string db_err = 2; | ||
int64 db_nodes = 3; | ||
int64 db_quads = 4; | ||
} | ||
} | ||
|
||
message BuildList { | ||
message Request {} | ||
message Response { | ||
repeated Build builds = 1; | ||
} | ||
} | ||
|
||
message ArtifactList { | ||
message Request { | ||
Artifact.Kind kind = 1; | ||
} | ||
message Response { | ||
repeated Artifact artifacts = 1; | ||
} | ||
} | ||
|
||
// | ||
// DB Models | ||
// | ||
|
||
message Build { | ||
string id = 1 [(gogoproto.casttype) = "github.com/cayleygraph/quad.IRI", (gogoproto.moretags) = "quad:\"@id\"", (gogoproto.customname) = "ID"]; // canonical URI | ||
google.protobuf.Timestamp created_at = 2 [(gogoproto.moretags) = "quad:\"schema:createdAt,optional\"", (gogoproto.stdtime) = true, (gogoproto.nullable) = true]; | ||
google.protobuf.Timestamp updated_at = 3 [(gogoproto.moretags) = "quad:\"schema:updatedAt,optional\"", (gogoproto.stdtime) = true, (gogoproto.nullable) = true]; | ||
State state = 4 [(gogoproto.moretags) = "quad:\"schema:state,optional\""]; | ||
google.protobuf.Timestamp completed_at = 5 [(gogoproto.moretags) = "quad:\"schema:completedAt,optional\"", (gogoproto.stdtime) = true, (gogoproto.nullable) = true]; | ||
string message = 6 [(gogoproto.moretags) = "quad:\"schema:message,optional\""]; | ||
google.protobuf.Timestamp started_at = 7 [(gogoproto.moretags) = "quad:\"schema:startedAt,optional\"", (gogoproto.stdtime) = true, (gogoproto.nullable) = true]; | ||
google.protobuf.Timestamp finished_at = 8 [(gogoproto.moretags) = "quad:\"schema:finishedAt,optional\"", (gogoproto.stdtime) = true, (gogoproto.nullable) = true]; | ||
string commit = 9 [(gogoproto.moretags) = "quad:\"schema:commit,optional\""]; | ||
string branch = 10 [(gogoproto.moretags) = "quad:\"schema:branch,optional\""]; | ||
|
||
enum State { | ||
UnknownState = 0; | ||
Running = 1; | ||
Failed = 2; | ||
Passed = 3; | ||
Canceled = 4; | ||
Scheduled = 5; | ||
Skipped = 6; | ||
NotRun = 7; | ||
} | ||
} | ||
|
||
message Artifact { | ||
string id = 1 [(gogoproto.casttype) = "github.com/cayleygraph/quad.IRI", (gogoproto.moretags) = "quad:\"@id\"", (gogoproto.customname) = "ID"]; // canonical URI | ||
google.protobuf.Timestamp created_at = 2 [(gogoproto.moretags) = "quad:\"schema:createdAt,optional\"", (gogoproto.stdtime) = true, (gogoproto.nullable) = true]; | ||
int64 file_size = 3 [(gogoproto.moretags) = "quad:\"schema:file_size,optional\""]; | ||
string local_path = 4 [(gogoproto.moretags) = "quad:\"schema:local_path,optional\""]; | ||
string download_url = 5 [(gogoproto.moretags) = "quad:\"schema:download_url,optional\""]; | ||
string mime_type= 6 [(gogoproto.moretags) = "quad:\"schema:mime_type,optional\""]; | ||
string sha1_sum= 7 [(gogoproto.moretags) = "quad:\"schema:sha1_sum,optional\""]; | ||
State state = 8 [(gogoproto.moretags) = "quad:\"schema:state,optional\""]; | ||
Kind kind = 9 [(gogoproto.moretags) = "quad:\"schema:kind,optional\""]; | ||
|
||
string has_build = 101 [(gogoproto.moretags) = "quad:\"hasBuild,optional\"", (gogoproto.casttype) = "github.com/cayleygraph/quad.IRI"]; | ||
|
||
enum State { | ||
UnknownState = 0; | ||
Finished = 1; | ||
New = 2; | ||
Error = 3; | ||
Deleted = 4; | ||
} | ||
enum Kind { | ||
UnknownKind = 0; | ||
IPA = 1; | ||
APK = 2; | ||
} | ||
} | ||
|
||
// | ||
// Constants & Internal | ||
// | ||
|
||
enum Driver { | ||
UnknownDriver = 0; | ||
GitHub = 1; | ||
Buildkite = 2; | ||
// ... | ||
} | ||
|
||
message Batch { | ||
repeated Build builds = 1; | ||
repeated Artifact artifacts = 2; | ||
// ... | ||
} |
Oops, something went wrong.