コード例 #1
0
        public void GetEnviornmentVariables_Should_Empty_Dictionary()
        {
            // Given
            var continuousIntegrationServer = new ContinuousIntegrationServer(new Mock <IEnviornmentVariables>().Object);

            // When
            var enviornmentVariables = continuousIntegrationServer.UserEnvironmentVariables;

            // Then
            enviornmentVariables.Should().BeEmpty();
        }
コード例 #2
0
        public void Branch_Should_Be_Empty_String()
        {
            // Given
            var continuousIntegrationServer = new ContinuousIntegrationServer();

            // When
            var branch = continuousIntegrationServer.Branch;

            // Then
            branch.Should().BeEmpty();
        }
コード例 #3
0
        public void Commit_Should_Empty_String()
        {
            // Given
            var continuousIntegrationServer = new ContinuousIntegrationServer();

            // When
            var commit = continuousIntegrationServer.Commit;

            // Then
            commit.Should().BeEmpty();
        }
コード例 #4
0
        public void Tag_Should_Empty_String()
        {
            // Given
            var continuousIntegrationServer = new ContinuousIntegrationServer(new Mock <IEnviornmentVariables>().Object);

            // When
            var slug = continuousIntegrationServer.Tag;

            // Then
            slug.Should().BeEmpty();
        }
コード例 #5
0
        public void Build_Should_Be_Empty_String_When_Enviornment_Variable_Does_Not_Exits()
        {
            // Given
            var cis = new ContinuousIntegrationServer(new Mock <IEnviornmentVariables>().Object);

            // When
            var build = cis.Build;

            // Then
            build.Should().BeEmpty();
        }
コード例 #6
0
        public void Service_Should_Empty_String()
        {
            // Given
            var continuousIntegrationServer = new ContinuousIntegrationServer(new Mock <IEnviornmentVariables>().Object);

            // When
            var service = continuousIntegrationServer.Service;

            // Then
            service.Should().BeEmpty();
        }
コード例 #7
0
        public void Branch_Should_Be_Empty_String()
        {
            // Given
            var continuousIntegrationServer = new ContinuousIntegrationServer(new Mock <IEnviornmentVariables>().Object);

            // When
            var branch = continuousIntegrationServer.Branch;

            // Then
            branch.Should().BeEmpty();
        }
コード例 #8
0
        public void GetEnviornmentVariables_Should_Empty_Dictionary()
        {
            // Given
            var continuousIntegrationServer = new ContinuousIntegrationServer();

            // When
            var enviornmentVariables = continuousIntegrationServer.GetEnviornmentVariables;

            // Then
            enviornmentVariables.Should().BeEmpty();
        }
コード例 #9
0
        public void Tag_Should_Empty_String()
        {
            // Given
            var continuousIntegrationServer = new ContinuousIntegrationServer();

            // When
            var slug = continuousIntegrationServer.Tag;

            // Then
            slug.Should().BeEmpty();
        }
コード例 #10
0
        public void Pr_Should_Empty_String()
        {
            // Given
            var continuousIntegrationServer = new ContinuousIntegrationServer();

            // when
            var pr = continuousIntegrationServer.Pr;

            // Then
            pr.Should().BeEmpty();
        }
コード例 #11
0
        public void Service_Should_Empty_String()
        {
            // Given
            var continuousIntegrationServer = new ContinuousIntegrationServer();

            // When
            var service = continuousIntegrationServer.Service;

            // Then
            service.Should().BeEmpty();
        }
コード例 #12
0
        public void Pr_Should_Empty_String()
        {
            // Given
            var continuousIntegrationServer = new ContinuousIntegrationServer(new Mock <IEnviornmentVariables>().Object);

            // when
            var pr = continuousIntegrationServer.Pr;

            // Then
            pr.Should().BeEmpty();
        }
コード例 #13
0
        public void Detecter_Should_False()
        {
            // Given
            var continuousIntegrationServer = new ContinuousIntegrationServer();

            // when
            var detecter = continuousIntegrationServer.Detecter;

            // Then
            detecter.Should().BeFalse();
        }
コード例 #14
0
        public void Detecter_Should_False()
        {
            // Given
            var continuousIntegrationServer = new ContinuousIntegrationServer(new Mock <IEnviornmentVariables>().Object);

            // when
            var detecter = continuousIntegrationServer.Detecter;

            // Then
            detecter.Should().BeFalse();
        }
コード例 #15
0
        public void Commit_Should_Empty_String()
        {
            // Given
            var continuousIntegrationServer = new ContinuousIntegrationServer(new Mock <IEnviornmentVariables>().Object);

            // When
            var commit = continuousIntegrationServer.Commit;

            // Then
            commit.Should().BeEmpty();
        }
コード例 #16
0
        public void BuildUrl_Should_Be_Set_When_Enviornment_Variable_Exits()
        {
            // Given
            Environment.SetEnvironmentVariable("CI_BUILD_URL", "www.google.com");
            var continuousIntegrationServer = new ContinuousIntegrationServer();

            // When
            var buildUrl = continuousIntegrationServer.BuildUrl;

            // Then
            buildUrl.Should().Be("www.google.com");
        }
コード例 #17
0
        public void BuildUrl_Should_Be_Empty_String_When_Enviornment_Variable_Does_Not_Exits()
        {
            // Given
            Environment.SetEnvironmentVariable("CI_BUILD_URL", null);
            var continuousIntegrationServer = new ContinuousIntegrationServer();

            // When
            var buildUrl = continuousIntegrationServer.BuildUrl;

            // Then
            buildUrl.Should().BeEmpty();
        }
コード例 #18
0
        public void Build_Should_Be_Set_When_Enviornment_Variable_Exits()
        {
            // Given
            Environment.SetEnvironmentVariable("CI_BUILD_ID", "123");
            var continuousIntegrationServer = new ContinuousIntegrationServer();

            // When
            var build = continuousIntegrationServer.Build;

            // Then
            build.Should().Be("123");
        }
コード例 #19
0
        public void Job_Should_Be_Set_When_Enviornment_Variable_Exits()
        {
            // Given
            Environment.SetEnvironmentVariable("CI_JOB_ID", "123");
            var continuousIntegrationServer = new ContinuousIntegrationServer();

            // When
            var job = continuousIntegrationServer.Job;

            // Then
            job.Should().Be("123");
        }
コード例 #20
0
        public void Job_Should_Be_Empty_String_When_Enviornment_Variable_Does_Not_Exits()
        {
            // Given
            Environment.SetEnvironmentVariable("CI_JOB_ID", null);
            var continuousIntegrationServer = new ContinuousIntegrationServer();

            // When
            var job = continuousIntegrationServer.Job;

            // Then
            job.Should().BeEmpty();
        }
コード例 #21
0
        public void Job_Should_Be_Set_When_Enviornment_Variable_Exits()
        {
            // Given
            var ev = new Mock <IEnviornmentVariables>();

            ev.Setup(s => s.GetEnvironmentVariable("CI_JOB_ID")).Returns("123");
            var cis = new ContinuousIntegrationServer(ev.Object);

            // When
            var job = cis.Job;

            // Then
            job.Should().Be("123");
        }
コード例 #22
0
        public void BuildUrl_Should_Be_Set_When_Enviornment_Variable_Exits()
        {
            // Given
            var ev = new Mock <IEnviornmentVariables>();

            ev.Setup(s => s.GetEnvironmentVariable("CI_BUILD_URL")).Returns("www.google.com");
            var cis = new ContinuousIntegrationServer(ev.Object);

            // When
            var buildUrl = cis.BuildUrl;

            // Then
            buildUrl.Should().Be("www.google.com");
        }
コード例 #23
0
        public void Uploader()
        {
            var ci = ContinuousIntegrationServer.GetType().Name;

            if (ci.Equals("ContinuousIntegrationServer"))
            {
                Log.Warning("No CI detected.");
            }
            else if (ci.Equals("TeamCity"))
            {
                Log.Information("TeamCity detected.");
                if (string.IsNullOrWhiteSpace(ContinuousIntegrationServer.Branch))
                {
                    Log.Warning("Teamcity does not automatically make build parameters available as environment variables.\nAdd the following environment parameters to the build configuration.\nenv.TEAMCITY_BUILD_BRANCH = %teamcity.build.branch%.\nenv.TEAMCITY_BUILD_ID = %teamcity.build.id%.\nenv.TEAMCITY_BUILD_URL = %teamcity.serverUrl%/viewLog.html?buildId=%teamcity.build.id%.\nenv.TEAMCITY_BUILD_COMMIT = %system.build.vcs.number%.\nenv.TEAMCITY_BUILD_REPOSITORY = %vcsroot.<YOUR TEAMCITY VCS NAME>.url%.");
                }
            }
            else
            {
                Log.Information($"{ci} detected.");
            }

            var vcs = VersionControlSystem.GetType().Name;

            if (vcs.Equals("VersionControlSystem"))
            {
                Log.Warning("No VCS detected.");
            }
            else
            {
                Log.Information($"{vcs} detected.");
            }

            Log.Information($"Project root: {VersionControlSystem.RepoRoot}");
            if (string.IsNullOrWhiteSpace(Yaml.FileName))
            {
                Log.Information("Yaml not found, that's ok! Learn more at http://docs.codecov.io/docs/codecov-yaml");
            }

            Log.Information("Reading reports.");
            Log.Information(string.Join("\n", Coverage.CoverageReports.Select(x => x.File)));

            if (EnviornmentVariables.GetEnviornmentVariables.Any())
            {
                Log.Information("Appending build variables");
                Log.Information(string.Join("\n", EnviornmentVariables.GetEnviornmentVariables.Select(x => x.Key.Trim()).ToArray()));
            }

            if (CommandLineCommandLineOptions.Dump)
            {
                Log.Warning("Skipping upload and dumping contents.");
                Log.Information(Report.Reporter);
                return;
            }

            Log.Information("Uploading Reports.");
            Log.Information("Pinging Codecov");

            var response = Upload.Uploader();

            Log.Verboase($"response: {response}");
            var splitResponse = response.Split('\n');

            if (CommandLineCommandLineOptions.DisableS3)
            {
                var reportUrl = splitResponse[1];
                Log.Information($"View reports at: {reportUrl}");
            }
            else
            {
                var s3        = new Uri(splitResponse[1]);
                var reportUrl = splitResponse[0];
                Log.Information($"Uploading to S3 {s3.Scheme}://{s3.Authority}");
                Log.Information($"View reports at: {reportUrl}");
            }
        }
コード例 #24
0
        public void Uploader()
        {
            var ci = ContinuousIntegrationServer.GetType().Name;

            if (ci.Equals("ContinuousIntegrationServer"))
            {
                Log.Warning("No CI detected.");
            }
            else if (ci.Equals("TeamCity"))
            {
                Log.Information("{ci} detected.", ci);
                if (string.IsNullOrWhiteSpace(ContinuousIntegrationServer.Branch))
                {
                    Log.Warning("Teamcity does not automatically make build parameters available as environment variables.\nAdd the following environment parameters to the build configuration.\nenv.TEAMCITY_BUILD_BRANCH = %teamcity.build.branch%.\nenv.TEAMCITY_BUILD_ID = %teamcity.build.id%.\nenv.TEAMCITY_BUILD_URL = %teamcity.serverUrl%/viewLog.html?buildId=%teamcity.build.id%.\nenv.TEAMCITY_BUILD_COMMIT = %system.build.vcs.number%.\nenv.TEAMCITY_BUILD_REPOSITORY = %vcsroot.<YOUR TEAMCITY VCS NAME>.url%.");
                }
            }
            else
            {
                Log.Information("{ci} detected.", ci);
            }

            var vcs = VersionControlSystem.GetType().Name;

            if (vcs.Equals("VersionControlSystem"))
            {
                Log.Warning("No VCS detected.");
            }
            else
            {
                Log.Information("{vcs} detected.", vcs);
            }

            Log.Information("Project root: {RepoRoot}", VersionControlSystem.RepoRoot);
            if (string.IsNullOrWhiteSpace(Yaml.FileName))
            {
                Log.Information("Yaml not found, that's ok! Learn more at {CodecovUrl}", "https://docs.codecov.io/docs/codecov-yaml");
            }

            Log.Information("Reading reports.");
            Log.Information(string.Join("\n", Coverage.CoverageReports.Select(x => x.File)));

            if (EnviornmentVariables.UserEnvironmentVariables.Any())
            {
                Log.Information("Appending build variables");
                Log.Information(string.Join("\n", EnviornmentVariables.UserEnvironmentVariables.Select(x => x.Key.Trim()).ToArray()));
            }

            if (CommandLineCommandLineOptions.Dump)
            {
                Log.Warning("Skipping upload and dumping contents.");
                Log.Information("url: {GetUrl}", Url.GetUrl);
                Log.Information(Report.Reporter);
                return;
            }

            // We warn if the total file size is above 20 MB
            var fileSizes = Coverage.CoverageReports.Sum(x => FileSystem.GetFileSize(x.File));

            if (fileSizes > 20_971_520)
            {
                Log.Warning("Total file size of reports is above 20MB, this may prevent report being shown on {Host}", Url.GetUrl.Host);
                Log.Warning("Reduce the total upload size if this occurs");
            }

            Log.Information("Uploading Reports.");
            Log.Information("url: {Scheme}://{Authority}", Url.GetUrl.Scheme, Url.GetUrl.Authority);
            Log.Information("query: {DisplayUrl}", DisplayUrl);

            var response = Upload.Uploader();

            Log.Verbose("response: {response}", response);
            var splitResponse = response.Split('\n');

            if (splitResponse.Length > 1)
            {
                var s3        = new Uri(splitResponse[1]);
                var reportUrl = splitResponse[0];
                Log.Information("Uploading to S3 {Scheme}://{Authority}", s3.Scheme, s3.Authority);
                Log.Information("View reports at: {reportUrl}", reportUrl);
            }
        }