コード例 #1
0
        /// <inheritdoc />
        protected override bool OnStepStart()
        {
            var codeProvider   = new CSharpCodeProvider();
            var rspFilePath    = MakeResponseFile();
            var compilerParams = MakeCompilerParameters(rspFilePath);

            // create a missing directory path
            var directoryPath = PathHelpers.GetDirectoryName(OutputPath);

            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
            }

            // compile the DLL then dispose of code provider
            var compilerResults = codeProvider.CompileAssemblyFromFile(compilerParams);

            codeProvider.Dispose();

            if (!compilerResults.Errors.HasErrors)
            {
                return(true);
            }

            foreach (CompilerError compilerError in compilerResults.Errors)
            {
                RockLog.WriteLine(this, compilerError.IsWarning
                    ? LogTier.Warning
                    : LogTier.Error, compilerError.ToString());
            }

            return(false);
        }
コード例 #2
0
        /// <inheritdoc />
        protected override IEnumerator OnExecute(JobContext context)
        {
            BaseField variable;

            if (!context.TryGetField(VariableName, out variable))
            {
                if (CreateNew)
                {
                    variable = Field <string> .Create(VariableName, NewValue);

                    context.Add(variable);
                }
                else
                {
                    IsSuccess = false;
                    RockLog.WriteLine(this, LogTier.Error, string.Format("Couldn't find variable of name: {0}", VariableName));
                    yield break;
                }
            }

            variable.SetValue(NewValue);

            IsSuccess = true;
            yield return(null);
        }
コード例 #3
0
        private IEnumerator OnIteration(int index)
        {
            RockLog.InsertLine();
            RockLog.WriteLine(this, LogTier.Info, string.Format("Starting iteration number: {0}", CurrentIteration));

            InnerScope.Reset();

            var iteratorVariable = Field <object> .Create(RepeatNumberName, index, false, true);

            // update the iterator job context
            InnerScope.ScopeContext.Add(iteratorVariable);

            // reset the inner scope and loop through the child steps
            yield return(EditorCoroutines.StartCoroutine(InnerScope.StartExecutingSteps(), this));

            if (!IsSuppressed)
            {
                switch (InnerScope.Request)
                {
                case StepRequest.ExitScope:
                case StepRequest.RootScope:
                case StepRequest.TerminateJob:

                    DoLoop = false;

                    break;
                }
            }

            CurrentIteration++;
        }
コード例 #4
0
        /// <inheritdoc />
        protected override IEnumerator OnExecute(JobContext context)
        {
            var otherArguments = OtherArguments != null && OtherArguments.Length > 0
                ? string.Join(" ", OtherArguments)
                : string.Empty;

            var jobArguments = OtherArguments != null && JobArguments.Length > 0
                ? string.Join(" ", JobArguments)
                : string.Empty;

            var processArguments = string.Format("-batchmode {0} -projectPath \"{1}\" -executeMethod \"{2}\" \"{3}\" {4}",
                                                 otherArguments, ProjectPath, CLI.ExternalMethodName, LocalJobPath, jobArguments);

            var startInfo = new ProcessStartInfo
            {
                FileName        = UnityExePath,
                Arguments       = processArguments,
                UseShellExecute = UseShellExecute,
                WindowStyle     = WindowStyle,
            };

            _process = new Process
            {
                StartInfo = startInfo
            };

            RockLog.WriteLine(this, LogTier.Info, string.Format("Running: \"{0}\" {1}", UnityExePath, processArguments));

            ResetTimeout();

            if (!_process.Start())
            {
                IsSuccess = false;
                yield break;
            }

            // continuously check if the process has exited or timeout has been reached
            while (!_process.HasExited && _currentTimeLeftMs > 0)
            {
                UpdateTimeoutTimeLeft();
                yield return(null);
            }

            // if the timeout has been reached and the process hasn't exited
            if (!_process.HasExited && _currentTimeLeftMs <= 0)
            {
                if (KillOnTimeout)
                {
                    _process.Kill();
                }

                ExitCode  = -1;
                IsSuccess = false;
                yield break;
            }

            ExitCode  = _process.ExitCode;
            IsSuccess = ExitCode == 0;
        }
コード例 #5
0
        /// <inheritdoc />
        protected override bool OnValidate()
        {
            if (!RegexDefinitions.ValidVariableCharacters.IsMatch(VariableName.Trim('%')))
            {
                RockLog.WriteLine(this, LogTier.Error, string.Format("The variable name \"{0}\" contains invalid characters.", VariableName));
                return(false);
            }

            return(true);
        }
コード例 #6
0
        /// <inheritdoc />
        protected override bool OnValidate()
        {
            if (DuplicateFileBehaviour == DuplicateBehaviour.Fail && File.Exists(FilePath))
            {
                RockLog.WriteLine(this, LogTier.Error, string.Format("File already exists at: \"{0}\"", FilePath));
                return(false);
            }

            return(true);
        }
コード例 #7
0
ファイル: RunExecutableStep.cs プロジェクト: RockTomate/Steps
        /// <inheritdoc />
        protected override bool OnValidate()
        {
            if (!File.Exists(ExecutableFilePath))
            {
                RockLog.WriteLine(this, LogTier.Error, string.Format("Executable not found at: \"{0}\"", ExecutableFilePath));
                return(false);
            }

            return(true);
        }
コード例 #8
0
        /// <inheritdoc />
        protected override bool OnValidate()
        {
            if (!Directory.Exists(DirectoryPath))
            {
                RockLog.WriteLine(this, LogTier.Error, string.Format("Directory not found at: \"{0}\"", DirectoryPath));
                return(false);
            }

            return(true);
        }
コード例 #9
0
        protected override bool OnValidate()
        {
            if (!Repository.IsValid(RepositoryPath))
            {
                RockLog.WriteLine(this, LogTier.Error, $"Repository at \'{RepositoryPath}\' does not exist.");
                return(false);
            }

            return(true);
        }
コード例 #10
0
ファイル: ExtractZipStep.cs プロジェクト: RockTomate/Steps
        /// <inheritdoc />
        protected override bool OnValidate()
        {
            if (!File.Exists(ZipPath))
            {
                RockLog.WriteLine(this, LogTier.Error, string.Format("File at \"{0}\" does not exist.", ZipPath));
                return(false);
            }

            return(true);
        }
コード例 #11
0
ファイル: GitInitStep.cs プロジェクト: RockTomate/Steps
        protected override bool OnValidate()
        {
            if (Repository.IsValid(NewRepositoryPath))
            {
                RockLog.WriteLine(this, LogTier.Error, $"Repository at \'{NewRepositoryPath}\' already exists.");
                return(false);
            }

            return(true);
        }
コード例 #12
0
        protected override bool OnValidate()
        {
            if (!BuildTarget.IsBuildTargetSupported())
            {
                RockLog.WriteLine(LogTier.Error,
                                  string.Format("Build target \"{0}\" is not supported by this Unity engine. " +
                                                "This might be because module for this build target hasn't been installed.", BuildTarget));
                return(false);
            }

            return(true);
        }
コード例 #13
0
ファイル: GitApplyTagStep.cs プロジェクト: RockTomate/Steps
        protected override bool OnStepStart()
        {
            var commit = GitUtils.GetCommit(Repository, CommitSearch);

            if (commit == null)
            {
                RockLog.WriteLine(this, LogTier.Error, "Commit not found!");
                return(false);
            }

            Repository.ApplyTag(TagName, commit.Sha);

            return(true);
        }
コード例 #14
0
        protected override bool OnStepStart()
        {
            var branch = Repository.Branches[BranchName];

            if (branch == null)
            {
                RockLog.WriteLine(this, LogTier.Error, $"Branch of name \"{BranchName}\" does not exist.");
                return(false);
            }

            Commands.Checkout(Repository, branch);

            return(true);
        }
コード例 #15
0
ファイル: RunExecutableStep.cs プロジェクト: RockTomate/Steps
        /// <inheritdoc />
        protected override IEnumerator OnExecute(JobContext context)
        {
            var startInfo = new ProcessStartInfo
            {
                FileName         = ExecutableFilePath,
                Arguments        = string.Join(" ", Arguments),
                UseShellExecute  = UseShellExecute,
                WindowStyle      = WindowStyle,
                WorkingDirectory = WorkDirectory,
            };

            _process = new Process
            {
                StartInfo = startInfo
            };

            RockLog.WriteLine(this, LogTier.Info, string.Format("Running: \"{0}\" {1}", ExecutableFilePath, startInfo.Arguments));

            ResetTimeout();

            if (!_process.Start())
            {
                IsSuccess = false;
                yield break;
            }

            // continuously check if the process has exited or timeout has been reached
            while (!_process.HasExited && _currentTimeLeftMs > 0)
            {
                UpdateTimeoutTimeLeft();
                yield return(null);
            }

            // if the timeout has been reached and the process hasn't exited
            if (!_process.HasExited && _currentTimeLeftMs <= 0)
            {
                if (KillOnTimeout)
                {
                    _process.Kill();
                }

                ExitCode  = -1;
                IsSuccess = false;
                yield break;
            }

            ExitCode  = _process.ExitCode;
            IsSuccess = ExitCode == 0;
        }
コード例 #16
0
ファイル: MoveDirectoryStep.cs プロジェクト: RockTomate/Steps
        /// <inheritdoc />
        protected override bool OnValidate()
        {
            if (!Directory.Exists(SourceDirectoryPath))
            {
                RockLog.WriteLine(this, LogTier.Error, string.Format("Source directory not found at: \"{0}\"", SourceDirectoryPath));
                return(false);
            }

            if (!Overwrite && Directory.Exists(NewDirectoryPath))
            {
                RockLog.WriteLine(this, LogTier.Error, string.Format("The directory already exists at: \"{0}\"", SourceDirectoryPath));
                return(false);
            }

            return(true);
        }
コード例 #17
0
ファイル: CopyFileStep.cs プロジェクト: RockTomate/Steps
        /// <inheritdoc />
        protected override bool OnValidate()
        {
            if (!File.Exists(SourceFilePath))
            {
                RockLog.WriteLine(this, LogTier.Error, string.Format("Source file not found at: \"{0}\"", SourceFilePath));
                return(false);
            }

            if (!Overwrite && File.Exists(NewFileCopyPath))
            {
                RockLog.WriteLine(this, LogTier.Error, string.Format("The file already exists at: \"{0}\"", NewFileCopyPath));
                return(false);
            }

            return(true);
        }
コード例 #18
0
        /// <inheritdoc />
        protected override IEnumerator OnExecute(JobContext context)
        {
            if (ItemList.IsEmpty())
            {
                RockLog.WriteLine(this, LogTier.Info, "Nothing to print. Skipping...");
                IsSuccess = true;
                yield break;
            }

            foreach (var item in ItemList)
            {
                Print(item);
                yield return(null);
            }

            IsSuccess = true;
        }
コード例 #19
0
ファイル: CopyFileStep.cs プロジェクト: RockTomate/Steps
        /// <inheritdoc />
        protected override bool OnStepStart()
        {
            try
            {
                if (Overwrite && File.Exists(NewFileCopyPath))
                {
                    File.Delete(NewFileCopyPath);
                }

                File.Copy(SourceFilePath, NewFileCopyPath);
            }
            catch (Exception ex)
            {
                RockLog.WriteLine(LogTier.Error, ex.Message);
                return(false);
            }

            return(true);
        }
コード例 #20
0
ファイル: RunJobStep.cs プロジェクト: RockTomate/Steps
        protected override IEnumerator OnExecute(JobContext context)
        {
            if (TargetJob.Id.Equals(context.JobId))
            {
                RockLog.WriteLine(this, LogTier.Error, "A currently running job cannot run itself!");
                IsSuccess = false;
                yield break;
            }

            _childSession = JobSession.Create(TargetJob, false);

            _childSession.RootContext.Parent.Parent = context;
            context.Session.ChildSessions.Add(_childSession);

            // modify existing job variables
            foreach (var keyValuePair in TargetJobVariables)
            {
                var customVariable  = keyValuePair.Value;
                var jobVariable     = _childSession.RootContext[keyValuePair.Key];
                var overriddenValue = customVariable.GetValue(context);
                jobVariable.UseFormula = false;
                jobVariable.SetValue(overriddenValue);

                RockLog.WriteLine(LogTier.Info, string.Format("Overridden variable named \"{0}\". New value: \"{1}\"",
                                                              jobVariable.Name, overriddenValue));
            }

            // add new variables
            foreach (var keyValuePair in NewVariables)
            {
                _childSession.RootContext.Add(keyValuePair.Value);
            }

            _childSession.Start();

            while (_childSession.InProgress)
            {
                yield return(null);
            }

            IsSuccess = _childSession.IsSuccess;
        }
コード例 #21
0
        /// <inheritdoc />
        protected override IEnumerator OnExecute(JobContext context)
        {
            Directory.CreateDirectory(Path.GetDirectoryName(DestinationFilePath) ?? "");

            _unityWebRequest = UnityWebRequest.Get(new Uri(Url).AbsoluteUri);
            _unityWebRequest.redirectLimit = RedirectLimit;
#if !UNITY_2019_3_OR_NEWER
            _unityWebRequest.chunkedTransfer = UseChunkedTransfer;
#endif

            var operation = _unityWebRequest.SendWebRequest();

            while (!operation.isDone)
            {
                yield return(null);
            }

            // handle failure scenario
#if UNITY_2020_2_OR_NEWER
            if (_unityWebRequest.result == UnityWebRequest.Result.ConnectionError)
#else
            if (_unityWebRequest.isNetworkError || _unityWebRequest.isHttpError)
#endif
            {
                RockLog.WriteLine(this, LogTier.Error, _unityWebRequest.error);
                IsSuccess = false;
                yield break;
            }
            // if the download was successful, save it
            else
            {
                RockLog.WriteLine(this, LogTier.Info, string.Format("Finished downloading file. Saving at \"{0}\"...", DestinationFilePath));

                File.WriteAllBytes(DestinationFilePath, _unityWebRequest.downloadHandler.data);

                RockLog.WriteLine(this, LogTier.Info, string.Format("Finished saving at \"{0}\"!", DestinationFilePath));

                IsSuccess = true;
            }
            _unityWebRequest.Dispose();
        }
コード例 #22
0
        /// <inheritdoc />
        protected override bool OnStepStart()
        {
            try
            {
                if (DuplicateFileBehaviour == DuplicateBehaviour.Overwrite && File.Exists(FilePath))
                {
                    File.Delete(FilePath);
                }

                using (var streamWriter = new StreamWriter(FilePath, DuplicateFileBehaviour == DuplicateBehaviour.Append, Encoding.UTF8))
                {
                    foreach (var content in Contents)
                    {
                        switch (WriteMode)
                        {
                        case WriteType.Write:

                            streamWriter.Write(content);

                            break;

                        case WriteType.WriteLine:

                            streamWriter.WriteLine(content);

                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                RockLog.WriteLine(this, LogTier.Error, ex.Message);
                return(false);
            }

            return(true);
        }
コード例 #23
0
        /// <inheritdoc />
        protected override bool OnStepStart()
        {
            GameObject = new GameObject(Name)
            {
                tag = Tag
            };

            GameObject.transform.position = Position;

            foreach (var compName in Components)
            {
                var componentType = Type.GetType(compName);
                if (componentType == null)
                {
                    RockLog.WriteLine(this, LogTier.Error, string.Format("Component by name \"{0}\" couldn't be added to GameObject named \"{1}\". Skipping...", compName, Name));
                    continue;
                }

                GameObject.AddComponent(componentType);
            }

            return(true);
        }
コード例 #24
0
        protected override bool OnStepStart()
        {
            var branch = Repository.Branches[NewBranchName];

            if (branch == null)
            {
                branch        = Repository.CreateBranch(NewBranchName);
                BranchCreated = true;
            }
            else
            {
                RockLog.WriteLine(this, LogTier.Warning, $"Branch with the name \"{NewBranchName}\" already exists.");
            }

            switch (CheckoutBehaviour)
            {
            case CheckoutBehaviourTypes.OnCreateOnly:

                if (BranchCreated)
                {
                    CheckoutBranch(branch);
                }
                break;

            case CheckoutBehaviourTypes.Always:
                CheckoutBranch(branch);
                break;

            case CheckoutBehaviourTypes.Never:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(true);
        }
コード例 #25
0
        private void Print(object item)
        {
            var message = item.ToString();

            RockLog.WriteLine(this, MessageType, message);

            if (FlushImmediately)
            {
                RockLog.FlushLogs();
            }

            if (!PrintUnityConsole || RTPreferences.Data.PrintToUnityConsole)
            {
                return;
            }

            switch (MessageType)
            {
            case LogTier.Info:

                Debug.Log(message);

                break;

            case LogTier.Warning:

                Debug.LogWarning(message);

                break;

            case LogTier.Error:

                Debug.LogError(message);

                break;
            }
        }
コード例 #26
0
        /// <inheritdoc />
        protected override bool OnValidate()
        {
            if (!File.Exists(UnityExePath))
            {
                RockLog.WriteLine(this, LogTier.Error, string.Format("Unity Engine executable not found at: \"{0}\"", UnityExePath));
                return(false);
            }

            if (!Directory.Exists(ProjectPath))
            {
                RockLog.WriteLine(this, LogTier.Error, string.Format("Project not found at: \"{0}\"", ProjectPath));
                return(false);
            }

            var jobAssetFilePath = PathHelpers.Combine(ProjectPath, LocalJobPath);

            if (!File.Exists(jobAssetFilePath))
            {
                RockLog.WriteLine(this, LogTier.Error, string.Format("Local Job asset not found at: \"{0}\"", jobAssetFilePath));
                return(false);
            }

            return(true);
        }
コード例 #27
0
ファイル: PrintLogStep.cs プロジェクト: RockTomate/Steps
        protected override bool OnStepStart()
        {
            switch (MessageType)
            {
            case LogTier.Info:

                Debug.Log(Message);

                break;

            case LogTier.Warning:

                Debug.LogWarning(Message);

                break;

            case LogTier.Error:

                Debug.LogError(Message);

                break;

            default:
                return(false);
            }

            if (!PrintToConsole || RTPreferences.Data.PrintToUnityConsole)
            {
                return(true);
            }

            RockLog.WriteLine(this, MessageType, Message);
            RockLog.FlushLogs();

            return(true);
        }
コード例 #28
0
        protected override bool OnStepStart()
        {
            var commit1 = GitUtils.GetCommit(Repository, CommitSearch1);

            if (commit1 == null)
            {
                RockLog.WriteLine(this, LogTier.Error, "Commit 1 not found!");
                return(false);
            }

            RockLog.WriteLine(this, LogTier.Info, $"Commit 1 found ({commit1.Sha})");

            var commit2 = GitUtils.GetCommit(Repository, CommitSearch2);

            if (commit2 == null)
            {
                RockLog.WriteLine(this, LogTier.Error, "Commit 2 not found!");
                return(false);
            }

            RockLog.WriteLine(this, LogTier.Info, $"Commit 2 found ({commit2.Sha})");

            if (commit1 == commit2)
            {
                RockLog.WriteLine(this, LogTier.Warning, "Both commits are the same. Aborting comparison...");
                return(true);
            }

            var commitTree1 = commit1.Parents.First().Tree;
            var commitTree2 = commit2.Parents.First().Tree;

            foreach (var entryChange in Repository.Diff.Compare <TreeChanges>(commitTree1, commitTree2))
            {
                var filePath = entryChange.Path;

                FilePaths.Add(filePath);

                switch (entryChange.Status)
                {
                case ChangeKind.Added:
                    AddedFilePaths.Add(filePath);
                    break;

                case ChangeKind.Deleted:
                    DeletedFilePaths.Add(filePath);
                    break;

                case ChangeKind.Modified:
                    ModifiedFilePaths.Add(filePath);
                    break;

                case ChangeKind.Renamed:
                    RenamedFilePaths.Add(filePath);
                    break;

                case ChangeKind.Copied:
                    break;

                case ChangeKind.Ignored:
                    break;

                case ChangeKind.Conflicted:
                    ConflictedFilePaths.Add(filePath);
                    break;

                default:
                    continue;
                }
            }

            return(true);
        }
コード例 #29
0
 private void CheckoutBranch(Branch branch)
 {
     RockLog.WriteLine(this, LogTier.Info, "Checking out to new branch...");
     Commands.Checkout(Repository, branch);
 }
コード例 #30
0
        /// <inheritdoc />
        protected override IEnumerator OnExecute(JobContext context)
        {
            AssetDirectoryPath = PathHelpers.FixSlashes(AssetDirectoryPath);


            _assetStoreApi = new AssetStoreAPI();

            yield return(null);

            _assetStoreApi.Login(Username, Password);

            while (_assetStoreApi.IsLogging())
            {
                yield return(null);
            }

            IsSuccess = _assetStoreApi.IsConnected;

            if (!IsSuccess)
            {
                RockLog.WriteLine(this, LogTier.Error, _assetStoreApi.LastError);
                yield break;
            }

            _assetStoreApi.FetchPackages();

            while (_assetStoreApi.IsFetchingPackages())
            {
                yield return(null);
            }

            IsSuccess = _assetStoreApi.HasPackages;

            if (!IsSuccess)
            {
                RockLog.WriteLine(this, LogTier.Error, _assetStoreApi.LastError);
                yield break;
            }

            // fetch required package
            var package = _assetStoreApi.EachPackage.FirstOrDefault(x => x.packageId == PackageId);

            if (package == null)
            {
                RockLog.WriteLine(this, LogTier.Error, string.Format("Package of id \"{0}\" not found.", PackageId));
                IsSuccess = false;
                yield break;
            }

            yield return(null);

            var packageFilePath = GeneratePackage();

            yield return(null);

            HttpWebResponse uploadWebResponse = null;

            var rootPath = AssetDirectoryPath;

            if (!rootPath.StartsWith("/"))
            {
                rootPath = '/' + AssetDirectoryPath;
            }

            // upload package to the asset store dashboard
            _assetStoreApi.Upload(
                package.id,
                packageFilePath,
                rootPath,
                Application.dataPath,
                Application.unityVersion,
                (response, s) =>
            {
                uploadWebResponse = response;
            }
                );

            while (uploadWebResponse == null)
            {
                yield return(null);
            }

            IsSuccess = uploadWebResponse.StatusCode == HttpStatusCode.OK;
        }