Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow validation from external scripts #5

Open
kirre-bylund opened this issue Dec 21, 2023 · 0 comments
Open

Allow validation from external scripts #5

kirre-bylund opened this issue Dec 21, 2023 · 0 comments

Comments

@kirre-bylund
Copy link

As a plugin developer for the Unity Asset Store I want to be able to utilize the official Asset Store Tools validation feature in my plugins CI to ensure maximum quality of my plugin. This is not possible at the time since everything is marked as internal.

If this is not something you have decided to specifically disallow, I would suggest opening the validation part of the tool up to be called from external scripts. I did a quick and dirty proof of concept of this which works (though needs improvement to keep the same quality as the rest of the tool):

namespace AssetStoreTools.Validator
{
    public static class PackageValidatorExposer
    {
        public class ValidationResult
        {
            public bool Success { get; set; }
            public string Error { get; set; }
        }
        public static ValidationResult ValidatePackage(string path)
        {
            var settings = new ValidationSettings
            {
                Category = "",
                ValidationPaths = new List<string> { path }
            };
            var result = PackageValidator.ValidatePackage(settings);
            bool testFailures = false;
            string testFailureMessages = "";
            foreach (var test in result.AutomatedTests)
            {
                testFailures |= test.Result.Result != TestResult.ResultStatus.Pass;
                if (test.Result.Result != TestResult.ResultStatus.Pass)
                {
                    for (int i = 0; i < test.Result.MessageCount; i++)
                    {
                        testFailureMessages += test.Result.GetMessage(i).GetText() + "\n";
                    }
                }
            }
            var newResult = new ValidationResult
            {
                Success = result.Status == ValidationStatus.RanToCompletion && !result.HadCompilationErrors &&
                          string.IsNullOrEmpty(result.Error) && !testFailures,
                Error = result.Error + "\n" + testFailureMessages
            };
            return newResult;
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant