Skip to content

Commit 8292b0f

Browse files
chore: install protocol buffer before building service (#3599)
## Purpose of this PR The most recent service update added a dependency to the protocol buffer compiler. This PR adds the protocol buffer driver to the CI DA service build script. ### Jira ticket NA <!-- Uncomment and mark items off with a * if this PR deprecates any API: ### Deprecated API - [ ] An `[Obsolete]` attribute was added along with a `(RemovedAfter yyyy-mm-dd)` entry. - [ ] An [api updater](https://confluence.unity3d.com/display/DEV/Obsolete+API+updaters) was added. - [ ] Deprecation of the API is explained in the CHANGELOG. - [ ] The users can understand why this API was removed and what they should use instead. --> ## Documentation - No documentation changes or additions were necessary. ## Testing & QA [//]: # ( This section is REQUIRED and should describe how the changes were tested and how should they be tested when Playtesting for the release. It can range from "edge case covered by unit tests" to "manual testing required and new sample was added". Expectation is that PR creator does some manual testing and provides a summary of it here.) ### Functional Testing [//]: # (If checked, List manual tests that have been performed.) _Manual testing :_ - [X] `Manual testing done` - Via back-end CI. _Automated tests:_ - [ ] `Covered by existing automated tests` - [ ] `Covered by new automated tests` _Does the change require QA team to:_ - [ ] `Review automated tests`? - [ ] `Execute manual tests`? If any boxes above are checked, please add QA as a PR reviewer. ## Backport No back port is required (a v2.x.x only update)
1 parent 8890554 commit 8292b0f

File tree

1 file changed

+67
-2
lines changed

1 file changed

+67
-2
lines changed

Tools/CI/run_cmb_service.sh

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,33 +60,98 @@ echo "Starting with echo server on port: $echo_port and the cmb service on port:
6060

6161
# Setup -------------------------------------------------------------------------
6262

63+
64+
ThrewError=false
65+
66+
# Mimics "Try-Catch" where you have to check if an error occurred after invoking
67+
try() {
68+
ThrewError=false
69+
"$@" || throw "$@"
70+
}
71+
72+
# Invoked by try
73+
throw() {
74+
logError "An error occurred executing this command:$@"
75+
ThrewError=true
76+
}
77+
78+
# A way to log messages that are easy to distinguish from the rest of the logs
79+
logMessage(){
80+
printf "\n############################################\n"
81+
printf "$@\n"
82+
printf "############################################\n"
83+
}
84+
85+
# A way to log error messages that are easy to distinguish from the rest of the logs
86+
logError(){
87+
printf "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
88+
printf "$@\n"
89+
printf "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
90+
}
91+
92+
# Protocol Buffer Compiler ------------------------------------------------------
93+
94+
# Apply any updates
95+
logMessage "Updating modules..."
96+
sudo apt-get update
97+
98+
# Install Protocol Buffer Compiler (using apt-get)
99+
logMessage "Installing protocol bufffer compiler as SUDO..."
100+
try sudo apt-get install -y protobuf-compiler
101+
102+
# If the previous command failed, try without sudo
103+
if $ThrewError; then
104+
logMessage "Installing protocol bufffer compiler as shell assigned account..."
105+
apt-get install -y protobuf-compiler
106+
else
107+
logMessage "Protocol bufffer compiler was installed as sudo!"
108+
fi
109+
110+
# Add the PROTOC environment variable that points to the Protocol Buffer Compiler binary
111+
export PROTOC="/usr/bin/protoc"
112+
113+
# Validate the PROTOC env var by getting the protoc version
114+
try $PROTOC --version
115+
116+
if $ThrewError; then
117+
logError "Failed to properly run protoc!"
118+
exit -1
119+
else
120+
logMessage "Protocol Buffer Compiler Installed & ENV variables verified!\n PROTOC path is: $PROTOC"
121+
fi
122+
63123
# clone the cmb service repo
64124
git clone https://github.com/Unity-Technologies/mps-common-multiplayer-backend.git
125+
65126
# navigate to the cmb service directory
66127
cd ./mps-common-multiplayer-backend/runtime
67128

68129
# Install rust
69130
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
131+
70132
# Add the cargo bin directory to the PATH
71133
export PATH="$HOME/.cargo/bin:$PATH"
72134

73-
74135
# Echo server -------------------------------------------------------------------
75136

76137
# Build the echo server
138+
logMessage "Beginning echo server build..."
77139
cargo build --example ngo_echo_server
140+
78141
# Run the echo server in the background
142+
logMessage "Running echo server tests..."
79143
cargo run --example ngo_echo_server -- --port $echo_port &
80144

81-
82145
# CMB Service -------------------------------------------------------------------
83146

84147
# Build a release version of the standalone cmb service
148+
logMessage "Beginning service release build..."
85149
cargo build --release --locked
86150

87151
# Run the standalone service on an infinite loop in the background.
88152
# The infinite loop is required as the service will exit each time all connected clients disconnect.
89153
# This means the service will exit after each test. The infinite loop will immediately restart the service each time it exits.
154+
logMessage "Running service integration tests..."
90155
while :; do
91156
./target/release/comb-server -l error --metrics-port 5000 standalone --port $service_port -t 60m;
92157
done & # <- use & to run the entire loop in the background

0 commit comments

Comments
 (0)