run a local httpbin instance and build the ios projects

This commit is contained in:
miterosan
2019-02-18 15:52:17 +01:00
parent 6d5efe7de9
commit 593009a87e
4 changed files with 77 additions and 10 deletions

View File

@@ -53,7 +53,7 @@ $TOOLS_DIR = Join-Path $BUILD_DIR "tools"
$CAKE_CSPROJ = Join-Path $BUILD_DIR "cakebuild.csproj"
# Install the required tools locally.
Write-Host "Restoring cake tools..."
Write-Host "Restoring cake..."
Invoke-Expression "dotnet restore `"$CAKE_CSPROJ`" --packages `"$TOOLS_DIR`"" | Out-Null
# Find the Cake executable

View File

@@ -1,17 +1,49 @@
#addin "nuget:?package=CodeFileSanity&version=0.0.21"
#addin "nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2018.2.2"
#tool "nuget:?package=NVika.MSBuild&version=1.0.1"
#tool "nuget:?package=Python&version=3.7.2"
var nVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First();
var pythonPath = GetFiles("./tools/python.*/tools/python.exe").First();
var waitressPath = pythonPath.GetDirectory().CombineWithFilePath("Scripts/waitress-serve.exe");
///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
///////////////////////////////////////////////////////////////////////////////
var target = Argument("target", "Build");
var configuration = Argument("configuration", "Release");
var configuration = Argument("configuration", "Debug");
var version = AppVeyor.IsRunningOnAppVeyor ? $"0.0.{AppVeyor.Environment.Build.Number}" : "0.0.0";
var rootDirectory = new DirectoryPath("..");
var toolsDirectory = new DirectoryPath("tools");
var artifactsDirectory = rootDirectory.Combine("artifacts");
var solution = rootDirectory.CombineWithFilePath("osu-framework.sln");
var frameworkProject = rootDirectory.CombineWithFilePath("osu.Framework/osu.Framework.csproj");
var iosFrameworkProject = rootDirectory.CombineWithFilePath("osu.Framework.iOS/osu.Framework.iOS.csproj");
var nativeLibsProject = rootDirectory.CombineWithFilePath("osu.Framework.NativeLibs/osu.Framework.NativeLibs.csproj");
///////////////////////////////////////////////////////////////////////////////
// Setup
///////////////////////////////////////////////////////////////////////////////
IProcess waitressProcess;
Setup(ctx => {
if (IsRunningOnWindows()) {
StartProcess(pythonPath, "-m pip install httpbin waitress");
waitressProcess = StartAndReturnProcess(waitressPath, new ProcessSettings {
Arguments = "--listen=*:80 httpbin:app",
});
Environment.SetEnvironmentVariable("LocalHttpBin", "true");
}
});
Teardown(ctx => {
waitressProcess?.Kill();
});
///////////////////////////////////////////////////////////////////////////////
// TASKS
@@ -28,13 +60,15 @@ Task("Compile")
Task("Test")
.IsDependentOn("Compile")
.Does(() => {
var testAssemblies = GetFiles(rootDirectory + "/**/*.Tests/bin/**/*.Tests.dll");
var testAssemblies = GetFiles(rootDirectory + $"/*.Tests/bin/{configuration}/*/*.Tests.dll");
DotNetCoreVSTest(testAssemblies, new DotNetCoreVSTestSettings {
var settings = new DotNetCoreVSTestSettings {
Logger = AppVeyor.IsRunningOnAppVeyor ? "Appveyor" : "trx",
Parallel = true,
ToolTimeout = TimeSpan.FromMinutes(10),
});
};
DotNetCoreVSTest(testAssemblies, settings);
});
// windows only because both inspectcore and nvika depend on net45
@@ -58,9 +92,41 @@ Task("CodeFileSanity")
});
});
Task("Pack")
.Does(() => {
EnsureDirectoryExists(artifactsDirectory);
CleanDirectory(artifactsDirectory);
var absoluteArtifactsPath = artifactsDirectory.MakeAbsolute(Context.Environment);
var msbuildPackSettings = new MSBuildSettings {
Restore = true,
BinaryLogger = new MSBuildBinaryLogSettings{Enabled = true},
Verbosity = Verbosity.Minimal,
ArgumentCustomization = args =>
{
args.Append($"/p:Configuration={configuration}");
args.Append($"/p:Version={version}");
args.Append($"/p:PackageOutputPath={absoluteArtifactsPath}");
return args;
}
}.WithTarget("Pack");
DotNetCorePack(frameworkProject.FullPath, new DotNetCorePackSettings{
OutputDirectory = artifactsDirectory,
Configuration = configuration,
ArgumentCustomization = args => args.Append($"/p:Version={version}")
});
MSBuild(iosFrameworkProject, msbuildPackSettings);
MSBuild(nativeLibsProject, msbuildPackSettings);
});
Task("Build")
.IsDependentOn("CodeFileSanity")
.IsDependentOn("InspectCode")
.IsDependentOn("Test");
.IsDependentOn("Test")
.IsDependentOn("Pack");
RunTarget(target);;

View File

@@ -5,7 +5,7 @@
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Cake" Version="0.30.0" />
<PackageReference Include="Cake.CoreCLR" Version="0.30.0" />
<PackageReference Include="Cake" Version="0.32.1" />
<PackageReference Include="Cake.CoreCLR" Version="0.32.1" />
</ItemGroup>
</Project>

View File

@@ -17,6 +17,7 @@ using WebRequest = osu.Framework.IO.Network.WebRequest;
namespace osu.Framework.Tests.IO
{
[TestFixture]
[Category("httpbin")]
public class TestWebRequest
{
private const string default_protocol = "http";
@@ -27,9 +28,9 @@ namespace osu.Framework.Tests.IO
static TestWebRequest()
{
bool isAppveyorBuild = Environment.GetEnvironmentVariable("APPVEYOR")?.ToLower().Equals("true") ?? false;
bool localHttpBin = Environment.GetEnvironmentVariable("LocalHttpBin")?.ToLower().Equals("true") ?? false;
if (isAppveyorBuild)
if (localHttpBin)
{
// httpbin very frequently falls over and causes random tests to fail
// Thus appveyor builds rely on a local httpbin instance to run the tests