Skip to content

Commit

Permalink
Added C# gRPC SDK (#1315)
Browse files Browse the repository at this point in the history
Added a C# wrapper for the Agones gRPC client built against .NET Standard 2.0 & Code Integrity tests built against .NET Core 2.2.

Commit includes:
 - Core C# Wrapper - Fully async & automatic health checks.
 - Agones CI Gen, Build & Test scripts.
 - Docs.
 - Relevant .gitignore modifications.
 - Make targets for C# SDK
 - Configuration specific auto-generate (DebugProtoGen), for development purposes

Resolves: #884 , #883

Co-authored-by: Mark Mandel <[email protected]>
  • Loading branch information
Reousa and markmandel authored Mar 31, 2020
1 parent 154e7fe commit 0850d9e
Show file tree
Hide file tree
Showing 13 changed files with 3,183 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ build/local-includes/*
!build/local-includes/README.md
/release
debug.test
obj
38 changes: 38 additions & 0 deletions build/build-sdk-images/csharp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2020 Google LLC All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ARG BASE_IMAGE=agones-build-sdk-base:latest
FROM $BASE_IMAGE

# Add installation step required to generate your SDK.
# This should contains tooling required to generate GRPC code, build (if distribution is required)
# and test your integration.

RUN apt-get update \
&& apt-get install -y wget

RUN apt-get update \
&& apt-get install -y apt-transport-https

RUN wget -q https://packages.microsoft.com/config/ubuntu/19.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb \
&& wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb


RUN apt-get update \
&& apt-get install -y dotnet-sdk-2.2

# code generation scripts
COPY *.sh /root/
RUN chmod +x /root/*.sh
22 changes: 22 additions & 0 deletions build/build-sdk-images/csharp/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

# Copyright 2020 Google LLC All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -ex

#Is obsolete if artifacts are not needed when NuGet publish is written.
#I'm still not sure how the artifacts are used, using `publish` for self-contained release packages.
cd ./sdks/csharp/sdk
dotnet publish -c Release
26 changes: 26 additions & 0 deletions build/build-sdk-images/csharp/gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

# Copyright 2020 Google LLC All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -ex

sdk=/go/src/agones.dev/agones/proto/sdk
googleapis=/go/src/agones.dev/agones/proto/googleapis
protoc_destination=/go/src/agones.dev/agones/sdks/csharp/sdk/generated

# Generate C# proto file `Sdk.cs`
protoc --csharp_out=${protoc_destination} -I ${sdk} -I ${googleapis} --plugin=protoc-gen-grpc=`which grpc_csharp_plugin` sdk.proto
# Generate proto stub?
protoc --grpc_out=${protoc_destination} -I ${sdk} -I ${googleapis} --plugin=protoc-gen-grpc=`which grpc_csharp_plugin` sdk.proto
23 changes: 23 additions & 0 deletions build/build-sdk-images/csharp/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# Copyright 2020 Google LLC All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -ex

# build the SDK project
# Run Code Integirty tests
cd ./sdks/csharp/test

dotnet test -c Release
4 changes: 3 additions & 1 deletion build/includes/sdk.mk
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ gen-sdk-grpc: COMMAND := gen
gen-sdk-grpc: run-sdk-command

# Runs a command on all supported languages, use COMMAND variable to select which command.
run-all-sdk-command: run-sdk-command-go run-sdk-command-rust run-sdk-command-cpp run-sdk-command-node run-sdk-command-restapi
run-all-sdk-command: run-sdk-command-go run-sdk-command-rust run-sdk-command-cpp run-sdk-command-node run-sdk-command-restapi run-sdk-command-csharp

run-sdk-command-node:
$(MAKE) run-sdk-command COMMAND=$(COMMAND) SDK_FOLDER=node
Expand All @@ -78,6 +78,8 @@ run-sdk-command-go:
run-sdk-command-restapi:
$(MAKE) run-sdk-command COMMAND=$(COMMAND) SDK_FOLDER=restapi

run-sdk-command-csharp:
$(MAKE) run-sdk-command COMMAND=$(COMMAND) SDK_FOLDER=csharp

# Runs a command for a specific SDK if it exists.
run-sdk-command:
Expand Down
Loading

0 comments on commit 0850d9e

Please sign in to comment.