Skip to content

Commit

Permalink
fix: Make CI build method throw on error
Browse files Browse the repository at this point in the history
  • Loading branch information
Dawid Sygocki committed Jun 29, 2023
1 parent c933e34 commit 719da0d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions Editor/ElympicsWebIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Text;
using System.Web;
using JetBrains.Annotations;
using Newtonsoft.Json;
using UnityEditor;
using UnityEngine;
Expand Down Expand Up @@ -370,13 +371,16 @@ private static void HandleUploadResults(ElympicsGameConfig currentGameConfig, Un
Debug.Log($"Uploaded game {currentGameConfig.GameName} with version {currentGameConfig.GameVersion}");
}

[UsedImplicitly]
public static void BuildAndUploadServerInBatchmode(string username, string password)
{
var gameConfig = ElympicsConfig.LoadCurrentElympicsGameConfig();
if (gameConfig == null)
throw new ArgumentNullException("No elympics game config found. Configure your game first before trying to build a server.");
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
throw new ArgumentNullException($"Login credentials not found.");
throw new ElympicsException("No Elympics game config found. Configure your game before trying to build a server.");
if (string.IsNullOrEmpty(username))
throw new ArgumentNullException(nameof(username));
if (string.IsNullOrEmpty(password))
throw new ArgumentNullException(nameof(password));

var loginOp = Login(username, password);

Expand All @@ -385,17 +389,17 @@ public static void BuildAndUploadServerInBatchmode(string username, string passw
LoginHandler(loginOp.webRequest);

if (!ElympicsConfig.IsLogin)
throw new Exception("Login operation failed. Check log for details");
throw new ElympicsException("Login operation failed. Check log for details");

if (!BuildTools.BuildElympicsServerLinux())
return;
throw new ElympicsException("Build failed");

var currentGameConfig = ElympicsConfig.LoadCurrentElympicsGameConfig();
if (!TryPack(currentGameConfig.GameId, currentGameConfig.GameVersion, BuildTools.EnginePath, EngineSubdirectory, out var enginePath))
throw new Exception("Problem with packing engine");
throw new ElympicsException("Problem with packing engine");

if (!TryPack(currentGameConfig.GameId, currentGameConfig.GameVersion, BuildTools.BotPath, BotSubdirectory, out var botPath))
throw new Exception("Problem with packing bot");
throw new ElympicsException("Problem with packing bot");

var url = GetCombinedUrl(ElympicsWebEndpoint, GamesRoutes.BaseRoute, currentGameConfig.GameId, GamesRoutes.GameVersionsRoute);
var uploadOp = ElympicsEditorWebClient.SendEnginePostRequestApi(url, currentGameConfig.GameVersion, new[] { enginePath, botPath });
Expand Down

0 comments on commit 719da0d

Please sign in to comment.