public void SetUp()
 {
     _ioUtilsMock = new Mock <IIoUtils>();
     Registry.RegisterComponent(_ioUtilsMock.Object);
     _uut    = new PublisherUtils();
     _stream = new MemoryStream();
 }
示例#2
0
 public bool IsBuildPublished()
 {
     if (!IsWebGLPublisherOpen())
     {
         return(false);
     }
     return(!string.IsNullOrEmpty(PublisherUtils.GetUrlOfLastPublishedBuild(publisherWindow)));
 }
        // ReSharper disable once UnusedMember.Global
        public async Task PublishStagedReleaseContent([TimerTrigger("%PublishReleaseContentCronSchedule%")]
                                                      TimerInfo timer,
                                                      ExecutionContext executionContext,
                                                      ILogger logger)
        {
            logger.LogInformation($"{executionContext.FunctionName} triggered at: {DateTime.Now}");

            var scheduled = (await QueryScheduledReleases()).ToList();

            if (scheduled.Any())
            {
                var published = new List <ReleaseStatus>();
                foreach (var releaseStatus in scheduled)
                {
                    logger.LogInformation($"Moving content for release: {releaseStatus.ReleaseId}");
                    await UpdateStage(releaseStatus, Started);

                    try
                    {
                        await _publishingService.PublishStagedReleaseContentAsync(releaseStatus.ReleaseId);

                        published.Add(releaseStatus);
                    }
                    catch (Exception e)
                    {
                        logger.LogError(e, $"Exception occured while executing {executionContext.FunctionName}");
                        await UpdateStage(releaseStatus, Failed,
                                          new ReleaseStatusLogMessage($"Exception in publishing stage: {e.Message}"));
                    }
                }

                var releaseIds = published.Select(status => status.ReleaseId).ToArray();

                try
                {
                    if (!PublisherUtils.IsDevelopment())
                    {
                        await _releaseService.DeletePreviousVersionsStatisticalData(releaseIds);
                    }

                    await _contentService.DeletePreviousVersionsDownloadFiles(releaseIds);

                    await _contentService.DeletePreviousVersionsContent(releaseIds);

                    await _notificationsService.NotifySubscribers(releaseIds);
                    await UpdateStage(published, Complete);
                }
                catch (Exception e)
                {
                    logger.LogError(e, $"Exception occured while executing {executionContext.FunctionName}");
                    await UpdateStage(published, Failed,
                                      new ReleaseStatusLogMessage($"Exception in publishing stage: {e.Message}"));
                }
            }

            logger.LogInformation(
                $"{executionContext.FunctionName} completed. {timer.FormatNextOccurrences(1)}");
        }
        public void GetUnityVersionOfBuild_ValidBuild_Success()
        {
            List <string> lines = new List <string>();

            lines.Add("m_EditorVersion: 2019.3.4f1");
            lines.Add("m_EditorVersionWithRevision: 2019.3.4f1(4f139db2fdbd)");
            File.WriteAllLines(Path.Combine(outputFolder, "ProjectVersion.txt"), lines);
            Assert.AreEqual("2019.3", PublisherUtils.GetUnityVersionOfBuild(outputFolder));
        }
        public void GetUnityVersionOfBuild_InvalidVersionFile_Fails()
        {
            List <string> lines = new List <string>();

            lines.Add("m_EditorVersion: broken data");
            lines.Add("m_EditorVersionWithRevision: broken data");

            File.WriteAllLines(Path.Combine(outputFolder, "ProjectVersion.txt"), lines);
            Assert.AreEqual(string.Empty, PublisherUtils.GetUnityVersionOfBuild(outputFolder));
        }
示例#6
0
        public bool IsBuildBeingUploaded()
        {
            if (!IsWebGLPublisherOpen())
            {
                return(false);
            }
            switch (PublisherUtils.GetCurrentPublisherState(publisherWindow))
            {
            case PublisherState.Upload:
            case PublisherState.Process:
                return(true);

            default: break;
            }
            return(!string.IsNullOrEmpty(PublisherUtils.GetUrlOfLastPublishedBuild(publisherWindow)));
        }
        public void AddCurrentSceneToBuildSettings_SceneAssetDoesNotExist_SceneIsNotAdded()
        {
            string[] currentScenesList         = EditorBuildSettingsScene.GetActiveSceneList(EditorBuildSettings.scenes);
            int      originalListElementsCount = currentScenesList.Length;

            string currentScenePath = SceneManager.GetActiveScene().path;

            Assert.IsEmpty(currentScenePath);
            Assert.IsFalse(currentScenesList.Contains(currentScenePath));

            bool sceneWasAdded = PublisherUtils.AddCurrentSceneToBuildSettings();

            currentScenesList = EditorBuildSettingsScene.GetActiveSceneList(EditorBuildSettings.scenes);

            Assert.AreEqual(originalListElementsCount, currentScenesList.Length);
            Assert.IsFalse(sceneWasAdded);
            Assert.IsFalse(currentScenesList.Contains(currentScenePath));
        }
        public void AddCurrentSceneToBuildSettings_SceneAssetExists_SceneIsAdded()
        {
            string[] currentScenesList         = EditorBuildSettingsScene.GetActiveSceneList(EditorBuildSettings.scenes);
            int      originalListElementsCount = currentScenesList.Length;

            Assert.IsTrue(EditorSceneManager.SaveScene(SceneManager.GetActiveScene(), sceneOutputFolder + "tempScene.unity"));

            string currentScenePath = SceneManager.GetActiveScene().path;

            Assert.IsNotEmpty(currentScenePath);
            Assert.IsFalse(currentScenesList.Contains(currentScenePath));

            bool sceneWasAdded = PublisherUtils.AddCurrentSceneToBuildSettings();

            currentScenesList = EditorBuildSettingsScene.GetActiveSceneList(EditorBuildSettings.scenes);

            Assert.AreEqual(originalListElementsCount + 1, currentScenesList.Length);
            Assert.IsTrue(sceneWasAdded);
            Assert.IsTrue(currentScenesList.Contains(currentScenePath));
        }
示例#9
0
        // ReSharper disable once UnusedMember.Global
        public async Task PublishReleaseContent(
            [QueueTrigger(PublishReleaseContentQueue)]
            PublishReleaseContentMessage message,
            ExecutionContext executionContext,
            ILogger logger)
        {
            logger.LogInformation($"{executionContext.FunctionName} triggered at: {DateTime.Now}");

            await UpdateStage(message.ReleaseId, message.ReleaseStatusId, State.Started);

            var context = new PublishContext(DateTime.UtcNow, false);

            try
            {
                await _contentService.UpdateContent(context, message.ReleaseId);

                await _releaseService.SetPublishedDatesAsync(message.ReleaseId, context.Published);

                if (!PublisherUtils.IsDevelopment())
                {
                    await _releaseService.DeletePreviousVersionsStatisticalData(message.ReleaseId);
                }

                await _contentService.DeletePreviousVersionsDownloadFiles(message.ReleaseId);

                await _contentService.DeletePreviousVersionsContent(message.ReleaseId);

                await _notificationsService.NotifySubscribers(message.ReleaseId);
                await UpdateStage(message.ReleaseId, message.ReleaseStatusId, State.Complete);
            }
            catch (Exception e)
            {
                logger.LogError(e, $"Exception occured while executing {executionContext.FunctionName}");
                logger.LogError(e.StackTrace);

                await UpdateStage(message.ReleaseId, message.ReleaseStatusId, State.Failed,
                                  new ReleaseStatusLogMessage($"Exception publishing release immediately: {e.Message}"));
            }

            logger.LogInformation($"{executionContext.FunctionName} completed");
        }
示例#10
0
        public bool AtLeastOneBuildIsRegistered()
        {
            if (!IsWebGLPublisherOpen())
            {
                return(false);
            }
            switch (PublisherUtils.GetCurrentPublisherState(publisherWindow))
            {
            case PublisherState.Zip:
            case PublisherState.Upload:
            case PublisherState.Process:
                return(true);

            default: break;
            }
            int availableBuilds = PublisherUtils.GetAllBuildsDirectories()
                                  .Where(p => (p != string.Empty) &&
                                         PublisherUtils.BuildIsValid(p)).Count();

            return(availableBuilds > 0);
        }
        // ReSharper disable once UnusedMember.Global
        public async Task PublishReleaseData(
            [QueueTrigger(PublishReleaseDataQueue)] PublishReleaseDataMessage message,
            ExecutionContext executionContext,
            ILogger logger)
        {
            logger.LogInformation($"{executionContext.FunctionName} triggered: {message}");

            if (PublisherUtils.IsDevelopment())
            {
                // Skip the ADF Pipeline if running locally
                // If the Release is immediate then trigger publishing the content
                // This usually happens when the ADF Pipeline is complete
                if (await _releaseStatusService.IsImmediate(message.ReleaseId, message.ReleaseStatusId))
                {
                    await _queueService.QueuePublishReleaseContentMessageAsync(message.ReleaseId,
                                                                               message.ReleaseStatusId);
                }

                await UpdateStage(message, Complete);
            }
            else
            {
                try
                {
                    var clientConfiguration = new DataFactoryClientConfiguration(_configuration);
                    var success             = TriggerDataFactoryReleasePipeline(clientConfiguration, logger, message);
                    await UpdateStage(message, success?Started : Failed);
                }
                catch (Exception e)
                {
                    logger.LogError(e, $"Exception occured while executing {executionContext.FunctionName}");
                    await UpdateStage(message, Failed,
                                      new ReleaseStatusLogMessage($"Exception in data stage: {e.Message}"));
                }
            }

            logger.LogInformation($"{executionContext.FunctionName} completed");
        }
 public void FormatBytes_HandlesAllCases_Success(ulong bytes, string expectedResult)
 {
     Assert.AreEqual(expectedResult, PublisherUtils.FormatBytes(bytes));
 }
        public void GetFilteredGameTitle_HandlesAllCases_Success(string originalTitle, string expectedResult)
        {
            string filteredTitle = PublisherUtils.GetFilteredGameTitle(originalTitle);

            Assert.AreEqual(expectedResult, filteredTitle);
        }