Skip to content

Commit

Permalink
Merge pull request #154 from berty/dev/moul/move-go-dir
Browse files Browse the repository at this point in the history
  • Loading branch information
moul authored Apr 30, 2020
2 parents c9b8c06 + e1f3a36 commit 12a26f5
Show file tree
Hide file tree
Showing 45 changed files with 270 additions and 349 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
- checkout
- tools/mod-download
- tools/mod-tidy-check
- run: make install
- run: make test GO_TEST_OPTS="-v -test.timeout=300s -test.parallel=1 -count=1" YOLO_DEBUG=1
- run: cd go && make install
- run: cd go && make test GO_TEST_OPTS="-v -test.timeout=300s -test.parallel=1 -count=1" YOLO_DEBUG=1
- moul/install_golangci-lint
- run: make lint
- run: cd go && make lint
- codecov/upload:
file: coverage.txt
docker-build:
Expand Down
5 changes: 3 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# default is tech team
* @berty/tech
* @moul
/* @moul
/web/ @ekelen
File renamed without changes.
76 changes: 0 additions & 76 deletions CODE_OF_CONDUCT.md

This file was deleted.

5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ RUN apk add --update --no-cache git gcc musl-dev make perl-utils
RUN GO111MODULE=off go get github.com/gobuffalo/packr/v2/packr2
WORKDIR /go/src/berty.tech/yolo
ENV GO111MODULE=on \
GOPROXY=proxy.golang.org
GOPROXY=proxy.golang.org
COPY go.* ./
RUN go mod download
COPY . ./
COPY go ./go/
RUN rm -rf web
COPY --from=web-build /app/dist web
WORKDIR /go/src/berty.tech/yolo/go
RUN make packr
RUN make install

Expand Down
76 changes: 0 additions & 76 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,79 +1,3 @@
DEV_RUN_OPTS ?= --dev-mode

GO_TEST_OPTS ?= -test.timeout=60s

.PHONY: test
test: generate
go test $(GO_TEST_OPTS) -cover -covermode=atomic -race -coverprofile=coverage.txt ./...

.PHONY: dev
dev: install
yolo -v server --cors-allowed-origins="*" --max-builds=50 --db-path=/tmp/yolo-dev.sqlite --basic-auth-password="uns3cur3" --auth-salt="uns3cur3" $(DEV_RUN_OPTS)

.PHONY: update-golden
update-golden:
# first, update the golden image that requires internet
go test -v -test.timeout=600s ./pkg/yolosvc/ -debug -update -run TestPullAndSave
# then, update all the offline golden files
BINTRAY_TOKEN="" go test -v -test.timeout=600s ./pkg/yolosvc/ -debug -update

.PHONY: install
install: generate
go install ./cmd/yolo

.PHONY: lint
lint: generate
golangci-lint run

.PHONY: packr
packr:
cd pkg/yolosvc && packr2 && ls -la *-packr.go packrd/packed-packr.go

##
## generate
##

PROTOS_SRC := $(wildcard ./api/*.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 ./pkg/yolopb/*.pb.go
shasum $(GEN_DEPS) | sort > gen.sum.tmp
mv gen.sum.tmp gen.sum

.PHONY: clean
clean:
rm -f gen.sum $(wildcard pkg/*/*.pb.go) $(wildcard pkg/*/*.pb.gw.go) $(wildcard pkg/*/*-packr.go) $(wildcard packrd/*)

.PHONY: tidy
tidy:
go mod tidy

.PHONY: docker.build
docker.build:
docker build -t bertytech/yolo .
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ You will need to get multiple CI tokens to allow Yolo to fetch your last builds.

### Install

`go get -u berty.tech/yolo`
`go get -u berty.tech/yolo/v2/go/cmd/yolo`

Or grab the last Docker image available [on the official Docker Registry]().

Expand Down
2 changes: 1 addition & 1 deletion api/yolopb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ 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/pkg/yolopb";
option go_package = "berty.tech/yolo/go/pkg/yolopb";
option (gogoproto.sizer_all) = true;
option (gogoproto.marshaler_all) = true;
option (gogoproto.unmarshaler_all) = true;
Expand Down
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
@@ -1 +1 @@
package yolo // import "berty.tech/yolo"
package yolo
2 changes: 0 additions & 2 deletions gen.sum

This file was deleted.

File renamed without changes.
75 changes: 75 additions & 0 deletions go/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
DEV_RUN_OPTS ?= --dev-mode

GO_TEST_OPTS ?= -test.timeout=60s

.PHONY: test
test: generate
go test $(GO_TEST_OPTS) -cover -covermode=atomic -race -coverprofile=coverage.txt ./...

.PHONY: dev
dev: install
yolo -v server --cors-allowed-origins="*" --max-builds=50 --db-path=/tmp/yolo-dev.sqlite --basic-auth-password="uns3cur3" --auth-salt="uns3cur3" $(DEV_RUN_OPTS)

.PHONY: update-golden
update-golden:
# first, update the golden image that requires internet
go test -v -test.timeout=600s ./pkg/yolosvc/ -debug -update -run TestPullAndSave
# then, update all the offline golden files
BINTRAY_TOKEN="" go test -v -test.timeout=600s ./pkg/yolosvc/ -debug -update

.PHONY: install
install: generate
go install ./cmd/yolo

.PHONY: lint
lint: generate
golangci-lint run

.PHONY: packr
packr:
cd pkg/yolosvc && packr2 && ls -la *-packr.go packrd/packed-packr.go

##
## generate
##

PROTOS_SRC := $(wildcard ../api/*.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/go" \
--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 ./pkg/yolopb/*.pb.go
shasum $(GEN_DEPS) | sort > gen.sum.tmp
mv gen.sum.tmp gen.sum

.PHONY: clean
clean:
rm -f gen.sum $(wildcard pkg/*/*.pb.go) $(wildcard pkg/*/*.pb.gw.go) $(wildcard pkg/*/*-packr.go) $(wildcard packrd/*)

.PHONY: tidy
tidy:
go mod tidy
4 changes: 2 additions & 2 deletions cmd/yolo/main.go → go/cmd/yolo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"syscall"
"time"

"berty.tech/yolo/v2/pkg/bintray"
"berty.tech/yolo/v2/pkg/yolosvc"
"berty.tech/yolo/v2/go/pkg/bintray"
"berty.tech/yolo/v2/go/pkg/yolosvc"
bearer "github.com/Bearer/bearer-go"
"github.com/buildkite/go-buildkite/buildkite"
"github.com/google/go-github/v31/github"
Expand Down
2 changes: 2 additions & 0 deletions go/gen.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 12a26f5

Please sign in to comment.