mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 06:22:50 +08:00
Merge pull request #21 from binarymash/develop
#20 - refactored build pipeline
This commit is contained in:
commit
aef0538ab8
1
.gitignore
vendored
1
.gitignore
vendored
@ -235,3 +235,4 @@ _Pvt_Extensions
|
|||||||
|
|
||||||
# FAKE - F# Make
|
# FAKE - F# Make
|
||||||
.fake/
|
.fake/
|
||||||
|
tools/
|
||||||
|
4
GitVersion.yml
Normal file
4
GitVersion.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
mode: ContinuousDelivery
|
||||||
|
branches: {}
|
||||||
|
ignore:
|
||||||
|
sha: []
|
13
Ocelot.sln
13
Ocelot.sln
@ -9,18 +9,19 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
.gitignore = .gitignore
|
.gitignore = .gitignore
|
||||||
appveyor.yml = appveyor.yml
|
appveyor.yml = appveyor.yml
|
||||||
build-and-run-tests.bat = build-and-run-tests.bat
|
build-and-run-tests.ps1 = build-and-run-tests.ps1
|
||||||
build.bat = build.bat
|
build.cake = build.cake
|
||||||
|
build.ps1 = build.ps1
|
||||||
configuration-explanation.txt = configuration-explanation.txt
|
configuration-explanation.txt = configuration-explanation.txt
|
||||||
global.json = global.json
|
global.json = global.json
|
||||||
LICENSE.md = LICENSE.md
|
LICENSE.md = LICENSE.md
|
||||||
Ocelot.nuspec = Ocelot.nuspec
|
Ocelot.nuspec = Ocelot.nuspec
|
||||||
push-to-nuget.bat = push-to-nuget.bat
|
|
||||||
README.md = README.md
|
README.md = README.md
|
||||||
run-acceptance-tests.bat = run-acceptance-tests.bat
|
release.ps1 = release.ps1
|
||||||
|
run-acceptance-tests.ps1 = run-acceptance-tests.ps1
|
||||||
run-benchmarks.bat = run-benchmarks.bat
|
run-benchmarks.bat = run-benchmarks.bat
|
||||||
run-tests.bat = run-tests.bat
|
run-benchmarks.ps1 = run-benchmarks.ps1
|
||||||
run-unit-tests.bat = run-unit-tests.bat
|
run-unit-tests.ps1 = run-unit-tests.ps1
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Ocelot", "src\Ocelot\Ocelot.xproj", "{D6DF4206-0DBA-41D8-884D-C3E08290FDBB}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Ocelot", "src\Ocelot\Ocelot.xproj", "{D6DF4206-0DBA-41D8-884D-C3E08290FDBB}"
|
||||||
|
1
ReleaseNotes.md
Normal file
1
ReleaseNotes.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
No issues closed since last release
|
1
build-and-release-unstable.ps1
Normal file
1
build-and-release-unstable.ps1
Normal file
@ -0,0 +1 @@
|
|||||||
|
./build.ps1 -target build-full
|
@ -1,2 +0,0 @@
|
|||||||
./run-tests.bat
|
|
||||||
./build.bat
|
|
1
build-and-run-tests.ps1
Normal file
1
build-and-run-tests.ps1
Normal file
@ -0,0 +1 @@
|
|||||||
|
./build.ps1 -target RunTests
|
@ -1,8 +0,0 @@
|
|||||||
echo -------------------------
|
|
||||||
|
|
||||||
echo Building Ocelot
|
|
||||||
dotnet restore src/Ocelot
|
|
||||||
dotnet build src/Ocelot -c Release
|
|
||||||
|
|
||||||
|
|
||||||
|
|
347
build.cake
Normal file
347
build.cake
Normal file
@ -0,0 +1,347 @@
|
|||||||
|
#tool "nuget:?package=GitVersion.CommandLine"
|
||||||
|
#tool "nuget:?package=OpenCover"
|
||||||
|
#tool "nuget:?package=ReportGenerator"
|
||||||
|
#tool "nuget:?package=GitReleaseNotes"
|
||||||
|
#addin "nuget:?package=Cake.DoInDirectory"
|
||||||
|
#addin "nuget:?package=Cake.Json"
|
||||||
|
|
||||||
|
// compile
|
||||||
|
var compileConfig = Argument("configuration", "Release");
|
||||||
|
var projectJson = "./src/Ocelot/project.json";
|
||||||
|
|
||||||
|
// build artifacts
|
||||||
|
var artifactsDir = Directory("artifacts");
|
||||||
|
|
||||||
|
// unit testing
|
||||||
|
var artifactsForUnitTestsDir = artifactsDir + Directory("UnitTests");
|
||||||
|
var unitTestAssemblies = @"./test/Ocelot.UnitTests";
|
||||||
|
|
||||||
|
// acceptance testing
|
||||||
|
var artifactsForAcceptanceTestsDir = artifactsDir + Directory("AcceptanceTests");
|
||||||
|
var acceptanceTestAssemblies = @"./test/Ocelot.AcceptanceTests";
|
||||||
|
|
||||||
|
// benchmark testing
|
||||||
|
var artifactsForBenchmarkTestsDir = artifactsDir + Directory("BenchmarkTests");
|
||||||
|
var benchmarkTestAssemblies = @"./test/Ocelot.Benchmarks";
|
||||||
|
|
||||||
|
// packaging
|
||||||
|
var packagesDir = artifactsDir + Directory("Packages");
|
||||||
|
var releaseNotesFile = packagesDir + File("releasenotes.md");
|
||||||
|
var artifactsFile = packagesDir + File("artifacts.txt");
|
||||||
|
|
||||||
|
// unstable releases
|
||||||
|
var nugetFeedUnstableKey = EnvironmentVariable("nuget-apikey-unstable");
|
||||||
|
var nugetFeedUnstableUploadUrl = "https://www.myget.org/F/ocelot-unstable/api/v2/package";
|
||||||
|
var nugetFeedUnstableSymbolsUploadUrl = "https://www.myget.org/F/ocelot-unstable/symbols/api/v2/package";
|
||||||
|
|
||||||
|
// stable releases
|
||||||
|
var tagsUrl = "https://api.github.com/repos/binarymash/ocelot/releases/tags/";
|
||||||
|
var nugetFeedStableKey = EnvironmentVariable("nuget-apikey-stable");
|
||||||
|
var nugetFeedStableUploadUrl = "https://www.myget.org/F/ocelot-stable/api/v2/package";
|
||||||
|
var nugetFeedStableSymbolsUploadUrl = "https://www.myget.org/F/ocelot-stable/symbols/api/v2/package";
|
||||||
|
|
||||||
|
// internal build variables - don't change these.
|
||||||
|
var releaseTag = "";
|
||||||
|
var buildVersion = committedVersion;
|
||||||
|
var committedVersion = "0.0.0-dev";
|
||||||
|
|
||||||
|
var target = Argument("target", "Default");
|
||||||
|
|
||||||
|
Information("target is " +target);
|
||||||
|
Information("Build configuration is " + compileConfig);
|
||||||
|
|
||||||
|
Task("Default")
|
||||||
|
.IsDependentOn("Build");
|
||||||
|
|
||||||
|
Task("Build")
|
||||||
|
.IsDependentOn("RunTests")
|
||||||
|
.IsDependentOn("CreatePackages");
|
||||||
|
|
||||||
|
Task("BuildAndReleaseUnstable")
|
||||||
|
.IsDependentOn("Build")
|
||||||
|
.IsDependentOn("ReleasePackagesToUnstableFeed");
|
||||||
|
|
||||||
|
Task("Clean")
|
||||||
|
.Does(() =>
|
||||||
|
{
|
||||||
|
if (DirectoryExists(artifactsDir))
|
||||||
|
{
|
||||||
|
DeleteDirectory(artifactsDir, recursive:true);
|
||||||
|
}
|
||||||
|
CreateDirectory(artifactsDir);
|
||||||
|
});
|
||||||
|
|
||||||
|
Task("Version")
|
||||||
|
.Does(() =>
|
||||||
|
{
|
||||||
|
var nugetVersion = GetNuGetVersionForCommit();
|
||||||
|
Information("SemVer version number: " + nugetVersion);
|
||||||
|
|
||||||
|
if (AppVeyor.IsRunningOnAppVeyor)
|
||||||
|
{
|
||||||
|
Information("Persisting version number...");
|
||||||
|
PersistVersion(nugetVersion);
|
||||||
|
buildVersion = nugetVersion;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Information("We are not running on build server, so we won't persist the version number.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Task("Restore")
|
||||||
|
.IsDependentOn("Clean")
|
||||||
|
.IsDependentOn("Version")
|
||||||
|
.Does(() =>
|
||||||
|
{
|
||||||
|
DotNetCoreRestore("./src");
|
||||||
|
DotNetCoreRestore("./test");
|
||||||
|
});
|
||||||
|
|
||||||
|
Task("RunUnitTests")
|
||||||
|
.IsDependentOn("Restore")
|
||||||
|
.Does(() =>
|
||||||
|
{
|
||||||
|
var buildSettings = new DotNetCoreTestSettings
|
||||||
|
{
|
||||||
|
Configuration = compileConfig,
|
||||||
|
};
|
||||||
|
|
||||||
|
EnsureDirectoryExists(artifactsForUnitTestsDir);
|
||||||
|
DotNetCoreTest(unitTestAssemblies, buildSettings);
|
||||||
|
});
|
||||||
|
|
||||||
|
Task("RunAcceptanceTests")
|
||||||
|
.IsDependentOn("Restore")
|
||||||
|
.Does(() =>
|
||||||
|
{
|
||||||
|
var buildSettings = new DotNetCoreTestSettings
|
||||||
|
{
|
||||||
|
Configuration = "Debug", //acceptance test config is hard-coded for debug
|
||||||
|
};
|
||||||
|
|
||||||
|
EnsureDirectoryExists(artifactsForAcceptanceTestsDir);
|
||||||
|
|
||||||
|
DoInDirectory("test/Ocelot.AcceptanceTests", () =>
|
||||||
|
{
|
||||||
|
DotNetCoreTest(".", buildSettings);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
Task("RunBenchmarkTests")
|
||||||
|
.IsDependentOn("Restore")
|
||||||
|
.Does(() =>
|
||||||
|
{
|
||||||
|
var buildSettings = new DotNetCoreRunSettings
|
||||||
|
{
|
||||||
|
Configuration = compileConfig,
|
||||||
|
};
|
||||||
|
|
||||||
|
EnsureDirectoryExists(artifactsForBenchmarkTestsDir);
|
||||||
|
|
||||||
|
DoInDirectory(benchmarkTestAssemblies, () =>
|
||||||
|
{
|
||||||
|
DotNetCoreRun(".", "", buildSettings);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
Task("RunTests")
|
||||||
|
.IsDependentOn("RunUnitTests")
|
||||||
|
.IsDependentOn("RunAcceptanceTests")
|
||||||
|
.Does(() =>
|
||||||
|
{
|
||||||
|
});
|
||||||
|
|
||||||
|
Task("CreatePackages")
|
||||||
|
.Does(() =>
|
||||||
|
{
|
||||||
|
EnsureDirectoryExists(packagesDir);
|
||||||
|
|
||||||
|
GenerateReleaseNotes();
|
||||||
|
|
||||||
|
var settings = new DotNetCorePackSettings
|
||||||
|
{
|
||||||
|
OutputDirectory = packagesDir,
|
||||||
|
NoBuild = true
|
||||||
|
};
|
||||||
|
|
||||||
|
DotNetCorePack(projectJson, settings);
|
||||||
|
|
||||||
|
System.IO.File.WriteAllLines(artifactsFile, new[]{
|
||||||
|
"nuget:Ocelot." + buildVersion + ".nupkg",
|
||||||
|
"nugetSymbols:Ocelot." + buildVersion + ".symbols.nupkg",
|
||||||
|
"releaseNotes:releasenotes.md"
|
||||||
|
});
|
||||||
|
|
||||||
|
if (AppVeyor.IsRunningOnAppVeyor)
|
||||||
|
{
|
||||||
|
var path = packagesDir.ToString() + @"/**/*";
|
||||||
|
|
||||||
|
foreach (var file in GetFiles(path))
|
||||||
|
{
|
||||||
|
AppVeyor.UploadArtifact(file.FullPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Task("ReleasePackagesToUnstableFeed")
|
||||||
|
.IsDependentOn("CreatePackages")
|
||||||
|
.Does(() =>
|
||||||
|
{
|
||||||
|
PublishPackages(nugetFeedUnstableKey, nugetFeedUnstableUploadUrl, nugetFeedUnstableSymbolsUploadUrl);
|
||||||
|
});
|
||||||
|
|
||||||
|
Task("EnsureStableReleaseRequirements")
|
||||||
|
.Does(() =>
|
||||||
|
{
|
||||||
|
if (!AppVeyor.IsRunningOnAppVeyor)
|
||||||
|
{
|
||||||
|
throw new Exception("Stable release should happen via appveyor");
|
||||||
|
}
|
||||||
|
|
||||||
|
var isTag =
|
||||||
|
AppVeyor.Environment.Repository.Tag.IsTag &&
|
||||||
|
!string.IsNullOrWhiteSpace(AppVeyor.Environment.Repository.Tag.Name);
|
||||||
|
|
||||||
|
if (!isTag)
|
||||||
|
{
|
||||||
|
throw new Exception("Stable release should happen from a published GitHub release");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Task("UpdateVersionInfo")
|
||||||
|
.IsDependentOn("EnsureStableReleaseRequirements")
|
||||||
|
.Does(() =>
|
||||||
|
{
|
||||||
|
releaseTag = AppVeyor.Environment.Repository.Tag.Name;
|
||||||
|
AppVeyor.UpdateBuildVersion(releaseTag);
|
||||||
|
});
|
||||||
|
|
||||||
|
Task("DownloadGitHubReleaseArtifacts")
|
||||||
|
.IsDependentOn("UpdateVersionInfo")
|
||||||
|
.Does(() =>
|
||||||
|
{
|
||||||
|
EnsureDirectoryExists(packagesDir);
|
||||||
|
|
||||||
|
var releaseUrl = tagsUrl + releaseTag;
|
||||||
|
var assets_url = ParseJson(GetResource(releaseUrl))
|
||||||
|
.GetValue("assets_url")
|
||||||
|
.Value<string>();
|
||||||
|
|
||||||
|
foreach(var asset in DeserializeJson<JArray>(GetResource(assets_url)))
|
||||||
|
{
|
||||||
|
var file = packagesDir + File(asset.Value<string>("name"));
|
||||||
|
Information("Downloading " + file);
|
||||||
|
DownloadFile(asset.Value<string>("browser_download_url"), file);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Task("ReleasePackagesToStableFeed")
|
||||||
|
.IsDependentOn("DownloadGitHubReleaseArtifacts")
|
||||||
|
.Does(() =>
|
||||||
|
{
|
||||||
|
PublishPackages(nugetFeedStableKey, nugetFeedStableUploadUrl, nugetFeedStableSymbolsUploadUrl);
|
||||||
|
});
|
||||||
|
|
||||||
|
Task("Release")
|
||||||
|
.IsDependentOn("ReleasePackagesToStableFeed");
|
||||||
|
|
||||||
|
RunTarget(target);
|
||||||
|
|
||||||
|
/// Gets nuique nuget version for this commit
|
||||||
|
private string GetNuGetVersionForCommit()
|
||||||
|
{
|
||||||
|
GitVersion(new GitVersionSettings{
|
||||||
|
UpdateAssemblyInfo = false,
|
||||||
|
OutputType = GitVersionOutput.BuildServer
|
||||||
|
});
|
||||||
|
|
||||||
|
var versionInfo = GitVersion(new GitVersionSettings{ OutputType = GitVersionOutput.Json });
|
||||||
|
return versionInfo.NuGetVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Updates project version in all of our projects
|
||||||
|
private void PersistVersion(string version)
|
||||||
|
{
|
||||||
|
Information(string.Format("We'll search all project.json files for {0} and replace with {1}...", committedVersion, version));
|
||||||
|
|
||||||
|
var projectJsonFiles = GetFiles("./**/project.json");
|
||||||
|
|
||||||
|
foreach(var projectJsonFile in projectJsonFiles)
|
||||||
|
{
|
||||||
|
var file = projectJsonFile.ToString();
|
||||||
|
|
||||||
|
Information(string.Format("Updating {0}...", file));
|
||||||
|
|
||||||
|
var updatedProjectJson = System.IO.File.ReadAllText(file)
|
||||||
|
.Replace(committedVersion, version);
|
||||||
|
|
||||||
|
System.IO.File.WriteAllText(file, updatedProjectJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// generates release notes based on issues closed in GitHub since the last release
|
||||||
|
private void GenerateReleaseNotes()
|
||||||
|
{
|
||||||
|
Information("Generating release notes at " + releaseNotesFile);
|
||||||
|
|
||||||
|
var releaseNotesExitCode = StartProcess(
|
||||||
|
@"tools/GitReleaseNotes/tools/gitreleasenotes.exe",
|
||||||
|
new ProcessSettings { Arguments = ". /o " + releaseNotesFile });
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(System.IO.File.ReadAllText(releaseNotesFile)))
|
||||||
|
{
|
||||||
|
System.IO.File.WriteAllText(releaseNotesFile, "No issues closed since last release");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (releaseNotesExitCode != 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Failed to generate release notes");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Publishes code and symbols packages to nuget feed, based on contents of artifacts file
|
||||||
|
private void PublishPackages(string feedApiKey, string codeFeedUrl, string symbolFeedUrl)
|
||||||
|
{
|
||||||
|
var artifacts = System.IO.File
|
||||||
|
.ReadAllLines(artifactsFile)
|
||||||
|
.Select(l => l.Split(':'))
|
||||||
|
.ToDictionary(v => v[0], v => v[1]);
|
||||||
|
|
||||||
|
var codePackage = packagesDir + File(artifacts["nuget"]);
|
||||||
|
var symbolsPackage = packagesDir + File(artifacts["nugetSymbols"]);
|
||||||
|
|
||||||
|
NuGetPush(
|
||||||
|
codePackage,
|
||||||
|
new NuGetPushSettings {
|
||||||
|
ApiKey = feedApiKey,
|
||||||
|
Source = codeFeedUrl
|
||||||
|
});
|
||||||
|
|
||||||
|
NuGetPush(
|
||||||
|
symbolsPackage,
|
||||||
|
new NuGetPushSettings {
|
||||||
|
ApiKey = feedApiKey,
|
||||||
|
Source = symbolFeedUrl
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// gets the resource from the specified url
|
||||||
|
private string GetResource(string url)
|
||||||
|
{
|
||||||
|
Information("Getting resource from " + url);
|
||||||
|
|
||||||
|
var assetsRequest = System.Net.WebRequest.CreateHttp(url);
|
||||||
|
assetsRequest.Method = "GET";
|
||||||
|
assetsRequest.Accept = "application/vnd.github.v3+json";
|
||||||
|
assetsRequest.UserAgent = "BuildScript";
|
||||||
|
|
||||||
|
using (var assetsResponse = assetsRequest.GetResponse())
|
||||||
|
{
|
||||||
|
var assetsStream = assetsResponse.GetResponseStream();
|
||||||
|
var assetsReader = new StreamReader(assetsStream);
|
||||||
|
return assetsReader.ReadToEnd();
|
||||||
|
}
|
||||||
|
}
|
189
build.ps1
Normal file
189
build.ps1
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
##########################################################################
|
||||||
|
# This is the Cake bootstrapper script for PowerShell.
|
||||||
|
# This file was downloaded from https://github.com/cake-build/resources
|
||||||
|
# Feel free to change this file to fit your needs.
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
<#
|
||||||
|
|
||||||
|
.SYNOPSIS
|
||||||
|
This is a Powershell script to bootstrap a Cake build.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
This Powershell script will download NuGet if missing, restore NuGet tools (including Cake)
|
||||||
|
and execute your Cake build script with the parameters you provide.
|
||||||
|
|
||||||
|
.PARAMETER Script
|
||||||
|
The build script to execute.
|
||||||
|
.PARAMETER Target
|
||||||
|
The build script target to run.
|
||||||
|
.PARAMETER Configuration
|
||||||
|
The build configuration to use.
|
||||||
|
.PARAMETER Verbosity
|
||||||
|
Specifies the amount of information to be displayed.
|
||||||
|
.PARAMETER Experimental
|
||||||
|
Tells Cake to use the latest Roslyn release.
|
||||||
|
.PARAMETER WhatIf
|
||||||
|
Performs a dry run of the build script.
|
||||||
|
No tasks will be executed.
|
||||||
|
.PARAMETER Mono
|
||||||
|
Tells Cake to use the Mono scripting engine.
|
||||||
|
.PARAMETER SkipToolPackageRestore
|
||||||
|
Skips restoring of packages.
|
||||||
|
.PARAMETER ScriptArgs
|
||||||
|
Remaining arguments are added here.
|
||||||
|
|
||||||
|
.LINK
|
||||||
|
http://cakebuild.net
|
||||||
|
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param(
|
||||||
|
[string]$Script = "build.cake",
|
||||||
|
[string]$Target = "Default",
|
||||||
|
[ValidateSet("Release", "Debug")]
|
||||||
|
[string]$Configuration = "Release",
|
||||||
|
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
|
||||||
|
[string]$Verbosity = "Verbose",
|
||||||
|
[switch]$Experimental,
|
||||||
|
[Alias("DryRun","Noop")]
|
||||||
|
[switch]$WhatIf,
|
||||||
|
[switch]$Mono,
|
||||||
|
[switch]$SkipToolPackageRestore,
|
||||||
|
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
|
||||||
|
[string[]]$ScriptArgs
|
||||||
|
)
|
||||||
|
|
||||||
|
[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
|
||||||
|
function MD5HashFile([string] $filePath)
|
||||||
|
{
|
||||||
|
if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf))
|
||||||
|
{
|
||||||
|
return $null
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.IO.Stream] $file = $null;
|
||||||
|
[System.Security.Cryptography.MD5] $md5 = $null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$md5 = [System.Security.Cryptography.MD5]::Create()
|
||||||
|
$file = [System.IO.File]::OpenRead($filePath)
|
||||||
|
return [System.BitConverter]::ToString($md5.ComputeHash($file))
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if ($file -ne $null)
|
||||||
|
{
|
||||||
|
$file.Dispose()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Preparing to run build script..."
|
||||||
|
|
||||||
|
if(!$PSScriptRoot){
|
||||||
|
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
|
||||||
|
}
|
||||||
|
|
||||||
|
$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
|
||||||
|
$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe"
|
||||||
|
$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe"
|
||||||
|
$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
|
||||||
|
$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config"
|
||||||
|
$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum"
|
||||||
|
|
||||||
|
# Should we use mono?
|
||||||
|
$UseMono = "";
|
||||||
|
if($Mono.IsPresent) {
|
||||||
|
Write-Verbose -Message "Using the Mono based scripting engine."
|
||||||
|
$UseMono = "-mono"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Should we use the new Roslyn?
|
||||||
|
$UseExperimental = "";
|
||||||
|
if($Experimental.IsPresent -and !($Mono.IsPresent)) {
|
||||||
|
Write-Verbose -Message "Using experimental version of Roslyn."
|
||||||
|
$UseExperimental = "-experimental"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Is this a dry run?
|
||||||
|
$UseDryRun = "";
|
||||||
|
if($WhatIf.IsPresent) {
|
||||||
|
$UseDryRun = "-dryrun"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Make sure tools folder exists
|
||||||
|
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
|
||||||
|
Write-Verbose -Message "Creating tools directory..."
|
||||||
|
New-Item -Path $TOOLS_DIR -Type directory | out-null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Make sure that packages.config exist.
|
||||||
|
if (!(Test-Path $PACKAGES_CONFIG)) {
|
||||||
|
Write-Verbose -Message "Downloading packages.config..."
|
||||||
|
try { (New-Object System.Net.WebClient).DownloadFile("http://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch {
|
||||||
|
Throw "Could not download packages.config."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Try find NuGet.exe in path if not exists
|
||||||
|
if (!(Test-Path $NUGET_EXE)) {
|
||||||
|
Write-Verbose -Message "Trying to find nuget.exe in PATH..."
|
||||||
|
$existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_) }
|
||||||
|
$NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1
|
||||||
|
if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) {
|
||||||
|
Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)."
|
||||||
|
$NUGET_EXE = $NUGET_EXE_IN_PATH.FullName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Try download NuGet.exe if not exists
|
||||||
|
if (!(Test-Path $NUGET_EXE)) {
|
||||||
|
Write-Verbose -Message "Downloading NuGet.exe..."
|
||||||
|
try {
|
||||||
|
(New-Object System.Net.WebClient).DownloadFile($NUGET_URL, $NUGET_EXE)
|
||||||
|
} catch {
|
||||||
|
Throw "Could not download NuGet.exe."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Save nuget.exe path to environment to be available to child processed
|
||||||
|
$ENV:NUGET_EXE = $NUGET_EXE
|
||||||
|
|
||||||
|
# Restore tools from NuGet?
|
||||||
|
if(-Not $SkipToolPackageRestore.IsPresent) {
|
||||||
|
Push-Location
|
||||||
|
Set-Location $TOOLS_DIR
|
||||||
|
|
||||||
|
# Check for changes in packages.config and remove installed tools if true.
|
||||||
|
[string] $md5Hash = MD5HashFile($PACKAGES_CONFIG)
|
||||||
|
if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
|
||||||
|
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
|
||||||
|
Write-Verbose -Message "Missing or changed package.config hash..."
|
||||||
|
Remove-Item * -Recurse -Exclude packages.config,nuget.exe
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Verbose -Message "Restoring tools from NuGet..."
|
||||||
|
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
|
||||||
|
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
Throw "An error occured while restoring NuGet tools."
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
|
||||||
|
}
|
||||||
|
Write-Verbose -Message ($NuGetOutput | out-string)
|
||||||
|
Pop-Location
|
||||||
|
}
|
||||||
|
|
||||||
|
# Make sure that Cake has been installed.
|
||||||
|
if (!(Test-Path $CAKE_EXE)) {
|
||||||
|
Throw "Could not find Cake.exe at $CAKE_EXE"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Start Cake
|
||||||
|
Write-Host "Running build script..."
|
||||||
|
Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs"
|
||||||
|
exit $LASTEXITCODE
|
22
build.readme.md
Normal file
22
build.readme.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#1. Overview
|
||||||
|
|
||||||
|
This document summarises the build and release process for the project. The build scripts are written using [Cake](http://cakebuild.net/), and are defined in `./build.cake`. The scripts have been designed to be run by either developers locally or by a build server (currently [AppVeyor](https://www.appveyor.com/)), with minimal logic defined in the build server itself.
|
||||||
|
|
||||||
|
#2. Building
|
||||||
|
* You'll generally want to run the `./build.ps1` script. This will compile, run unit and acceptance tests and build the output packages locally. Output will got to the `./artifacts` directory.
|
||||||
|
* You can view the current commit's [SemVer](http://semver.org/) build information by running `./version.ps1`.
|
||||||
|
* The other `./*.ps1` scripts perform subsets of the build process, if you don't want to run the full build.
|
||||||
|
* The release process works best with GitFlow branching; this allows us to publish every development commit to an unstable feed with a unique SemVer version, and then choose when to release to a stable feed.
|
||||||
|
|
||||||
|
#3. Release process
|
||||||
|
This section defines the release process for the maintainers of the project.
|
||||||
|
* Merge pull requests to the `release` branch.
|
||||||
|
* Every commit pushed to the Origin repo will kick off the [ocelot-build](https://ci.appveyor.com/project/binarymash/ocelot) project in AppVeyor. This performs the same tasks as the command line build, and in addition pushes the packages to the unstable nuget feed.
|
||||||
|
* When you're ready for a release, create a release branch. You'll probably want to update the committed `./ReleaseNotes.md` based on the contents of the equivalent file in the `./artifacts` directory.
|
||||||
|
* When the `release` branch has built successfully in Appveyor, select the build and then Deploy to the `GitHub Release` environment. This will create a new release in GitHub.
|
||||||
|
* In Github, navigate to the [release](https://github.com/binarymash/Ocelot/releases). Modify the release name and tag as desired.
|
||||||
|
* When you're ready, publish the release. This will tag the commit with the specified release number.
|
||||||
|
* The [ocelot-release](https://ci.appveyor.com/project/binarymash/ocelot-wtaj9) project will detect the newly created tag and kick off the release process. This will download the artifacts from GitHub, and publish the packages to the stable nuget feed.
|
||||||
|
* When you have a final stable release build, merge the `release` branch into `master` and `develop`. Deploy the master branch to github and following the full release process as described above. Don't forget to uncheck the "This is a pre-release" checkbox in GitHub before publishing.
|
||||||
|
* Note - because the release builds are initiated by tagging a commit, if for some reason a release build fails in AppVeyor you'll need to delete the tag from the repo and republish the release in GitHub.
|
||||||
|
|
1
release.ps1
Normal file
1
release.ps1
Normal file
@ -0,0 +1 @@
|
|||||||
|
./build.ps1 -target Release
|
@ -1,8 +0,0 @@
|
|||||||
echo Running Ocelot.AcceptanceTests
|
|
||||||
cd test/Ocelot.AcceptanceTests/
|
|
||||||
dotnet restore
|
|
||||||
dotnet test
|
|
||||||
cd ../../
|
|
||||||
|
|
||||||
echo Restoring Ocelot.ManualTest
|
|
||||||
dotnet restore test/Ocelot.ManualTest/
|
|
1
run-acceptance-tests.ps1
Normal file
1
run-acceptance-tests.ps1
Normal file
@ -0,0 +1 @@
|
|||||||
|
./build -target RunAcceptanceTests
|
@ -1,15 +0,0 @@
|
|||||||
echo -------------------------
|
|
||||||
|
|
||||||
echo Running Ocelot.Benchmarks
|
|
||||||
|
|
||||||
cd test/Ocelot.Benchmarks
|
|
||||||
|
|
||||||
dotnet restore
|
|
||||||
|
|
||||||
dotnet run
|
|
||||||
|
|
||||||
cd ../../
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
1
run-benchmarks.ps1
Normal file
1
run-benchmarks.ps1
Normal file
@ -0,0 +1 @@
|
|||||||
|
./build.ps1 -target RunBenchmarkTests
|
@ -1,2 +0,0 @@
|
|||||||
./run-unit-tests.bat
|
|
||||||
./run-acceptance-tests.bat
|
|
@ -1,8 +0,0 @@
|
|||||||
echo -------------------------
|
|
||||||
|
|
||||||
echo Restoring Ocelot
|
|
||||||
dotnet restore src/Ocelot
|
|
||||||
|
|
||||||
echo Running Ocelot.UnitTests
|
|
||||||
dotnet restore test/Ocelot.UnitTests/
|
|
||||||
dotnet test test/Ocelot.UnitTests/
|
|
1
run-unit-tests.ps1
Normal file
1
run-unit-tests.ps1
Normal file
@ -0,0 +1 @@
|
|||||||
|
./build.ps1 -target RunUnitTests
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.0.0-*",
|
"version": "0.0.0-dev",
|
||||||
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
|
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.0.0-*",
|
"version": "0.0.0-dev",
|
||||||
|
|
||||||
"buildOptions": {
|
"buildOptions": {
|
||||||
"copyToOutput": {
|
"copyToOutput": {
|
||||||
@ -22,10 +22,10 @@
|
|||||||
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
|
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
|
||||||
"Microsoft.AspNetCore.Http": "1.1.0",
|
"Microsoft.AspNetCore.Http": "1.1.0",
|
||||||
"Microsoft.DotNet.InternalAbstractions": "1.0.0",
|
"Microsoft.DotNet.InternalAbstractions": "1.0.0",
|
||||||
"Ocelot": "1.0.0-*",
|
"Ocelot": "0.0.0-dev",
|
||||||
"xunit": "2.2.0-beta2-build3300",
|
"xunit": "2.2.0-beta2-build3300",
|
||||||
"dotnet-test-xunit": "2.2.0-preview2-build1029",
|
"dotnet-test-xunit": "2.2.0-preview2-build1029",
|
||||||
"Ocelot.ManualTest": "1.0.0-*",
|
"Ocelot.ManualTest": "0.0.0-dev",
|
||||||
"Microsoft.AspNetCore.TestHost": "1.1.0",
|
"Microsoft.AspNetCore.TestHost": "1.1.0",
|
||||||
"IdentityServer4": "1.0.1",
|
"IdentityServer4": "1.0.1",
|
||||||
"Microsoft.AspNetCore.Mvc": "1.1.0",
|
"Microsoft.AspNetCore.Mvc": "1.1.0",
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"version": "1.0.0-*",
|
"version": "0.0.0-dev",
|
||||||
"buildOptions": {
|
"buildOptions": {
|
||||||
"emitEntryPoint": true
|
"emitEntryPoint": true
|
||||||
},
|
},
|
||||||
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Ocelot": "1.0.0-*",
|
"Ocelot": "0.0.0-dev",
|
||||||
"BenchmarkDotNet": "0.10.1"
|
"BenchmarkDotNet": "0.10.1"
|
||||||
},
|
},
|
||||||
"runtimes": {
|
"runtimes": {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.0.0-*",
|
"version": "0.0.0-dev",
|
||||||
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.AspNetCore.Http": "1.1.0",
|
"Microsoft.AspNetCore.Http": "1.1.0",
|
||||||
@ -10,7 +10,7 @@
|
|||||||
"Microsoft.Extensions.Logging.Console": "1.1.0",
|
"Microsoft.Extensions.Logging.Console": "1.1.0",
|
||||||
"Microsoft.Extensions.Logging.Debug": "1.1.0",
|
"Microsoft.Extensions.Logging.Debug": "1.1.0",
|
||||||
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
|
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
|
||||||
"Ocelot": "1.0.0-*",
|
"Ocelot": "0.0.0-dev",
|
||||||
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
|
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
|
||||||
"Microsoft.NETCore.App": "1.1.0"
|
"Microsoft.NETCore.App": "1.1.0"
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.0.0-*",
|
"version": "0.0.0-dev",
|
||||||
|
|
||||||
"testRunner": "xunit",
|
"testRunner": "xunit",
|
||||||
|
|
||||||
@ -13,7 +13,7 @@
|
|||||||
"Microsoft.Extensions.Logging.Debug": "1.1.0",
|
"Microsoft.Extensions.Logging.Debug": "1.1.0",
|
||||||
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
|
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
|
||||||
"Microsoft.AspNetCore.Http": "1.1.0",
|
"Microsoft.AspNetCore.Http": "1.1.0",
|
||||||
"Ocelot": "1.0.0-*",
|
"Ocelot": "0.0.0-dev",
|
||||||
"xunit": "2.2.0-beta2-build3300",
|
"xunit": "2.2.0-beta2-build3300",
|
||||||
"dotnet-test-xunit": "2.2.0-preview2-build1029",
|
"dotnet-test-xunit": "2.2.0-preview2-build1029",
|
||||||
"Moq": "4.6.38-alpha",
|
"Moq": "4.6.38-alpha",
|
||||||
|
1
version.ps1
Normal file
1
version.ps1
Normal file
@ -0,0 +1 @@
|
|||||||
|
.\tools\GitVersion.CommandLine\tools\GitVersion.exe
|
Loading…
x
Reference in New Issue
Block a user