changes suggest by mr mash

This commit is contained in:
TomPallister 2017-03-11 09:13:50 +00:00
parent 490de4c45d
commit efec217cab
2 changed files with 67 additions and 95 deletions

View File

@ -7,20 +7,22 @@
// compile
var compileConfig = Argument("configuration", "Release");
var projectJson = "./src/Ocelot/project.json";
var slnFile = "./Ocelot.sln";
// build artifacts
var artifactsDir = Directory("artifacts");
// unit testing
var artifactsForUnitTestsDir = artifactsDir + Directory("UnitTests");
var unitTestAssemblies = @"./test/Ocelot.UnitTests";
var unitTestAssemblies = @"./test/Ocelot.UnitTests/Ocelot.UnitTests.csproj";
// acceptance testing
var artifactsForAcceptanceTestsDir = artifactsDir + Directory("AcceptanceTests");
var acceptanceTestAssemblies = @"./test/Ocelot.AcceptanceTests/Ocelot.AcceptanceTests.csproj";
// integration testing
var artifactsForIntegrationTestsDir = artifactsDir + Directory("IntegrationTests");
var integrationTestAssemblies = @"./test/Ocelot.IntegrationTests/Ocelot.IntegrationTests.csproj";
// benchmark testing
var artifactsForBenchmarkTestsDir = artifactsDir + Directory("BenchmarkTests");
@ -81,13 +83,12 @@ Task("Version")
{
versioning = GetNuGetVersionForCommit();
var nugetVersion = versioning.NuGetVersion;
Information("SemVer version number: " + nugetVersion);
if (AppVeyor.IsRunningOnAppVeyor)
{
Information("Persisting version number...");
PersistVersion(committedVersion, nugetVersion);
PersistVersion(nugetVersion);
buildVersion = nugetVersion;
}
else
@ -101,102 +102,76 @@ Task("Restore")
.IsDependentOn("Version")
.Does(() =>
{
DotNetCoreRestore("./src");
DotNetCoreRestore("./test");
DotNetCoreRestore(slnFile);
});
Task("RunUnitTests")
Task("Compile")
.IsDependentOn("Restore")
.Does(() =>
{
var buildSettings = new DotNetCoreTestSettings
var settings = new DotNetCoreBuildSettings
{
Configuration = compileConfig,
};
DotNetCoreBuild(slnFile, settings);
});
Task("RunUnitTests")
.IsDependentOn("Compile")
.Does(() =>
{
var settings = new DotNetCoreTestSettings
{
Configuration = compileConfig,
};
EnsureDirectoryExists(artifactsForUnitTestsDir);
DotNetCoreTest(unitTestAssemblies, buildSettings);
DotNetCoreTest(unitTestAssemblies, settings);
});
Task("RunAcceptanceTests")
.IsDependentOn("Restore")
.IsDependentOn("Compile")
.Does(() =>
{
var buildSettings = new DotNetCoreTestSettings
{
Configuration = "Debug", //acceptance test config is hard-coded for debug
};
EnsureDirectoryExists(artifactsForAcceptanceTestsDir);
DoInDirectory("test/Ocelot.AcceptanceTests", () =>
{
DotNetCoreTest(".", buildSettings);
});
});
Task("RunIntegrationTests")
.IsDependentOn("Restore")
.Does(() =>
{
var buildSettings = new DotNetCoreTestSettings
{
Configuration = "Debug", //int test config is hard-coded for debug
};
EnsureDirectoryExists(artifactsForIntegrationTestsDir);
DoInDirectory("test/Ocelot.IntegrationTests", () =>
{
DotNetCoreTest(".", buildSettings);
});
});
Task("RunBenchmarkTests")
.IsDependentOn("Restore")
.Does(() =>
{
var buildSettings = new DotNetCoreRunSettings
var settings = new DotNetCoreTestSettings
{
Configuration = compileConfig,
};
EnsureDirectoryExists(artifactsForBenchmarkTestsDir);
DoInDirectory(benchmarkTestAssemblies, () =>
{
DotNetCoreRun(".", "", buildSettings);
EnsureDirectoryExists(artifactsForAcceptanceTestsDir);
DotNetCoreTest(acceptanceTestAssemblies, settings);
});
Task("RunIntegrationTests")
.IsDependentOn("Compile")
.Does(() =>
{
var settings = new DotNetCoreTestSettings
{
Configuration = compileConfig,
};
EnsureDirectoryExists(artifactsForIntegrationTestsDir);
DotNetCoreTest(integrationTestAssemblies, settings);
});
Task("RunTests")
.IsDependentOn("RunUnitTests")
.IsDependentOn("RunAcceptanceTests")
.IsDependentOn("RunIntegrationTests")
.Does(() =>
{
});
.IsDependentOn("RunIntegrationTests");
Task("CreatePackages")
.IsDependentOn("Compile")
.Does(() =>
{
EnsureDirectoryExists(packagesDir);
CopyFiles("./src/**/Ocelot.*.nupkg", packagesDir);
GenerateReleaseNotes(releaseNotesFile);
var settings = new DotNetCorePackSettings
{
OutputDirectory = packagesDir,
NoBuild = true
};
DotNetCorePack(projectJson, settings);
GenerateReleaseNotes();
System.IO.File.WriteAllLines(artifactsFile, new[]{
"nuget:Ocelot." + buildVersion + ".nupkg",
"nugetSymbols:Ocelot." + buildVersion + ".symbols.nupkg",
"releaseNotes:releasenotes.md"
});
@ -215,9 +190,9 @@ Task("ReleasePackagesToUnstableFeed")
.IsDependentOn("CreatePackages")
.Does(() =>
{
if (ShouldPublishToUnstableFeed(nugetFeedUnstableBranchFilter, versioning.BranchName))
if (ShouldPublishToUnstableFeed())
{
PublishPackages(packagesDir, artifactsFile, nugetFeedUnstableKey, nugetFeedUnstableUploadUrl, nugetFeedUnstableSymbolsUploadUrl);
PublishPackages(nugetFeedUnstableKey, nugetFeedUnstableUploadUrl, nugetFeedUnstableSymbolsUploadUrl);
}
});
@ -270,7 +245,7 @@ Task("ReleasePackagesToStableFeed")
.IsDependentOn("DownloadGitHubReleaseArtifacts")
.Does(() =>
{
PublishPackages(packagesDir, artifactsFile, nugetFeedStableKey, nugetFeedStableUploadUrl, nugetFeedStableSymbolsUploadUrl);
PublishPackages(nugetFeedStableKey, nugetFeedStableUploadUrl, nugetFeedStableSymbolsUploadUrl);
});
Task("Release")
@ -290,43 +265,37 @@ private GitVersion GetNuGetVersionForCommit()
}
/// Updates project version in all of our projects
private void PersistVersion(string committedVersion, string newVersion)
private void PersistVersion(string version)
{
Information(string.Format("We'll search all project.json files for {0} and replace with {1}...", committedVersion, newVersion));
Information(string.Format("We'll search all csproj files for {0} and replace with {1}...", committedVersion, version));
var projectJsonFiles = GetFiles("./**/project.json");
var projectFiles = GetFiles("./**/*.csproj");
foreach(var projectJsonFile in projectJsonFiles)
foreach(var projectFile in projectFiles)
{
var file = projectJsonFile.ToString();
var file = projectFile.ToString();
Information(string.Format("Updating {0}...", file));
var updatedProjectJson = System.IO.File.ReadAllText(file)
.Replace(committedVersion, newVersion);
var updatedProjectFile = System.IO.File.ReadAllText(file)
.Replace(committedVersion, version);
System.IO.File.WriteAllText(file, updatedProjectJson);
System.IO.File.WriteAllText(file, updatedProjectFile);
}
}
/// generates release notes based on issues closed in GitHub since the last release
private void GenerateReleaseNotes(ConvertableFilePath file)
private void GenerateReleaseNotes()
{
if (!IsRunningOnWindows())
{
Warning("We can't generate release notes as we're not running on Windows.");
return;
}
Information("Generating release notes at " + file);
Information("Generating release notes at " + releaseNotesFile);
var releaseNotesExitCode = StartProcess(
@"tools/GitReleaseNotes/tools/gitreleasenotes.exe",
new ProcessSettings { Arguments = ". /o " + file });
new ProcessSettings { Arguments = ". /o " + releaseNotesFile });
if (string.IsNullOrEmpty(System.IO.File.ReadAllText(file)))
if (string.IsNullOrEmpty(System.IO.File.ReadAllText(releaseNotesFile)))
{
System.IO.File.WriteAllText(file, "No issues closed since last release");
System.IO.File.WriteAllText(releaseNotesFile, "No issues closed since last release");
}
if (releaseNotesExitCode != 0)
@ -336,7 +305,7 @@ private void GenerateReleaseNotes(ConvertableFilePath file)
}
/// Publishes code and symbols packages to nuget feed, based on contents of artifacts file
private void PublishPackages(ConvertableDirectoryPath packagesDir, ConvertableFilePath artifactsFile, string feedApiKey, string codeFeedUrl, string symbolFeedUrl)
private void PublishPackages(string feedApiKey, string codeFeedUrl, string symbolFeedUrl)
{
var artifacts = System.IO.File
.ReadAllLines(artifactsFile)
@ -345,7 +314,6 @@ private void PublishPackages(ConvertableDirectoryPath packagesDir, ConvertableFi
var codePackage = packagesDir + File(artifacts["nuget"]);
Information("Pushing package " + codePackage);
NuGetPush(
codePackage,
new NuGetPushSettings {
@ -372,17 +340,17 @@ private string GetResource(string url)
}
}
private bool ShouldPublishToUnstableFeed(string filter, string branchName)
private bool ShouldPublishToUnstableFeed()
{
var regex = new System.Text.RegularExpressions.Regex(filter);
var publish = regex.IsMatch(branchName);
var regex = new System.Text.RegularExpressions.Regex(nugetFeedUnstableBranchFilter);
var publish = regex.IsMatch(versioning.BranchName);
if (publish)
{
Information("Branch " + branchName + " will be published to the unstable feed");
Information("Branch " + versioning.BranchName + " will be published to the unstable feed");
}
else
{
Information("Branch " + branchName + " will not be published to the unstable feed");
Information("Branch " + versioning.BranchName + " will not be published to the unstable feed");
}
return publish;
}

View File

@ -5,15 +5,19 @@
<AssemblyTitle>Ocelot</AssemblyTitle>
<VersionPrefix>0.0.0-dev</VersionPrefix>
<TargetFramework>netcoreapp1.1</TargetFramework>
<NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion>
<AssemblyName>Ocelot</AssemblyName>
<PackageId>Ocelot</PackageId>
<PackageTags>API Gateway;.NET core</PackageTags>
<PackageProjectUrl>https://github.com/TomPallister/Ocelot</PackageProjectUrl>
<PackageProjectUrl>https://github.com/TomPallister/Ocelot</PackageProjectUrl>
<RuntimeIdentifiers>win10-x64;osx.10.11-x64;osx.10.12-x64;win7-x64</RuntimeIdentifiers>
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<Authors>Tom Pallister</Authors>
</PropertyGroup>
<ItemGroup>