Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

Commit

Permalink
Hooking the Go compilation step into the sbt build and adding a depen…
Browse files Browse the repository at this point in the history
…dency for the TCK
  • Loading branch information
viktorklang committed Sep 16, 2019
1 parent c99b53d commit 5b9df7c
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 2,145 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ target-sbt
node_modules
.idea/
.nyc_output
go-support/shoppingcart/cmd/shoppingcart/tck_shoppingcart
57 changes: 25 additions & 32 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,30 @@ lazy val `java-shopping-cart` = (project in file("samples/java-shopping-cart"))
}
)

lazy val `go-support` = (project in file("go-support"))
.settings(
name := "go-support",
(compile in Compile) := {
// FIXME only recompile if any of the files in the project has changed
import scala.util.Properties.{isLinux, isMac, isWin}
val (os_arch, cmd) =
if (isLinux) ("linux on amd64", "./go-support/build/run_tck_shopping_cart_build.sh linux amd64")
else if (isMac) ("darwin on amd64", "./go-support/build/run_tck_shopping_cart_build.sh darwin amd64")
else if (isWin) ("windows on amd64", "& .\\go-support\\build\\run_tck_shopping_cart_build.ps1 windows amd64") // FIXME IMPLEMENT
else throw new IllegalStateException("Running on an unsupported OS/ARCH combination: " + sys.props("os.name"))

val SuccessMessage = "go-support compiled successfully: " + os_arch + "\n"

(cmd !!) match {
case SuccessMessage =>
streams.value.log.success("go-support compilation succeeded")
(compile in Compile).value // TODO should we produce our own compilation result instead perhaps?
case err =>
throw new IllegalStateException("go-support compilation failed: " + err)
}
}
)

lazy val `akka-client` = (project in file("samples/akka-client"))
.enablePlugins(AkkaGrpcPlugin)
.settings(
Expand Down Expand Up @@ -717,7 +741,7 @@ lazy val `tck` = (project in file("tck"))
fork in test := true,
parallelExecution in IntegrationTest := false,
executeTests in IntegrationTest := (executeTests in IntegrationTest)
.dependsOn(`proxy-core` / assembly, `java-shopping-cart` / assembly)
.dependsOn(`proxy-core` / assembly, `java-shopping-cart` / assembly, `go-support` / Compile / compile)
.value
)

Expand Down Expand Up @@ -747,34 +771,3 @@ def doCompileK8sDescriptors(dir: File,
streams.log.info("Generated YAML descriptor in " + target)
target
}

lazy val buildGoTCKShoppingCart = taskKey[Unit]("build go-shopping-cart for the TCK")

buildGoTCKShoppingCart := {
var cmd = ""
var os_arch = ""
if (sys.props("os.name").contains("Linux")) {
os_arch = "linux amd64"
cmd = "./go-support/build/run_tck_shopping_cart_build.sh %s".format(os_arch)
} else if (sys.props("os.name").contains("Mac OS X")) {
os_arch = "darwin amd64"
cmd = "./go-support/build/run_tck_shopping_cart_build.sh %s".format(os_arch)
} else if (sys.props("os.name").contains("Windows")) {
os_arch = "windows amd64"
// FIXME: someone with windows has to test that
cmd = "& .\\go-support\\build\\run_tck_shopping_cart_build.ps1 %s".format(os_arch)
} else {
val msg = "unable to find a valid OS/ARCH combination"
// FIXME: the sbt linter seems to be unhappy with the use of streams here
streams.value.log.error(msg)
throw new IllegalStateException(msg)
}

if ((cmd !) == 0) {
streams.value.log.success("build go-shopping-cart for the TCK for: %s: successfully!".format(os_arch))
} else {
streams.value.log.error("build go-shopping-cart for the TCK: failed")
}
}
// TODO: this has to run on compile time or when the TCK is built
// (run in Compile) <<= (run in Compile).dependsOn(something)
4 changes: 1 addition & 3 deletions go-support/build/build_tck_shopping_cart_in_docker.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#!/usr/bin/env bash

echo "building go TCK shoppingcart for OS: ${GOOS} on ${GOARCH}"

SUFFIX=""
if [ "$GOOS" == "windows" ]; then
SUFFIX=".exe"
fi

cd shoppingcart/cmd/shoppingcart/ && CGO_ENABLED=0 go build -v -o "tck_shoppingcart${SUFFIX}"
cd shoppingcart/cmd/shoppingcart/ && CGO_ENABLED=0 go build -v -o "tck_shoppingcart${SUFFIX}" && echo "go-support compiled successfully: ${GOOS} on ${GOARCH}"
9 changes: 1 addition & 8 deletions go-support/generate
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
#!/usr/bin/env bash

protoc --go_out=plugins=grpc:. --proto_path=./protocols/frontend/ --proto_path=./protocols/protocol/ --proto_path=./protocols/proxy/ --proto_path=./protocols/example/ protocols/protocol/cloudstate/entity.proto
protoc --go_out=plugins=grpc:. --proto_path=./protocols/frontend/ --proto_path=./protocols/protocol/ --proto_path=./protocols/proxy/ --proto_path=./protocols/example/ protocols/frontend/cloudstate/entity_key.proto
protoc --go_out=plugins=grpc:. --proto_path=./protocols/frontend/ --proto_path=./protocols/protocol/ --proto_path=./protocols/proxy/ --proto_path=./protocols/example/ protocols/protocol/cloudstate/event_sourced.proto

protoc --go_out=plugins=grpc:. --proto_path=./protocols/frontend/ --proto_path=./protocols/protocol/ --proto_path=./protocols/proxy/ --proto_path=./protocols/example/ protocols/protocol/cloudstate/crdt.proto
protoc --go_out=plugins=grpc:. --proto_path=./protocols/frontend/ --proto_path=./protocols/protocol/ --proto_path=./protocols/proxy/ --proto_path=./protocols/example/ protocols/protocol/cloudstate/function.proto

protoc --go_out=plugins=grpc:. --proto_path=./protocols/frontend/ --proto_path=./protocols/protocol/ --proto_path=./protocols/proxy/ --proto_path=./protocols/example/ protocols/example/shoppingcart/shoppingcart.proto
protoc --go_out=plugins=grpc:. --proto_path=./protocols/frontend/ --proto_path=./protocols/protocol/ --proto_path=./protocols/proxy/ --proto_path=./protocols/example/ protocols/protocol/cloudstate/entity.proto protocols/frontend/cloudstate/entity_key.proto protocols/protocol/cloudstate/event_sourced.proto protocols/protocol/cloudstate/crdt.proto protocols/protocol/cloudstate/function.proto protocols/example/shoppingcart/shoppingcart.proto
66 changes: 0 additions & 66 deletions go-support/protos/example/crdts/crdt-example.proto

This file was deleted.

27 changes: 0 additions & 27 deletions go-support/protos/example/shoppingcart/persistence/domain.proto

This file was deleted.

60 changes: 0 additions & 60 deletions go-support/protos/example/shoppingcart/shoppingcart.proto

This file was deleted.

30 changes: 0 additions & 30 deletions go-support/protos/frontend/cloudstate/entity_key.proto

This file was deleted.

31 changes: 0 additions & 31 deletions go-support/protos/frontend/google/api/annotations.proto

This file was deleted.

Loading

0 comments on commit 5b9df7c

Please sign in to comment.