Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip(ci): set up CI with Azure Pipelines #28

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
227720c
wip(ci): set up CI with Azure Pipelines
nielslanting Aug 10, 2019
50d8f57
wip(ci): azure pipelines for go project
nielslanting Aug 10, 2019
80a65de
wip(ci): tabs to spaces
nielslanting Aug 10, 2019
9330cdb
wip(ci): make build correct indent
nielslanting Aug 10, 2019
4715003
wip(ci): added protobuf-compiler install to build step
nielslanting Aug 10, 2019
370cf2a
wip(ci): editor config and spaces in pipeline yml
nielslanting Aug 10, 2019
13bae0e
wip(ci): sudo apt install
nielslanting Aug 10, 2019
c31c670
wip(ci): relative api path and pipeline go 1.12
nielslanting Aug 10, 2019
0430829
wip(ci): workingDirectory removed
nielslanting Aug 10, 2019
6818e49
wip(ci): added ls and pwd
nielslanting Aug 10, 2019
2bfda9d
wip(ci): updated editorconfig, protoc from pipeline instead of make
nielslanting Aug 10, 2019
c72800c
wip(ci): more debugging
nielslanting Aug 10, 2019
95db0e3
wip(ci): more debugging 2
nielslanting Aug 10, 2019
7429bf2
wip(ci): makefile relative paths
nielslanting Aug 10, 2019
9c30c1a
wip(ci): install protobuf 3
nielslanting Aug 10, 2019
85a2b59
wip(ci): protobuf proper unzipping
nielslanting Aug 10, 2019
69af62b
wip(ci): add gopath bin to path
nielslanting Aug 10, 2019
a06d8ea
wip(ci): go111 modules enabled
nielslanting Aug 10, 2019
e04809c
wip(ci): added grpc-gateway dependencies to pipeline
nielslanting Aug 10, 2019
e62f91e
wip(ci): updated protobuf to 3.9.1
nielslanting Aug 10, 2019
a9b357b
wip(ci): made proto not relative
nielslanting Aug 10, 2019
9aaa358
wip(ci): proper protoc version
nielslanting Aug 10, 2019
0d63b7d
wip(ci): add include to path
nielslanting Aug 10, 2019
89ccb7b
wip(ci): commented out go get grpc-gatway
nielslanting Aug 10, 2019
201e601
wip(ci): different go get command
nielslanting Aug 10, 2019
248f02d
wip(ci): goroot in path
nielslanting Aug 10, 2019
7ee7bea
wip(ci): ci without setup
nielslanting Aug 10, 2019
06cf16b
wip(ci): test without workingDirectory
nielslanting Aug 10, 2019
6686644
wip(ci): install protobuf in different step
nielslanting Aug 10, 2019
a2ab2bd
wip(ci): set path through command
nielslanting Aug 10, 2019
9ed159e
wip(ci): use pipe instead of forward slash
nielslanting Aug 10, 2019
a841c9f
wip(ci): ls src dir
nielslanting Aug 10, 2019
65819d1
wip(ci): more logging
nielslanting Aug 10, 2019
21b4f88
wip(ci): removed blank lines
nielslanting Aug 10, 2019
186bfc4
wip(ci): modulePath back to gopath
nielslanting Aug 10, 2019
4c51470
wip(ci): go get u before
nielslanting Aug 10, 2019
e288f0b
wip(ci): protobuf generation different step
nielslanting Aug 11, 2019
ee072e4
wip(ci): log gopath
nielslanting Aug 11, 2019
d2dc0e9
wip(ci): modulepath in caps
nielslanting Aug 11, 2019
e5dd58e
wip(ci): more logging ls
nielslanting Aug 11, 2019
41392f4
wip(ci): disable go111module again
nielslanting Aug 11, 2019
d447d39
wip(ci): go get all, removed logging for protobuf step
nielslanting Aug 11, 2019
27c5177
wip(ci): publish server artifact
nielslanting Aug 11, 2019
29b5ab4
wip(ci): cross compilation and artifact
nielslanting Aug 11, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = tab
indent_size=2
indent_size = 2

[*.yml]
indent_style = space
indent_size = 2
26 changes: 17 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
build:
go build -o ./bin/server/server ./cmd/server
build_darwin:
GOOS=darwin GOARD=amd64 go build -o ./bin/server/server_darwin_x86_64 ./cmd/server

build_windows:
GOOS=windows GOARD=amd64 go build -o ./bin/server/server_windows_x86_64.exe ./cmd/server

build_linux:
GOOS=linux GOARD=amd64 go build -o ./bin/server/server_linux_x86_64 ./cmd/server

build: build_darwin build_windows build_linux

api_go:
protoc -I api/proto/v1/ \
protoc -I ./api/proto/v1/ \
-I ${GOPATH}/src \
-I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
-I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway \
--go_out=plugins=grpc:pkg/api/v1 \
economy_service.proto

api_gateway:
protoc -I api/proto/v1/ \
-I${GOPATH}/src \
-I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
protoc -I ./api/proto/v1/ \
-I ${GOPATH}/src \
-I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
-I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway \
--grpc-gateway_out=logtostderr=true:pkg/api/v1 \
economy_service.proto

api_swagger:
protoc -I api/proto/v1/ \
-I${GOPATH}/src \
-I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
protoc -I ./api/proto/v1/ \
-I ${GOPATH}/src \
-I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
-I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway \
--swagger_out=logtostderr=true:api/swagger/v1 \
economy_service.proto
Expand Down
56 changes: 56 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Go
# Build your Go project.
# Add steps that test, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/go

trigger:
- master

pool:
vmImage: 'ubuntu-16.04'

variables:
# GO111MODULE: 'on'
GOBIN: '$(GOPATH)/bin' # Go binaries path
GOROOT: '/usr/local/go1.12' # Go installation path
GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
MODULEPATH: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code

steps:
- script: |
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
mkdir -p '$(MODULEPATH)'
shopt -s extglob
shopt -s dotglob
mv !(gopath) '$(MODULEPATH)'
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
displayName: 'Set up the Go workspace'

- script: |
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.9.1/protoc-3.9.1-linux-x86_32.zip
unzip protoc-3.9.1-linux-x86_32.zip -d protoc3
sudo mv protoc3/bin/* /usr/local/bin/
sudo mv protoc3/include/* /usr/local/include/
echo '##vso[task.prependpath]/usr/local/bin'
echo '##vso[task.prependpath]/usr/local/include'
displayName: 'Set up protobuf'

- script: |
go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go get -v github.com/golang/protobuf/protoc-gen-go
make api
workingDirectory: '$(MODULEPATH)'
displayName: 'Generating protobuf'

- script: |
go version
go get -v ./...
make build
workingDirectory: '$(MODULEPATH)'
displayName: 'Get dependencies, then build'

- publish: $(MODULEPATH)/bin/server
artifact: server
95 changes: 0 additions & 95 deletions cmd/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ import (
v1 "github.com/GameComponent/economy-service/pkg/api/v1"
)

const (
// apiVersion is version of API is provided by server
apiVersion = "v1"
)

func main() {
// get configuration
address := flag.String("server", "127.0.0.1:3000", "gRPC server in format host:port")
Expand All @@ -38,7 +33,6 @@ func main() {

// Call CreateItem
req1 := v1.CreateItemRequest{
Api: apiVersion,
Name: "kaasbaas",
}

Expand All @@ -52,7 +46,6 @@ func main() {

// Call UpdateItem
req2 := v1.UpdateItemRequest{
Api: apiVersion,
ItemId: res1.Item.GetId(),
Name: "bierplezier",
}
Expand All @@ -67,7 +60,6 @@ func main() {

// Call UpdateItem
req6 := v1.CreateStorageRequest{
Api: apiVersion,
PlayerId: "1337",
Name: "bank",
}
Expand All @@ -82,7 +74,6 @@ func main() {

// Call GiveItem
req7 := v1.GiveItemRequest{
Api: apiVersion,
StorageId: res6.GetStorage().GetId(),
ItemId: res1.GetItem().GetId(),
}
Expand All @@ -97,7 +88,6 @@ func main() {

// Call GetStorage
req8 := v1.GetStorageRequest{
Api: apiVersion,
StorageId: res6.GetStorage().GetId(),
}

Expand All @@ -108,89 +98,4 @@ func main() {

fmt.Println("GetStorage result:")
fmt.Println(proto.MarshalTextString(res8))

// // Call UpdateItem3
// req3 := v1.UpdateItemRequest{
// Api: apiVersion,
// ItemId: res1.Item.GetId(),
// Name: "bierplezier222",
// }

// res3, err := client.UpdateItem(ctx, &req3)
// if err != nil {
// log.Fatalf("UpdateItem2 failed: %v", err)
// }

// fmt.Println("UpdateItem2 result:")
// fmt.Println(proto.MarshalTextString(res3))

// // Call CreateItem4
// req4 := v1.CreateItemRequest{
// Api: apiVersion,
// Name: "dfgdfgfd777",
// }

// res4, err := client.CreateItem(ctx, &req4)
// if err != nil {
// log.Fatalf("CreateItem failed: %v", err)
// }

// fmt.Println("CreateItem4 result:")
// fmt.Println(proto.MarshalTextString(res4))

// Call ListItems5
// req5 := v1.ListItemsRequest{
// Api: apiVersion,
// }

// res5, err := client.ListItems(ctx, &req5)
// if err != nil {
// log.Fatalf("ListItems failed: %v", err)
// }

// fmt.Println("ListItems result:")
// fmt.Println(proto.MarshalTextString(res5))

// Call Give
// req1 := v1.GiveItemRequest{
// Api: apiVersion,
// StorageId: "storageid",
// ItemId: "testid",
// }

// res1, err := client.GiveItem(ctx, &req1)
// if err != nil {
// log.Fatalf("Give failed: %v", err)
// }

// fmt.Println("Give result:")
// fmt.Println(proto.MarshalTextString(res1))

// Call GetInventory
// req2 := v1.GetStorageRequest{
// Api: apiVersion,
// StorageId: "storageid",
// }

// res2, err := client.GetStorage(ctx, &req2)
// if err != nil {
// log.Fatalf("Give failed: %v", err)
// }

// fmt.Println("GetInventory result:")
// fmt.Println(proto.MarshalTextString(res2))

// Call GetPlayer
// req3 := v1.GetPlayerRequest{
// Api: apiVersion,
// PlayerId: "playerid",
// }

// res3, err := client.GetPlayer(ctx, &req3)
// if err != nil {
// log.Fatalf("Give failed: %v", err)
// }

// fmt.Println("GetPlayer result:")
// fmt.Println(proto.MarshalTextString(res3))
}