diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..923b209 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +language: csharp +os: + - linux +git: + depth: 999999 +before_install: + - git status + - git branch +mono: + - latest +dotnet: 1.0.4 +dist: trusty +script: + - ./build.sh diff --git a/README.md b/README.md index 1790d8c..b63497f 100644 --- a/README.md +++ b/README.md @@ -265,19 +265,21 @@ Note that this mechanism is not as strongly typed as the other methods; you will ## Build Status -The repository is built on [AppVeyor](https://ci.appveyor.com/project/binarymash/responses). - ### Stable -[![Build status](https://ci.appveyor.com/api/projects/status/p51dvusrw32u9b17/branch/master?svg=true)](https://ci.appveyor.com/project/binarymash/responses/branch/master) -[![Coverage Status](https://coveralls.io/repos/github/binarymash/responses/badge.svg?branch=master)](https://coveralls.io/github/binarymash/responses?branch=master) +| Environment | Environment Config | Build Server | Status | Coverage +|--------------|--------------------|--------------|--------|--------- +| Windows | Visual Studio 2017 | Appveyor | [![Build status](https://ci.appveyor.com/api/projects/status/p51dvusrw32u9b17/branch/master?svg=true)](https://ci.appveyor.com/project/binarymash/responses/branch/master) | [![Coverage Status](https://coveralls.io/repos/github/binarymash/responses/badge.svg?branch=master)](https://coveralls.io/github/binarymash/responses?branch=master) +| Ubuntu 14.04 | SDK 1.0.4 | Travis | [![Build Status](https://travis-ci.org/binarymash/responses.svg?branch=master)](https://travis-ci.org/binarymash/responses) | - -### Development +### Development -[![Build status](https://ci.appveyor.com/api/projects/status/p51dvusrw32u9b17/branch/develop?svg=true)](https://ci.appveyor.com/project/binarymash/responses/branch/develop) -[![Coverage Status](https://coveralls.io/repos/github/binarymash/responses/badge.svg?branch=develop)](https://coveralls.io/github/binarymash/responses?branch=develop) +| Environment | Environment Config | Build Server | Status | Coverage +|--------------|--------------------|--------------|--------|--------- +| Windows | Visual Studio 2017 | Appveyor | [![Build status](https://ci.appveyor.com/api/projects/status/p51dvusrw32u9b17/branch/develop?svg=true)](https://ci.appveyor.com/project/binarymash/responses/branch/develop) | [![Coverage Status](https://coveralls.io/repos/github/binarymash/responses/badge.svg?branch=develop)](https://coveralls.io/github/binarymash/responses?branch=develop) +| Ubuntu 14.04 | SDK 1.0.4 | Travis | [![Build Status](https://travis-ci.org/binarymash/responses.svg?branch=develop)](https://travis-ci.org/binarymash/responses) | - Development builds are published to https://www.myget.org/F/binarymash-unstable/api/v3/index.json diff --git a/build.cake b/build.cake index ecf74bf..40aafe6 100644 --- a/build.cake +++ b/build.cake @@ -81,15 +81,15 @@ Task("Version") var nugetVersion = versioning.NuGetVersion; Information("SemVer version number: " + nugetVersion); - if (AppVeyor.IsRunningOnAppVeyor) + if (BuildSystem.IsLocalBuild) { - Information("Persisting version number..."); - PersistVersion(committedVersion, nugetVersion); - buildVersion = nugetVersion; + Information("We are not running on build server, so we won't persist the version number."); } else { - Information("We are not running on build server, so we won't persist the version number."); + Information("Persisting version number..."); + PersistVersion(committedVersion, nugetVersion); + buildVersion = nugetVersion; } }); @@ -117,55 +117,70 @@ Task("RunUnitTestsCoverageReport") .IsDependentOn("Compile") .Does(context => { - var coverageSummaryFile = artifactsForUnitTestsDir + File("coverage.xml"); - - EnsureDirectoryExists(artifactsForUnitTestsDir); - - OpenCover(tool => - { - tool.DotNetCoreTest(unitTestAssemblies); - }, - new FilePath(coverageSummaryFile), - new OpenCoverSettings() - { - Register="user", - ArgumentCustomization=args=>args.Append(@"-oldstyle -returntargetcode") - } - .WithFilter("+[BinaryMash.*]*") - .WithFilter("-[xunit*]*") - .WithFilter("-[BinaryMash.*.Tests]*") - ); - - ReportGenerator(coverageSummaryFile, artifactsForUnitTestsDir); - - if (AppVeyor.IsRunningOnAppVeyor) + if (IsRunningOnWindows()) { - var repoToken = EnvironmentVariable(coverallsRepoToken); - if (string.IsNullOrEmpty(repoToken)) + var coverageSummaryFile = artifactsForUnitTestsDir + File("coverage.xml"); + + EnsureDirectoryExists(artifactsForUnitTestsDir); + + OpenCover(tool => + { + tool.DotNetCoreTest(unitTestAssemblies); + }, + new FilePath(coverageSummaryFile), + new OpenCoverSettings() + { + Register="user", + ArgumentCustomization=args=>args.Append(@"-oldstyle -returntargetcode") + } + .WithFilter("+[BinaryMash.*]*") + .WithFilter("-[xunit*]*") + .WithFilter("-[BinaryMash.*.Tests]*") + ); + + ReportGenerator(coverageSummaryFile, artifactsForUnitTestsDir); + + if (BuildSystem.IsRunningOnAppVeyor) + { + var repoToken = EnvironmentVariable(coverallsRepoToken); + if (string.IsNullOrEmpty(repoToken)) + { + throw new Exception(string.Format("Coveralls repo token not found. Set environment variable '{0}'", coverallsRepoToken)); + } + + Information("Uploading test coverage to coveralls.io"); + CoverallsNet(coverageSummaryFile, CoverallsNetReportType.OpenCover, new CoverallsNetSettings() + { + RepoToken = repoToken + }); + } + else { - throw new Exception(string.Format("Coveralls repo token not found. Set environment variable '{0}'", coverallsRepoToken)); + Information("We are not running on the authoritative build server so we won't publish the coverage report to coveralls.io"); } - Information("Uploading test coverage to coveralls.io"); - CoverallsNet(coverageSummaryFile, CoverallsNetReportType.OpenCover, new CoverallsNetSettings() + var sequenceCoverage = XmlPeek(coverageSummaryFile, "//CoverageSession/Summary/@sequenceCoverage"); + var branchCoverage = XmlPeek(coverageSummaryFile, "//CoverageSession/Summary/@branchCoverage"); + + Information("Sequence Coverage: " + sequenceCoverage); + + if(double.Parse(sequenceCoverage) < minCodeCoverage) { - RepoToken = repoToken - }); + throw new Exception(string.Format("Code coverage fell below the threshold of {0}%", minCodeCoverage)); + }; } else { - Information("We are not running on the build server so we won't publish the coverage report to coveralls.io"); - } + var settings = new DotNetCoreTestSettings + { + Configuration = compileConfig, + }; - var sequenceCoverage = XmlPeek(coverageSummaryFile, "//CoverageSession/Summary/@sequenceCoverage"); - var branchCoverage = XmlPeek(coverageSummaryFile, "//CoverageSession/Summary/@branchCoverage"); + EnsureDirectoryExists(artifactsForUnitTestsDir); + DotNetCoreTest(unitTestAssemblies, settings); - Information("Sequence Coverage: " + sequenceCoverage); - - if(double.Parse(sequenceCoverage) < minCodeCoverage) - { - throw new Exception(string.Format("Code coverage fell below the threshold of {0}%", minCodeCoverage)); - }; + Warning("We are not running on Windows, so cannot test code coverage. If coverage is insufficient then the build will fail at this point when building on Windows."); + } }); Task("RunTests") @@ -186,7 +201,7 @@ Task("CreatePackages") "releaseNotes:releasenotes.md" }); - if (AppVeyor.IsRunningOnAppVeyor) + if (BuildSystem.IsRunningOnAppVeyor) { var path = packagesDir.ToString() + @"/**/*"; @@ -210,7 +225,7 @@ Task("ReleasePackagesToUnstableFeed") Task("EnsureStableReleaseRequirements") .Does(() => { - if (!AppVeyor.IsRunningOnAppVeyor) + if (!BuildSystem.IsRunningOnAppVeyor) { throw new Exception("Stable release should happen via appveyor"); }