Пример #1
0
        private static void Main(string[] args)
        {
            if (args.Length < 2 || args.Length > 4)
            {
                DrawHeader();
                return;
            }

            var coverallsModelcs = new CoverallsModelcs();
            coverallsModelcs.RepoToken = Environment.GetEnvironmentVariable(COVERALLS_REPO_TOKEN);

            if (string.IsNullOrEmpty(coverallsModelcs.RepoToken))
            {
                Log.ErrorWriteLine($"Environment variable '{COVERALLS_REPO_TOKEN}' is empty");
            }

            gitRootFolder = Path.GetFullPath(args[0]);
            if (!Directory.Exists(gitRootFolder))
            {
                Log.ErrorWriteLine("Path to git root folder doesn't exist.");
            }

            var xmlPath = Path.GetFullPath(args[1]);
            if (!File.Exists(xmlPath))
            {
                Log.ErrorWriteLine($"File {xmlPath} not found.");
            }

            if (args.Length >= 3 && !string.IsNullOrEmpty(args[2]))
            {
                coverallsModelcs.ServiceName = args[2];
            }
            var gitInfo = new GitInfo(gitRootFolder);
            coverallsModelcs.Git.Head = gitInfo.GetLastCommitInfo();

            coverallsModelcs.Git.Branch = args.Length >= 4 && !string.IsNullOrEmpty(args[3])
                ? args[3]
                : gitInfo.GetCurrentBranchName();

            coverallsModelcs.ServiceBranch = coverallsModelcs.Git.Branch;

            var xdoc = XDocument.Load(xmlPath);
            ConvertCloverXMLtoJSON(xdoc, coverallsModelcs);
            var bytes = coverallsModelcs.ToJson();
            HttpUploadFile("https://coveralls.io/api/v1/jobs", bytes);
        }