Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.

Commit 3ef46ca

Browse files
committed
Merge branch 'develop'
* develop: (46 commits) Add NoOpRavenClient, an empty (no-op) empty implementation of IRavenClient. Updated `NuGetOrgApiKey` formatting formatting Fix nuget packages build to include metadata. Added MetaData to use new csproj format Run PowerShell directly and validate api key better Reintroduce acceptance criteria since secrets are unavailable in pull requests anyway Always accept criteria to test nuget push before merging Set the source Simplifications and clarifications Use NuGetPush instead of PublishNuGets Let's try NuGet.Push instead Another take on the .nupkg file glob Ensure the artifacts directory exists in the Package task Ensure the artifacts directory exists in UploadArtifacts Added NuGet.Core addin and removed ExtendedNuGetAliases prefix Explicit ToString() Prefix with ExtendedNuGetAliases. Use File() for glob pattern so it can be combined with ConvertableDirectoryPath Added Cake.ExtendedNuGet addin ...
2 parents 305a19b + a042b2d commit 3ef46ca

44 files changed

Lines changed: 1207 additions & 1476 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,10 @@ obj/
1414
/TestResult.xml
1515
docs/_build
1616
.vs
17+
artifacts/
18+
build/
19+
tools/
20+
!tools/packages.config
21+
!tools/NuGet.config
22+
.vscode
23+
.idea

.travis.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
language: csharp
2+
mono:
3+
- weekly
4+
25
solution: src/SharpRaven.sln
6+
37
sudo: false
4-
install:
5-
- make
8+
dotnet: 2.0.0
9+
dist: trusty
10+
611
script:
7-
- make test
12+
- ./build.sh --verbosity diagnostic --target Travis

Makefile

Lines changed: 0 additions & 12 deletions
This file was deleted.

appveyor.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
environment:
2+
NuGetOrgApiKey:
3+
secure: pAgSjPrAcwxzQMP32ya83+Hy+g3uS2J5ubnjv49d9urupYC5xJLVqcPOpnJ4ChYn
4+
version: 1.0.{build}
5+
image: Visual Studio 2017
6+
build_script:
7+
- ps: .\build.ps1 -Target AppVeyor -Verbosity Diagnostic
8+
test: off

build.cake

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
#tool "nuget:?package=NUnit.Runners&version=2.6.4"
2+
#tool "nuget:?package=GitVersion.CommandLine"
3+
4+
//////////////////////////////////////////////////////////////////////
5+
// ARGUMENTS
6+
//////////////////////////////////////////////////////////////////////
7+
8+
var target = Argument("target", "Default");
9+
var configuration = Argument("configuration", "Debug");
10+
var nugetOrgApiKey = EnvironmentVariable("NuGetOrgApiKey");
11+
12+
var isAppveyor = BuildSystem.IsRunningOnAppVeyor;
13+
var isTravis = BuildSystem.IsRunningOnTravisCI;
14+
15+
//////////////////////////////////////////////////////////////////////
16+
// VERSION
17+
//////////////////////////////////////////////////////////////////////
18+
19+
var gitVersion = isTravis ? null : GitVersion(new GitVersionSettings
20+
{
21+
OutputType = GitVersionOutput.Json,
22+
UpdateAssemblyInfo = false
23+
});
24+
25+
var version = isTravis ? "0.0.1" : gitVersion.NuGetVersion;
26+
27+
//////////////////////////////////////////////////////////////////////
28+
// CONSTS
29+
//////////////////////////////////////////////////////////////////////
30+
31+
var artifactsDir = Directory("./artifacts");
32+
var outputDir = Directory("./build");
33+
34+
var dotnetFrameworks = IsRunningOnWindows() ? new [] { "net45", "net40", "netstandard2.0" } : new string[] { };
35+
// net35 can't be build by dotnet - https://github.com/Microsoft/msbuild/issues/1333
36+
var msBuildFrameworks = IsRunningOnWindows() ? new [] { "net35" } : new [] { "net45", "net40", "net35", "netstandard2.0" };
37+
38+
var frameworks = dotnetFrameworks.Union(msBuildFrameworks).ToList();
39+
40+
var solution = "src/SharpRaven.sln";
41+
var packages = new []
42+
{
43+
"src/app/SharpRaven/SharpRaven.csproj",
44+
"src/app/SharpRaven.Nancy/SharpRaven.Nancy.csproj",
45+
};
46+
47+
//////////////////////////////////////////////////////////////////////
48+
// SETUP
49+
//////////////////////////////////////////////////////////////////////
50+
51+
Setup(context =>
52+
{
53+
if (isAppveyor)
54+
{
55+
AppVeyor.UpdateBuildVersion(gitVersion.FullBuildMetaData);
56+
}
57+
58+
Information("Building version {0} of RavenSharp.", version);
59+
});
60+
61+
//////////////////////////////////////////////////////////////////////
62+
// TASKS
63+
//////////////////////////////////////////////////////////////////////
64+
65+
Task("Clean")
66+
.Description("Deletes all files in the artifact and output directories")
67+
.Does(() =>
68+
{
69+
CleanDirectory(artifactsDir);
70+
CleanDirectory(outputDir);
71+
});
72+
73+
Task("RestorePackages")
74+
.Description("Restores packages from nuget using 'dotnet'")
75+
.Does(() =>
76+
{
77+
DotNetCoreRestore(solution);
78+
});
79+
80+
Task("UpdateAssemblyInformation")
81+
.Description("Update assembly information using GitVersion")
82+
.Does(() =>
83+
{
84+
if (!isAppveyor)
85+
{
86+
return;
87+
}
88+
89+
GitVersion(new GitVersionSettings
90+
{
91+
UpdateAssemblyInfo = true,
92+
UpdateAssemblyInfoFilePath = "src/CommonAssemblyInfo.cs",
93+
});
94+
95+
Information("AssemblyVersion -> {0}", gitVersion.AssemblySemVer);
96+
Information("AssemblyFileVersion -> {0}.0", gitVersion.MajorMinorPatch);
97+
Information("AssemblyInformationalVersion -> {0}", gitVersion.InformationalVersion);
98+
});
99+
100+
Task("Build")
101+
.Description("Builds all versions")
102+
.IsDependentOn("RestorePackages")
103+
.IsDependentOn("UpdateAssemblyInformation")
104+
.Does(() =>
105+
{
106+
EnsureDirectoryExists(outputDir);
107+
108+
foreach (var framework in msBuildFrameworks)
109+
{
110+
var settings = new MSBuildSettings
111+
{
112+
Configuration = configuration + "-" + framework,
113+
ToolVersion = MSBuildToolVersion.VS2017,
114+
};
115+
settings.WithProperty("TargetFramework", new string[] { framework });
116+
117+
MSBuild(solution, settings);
118+
}
119+
120+
foreach (var framework in dotnetFrameworks)
121+
{
122+
DotNetCoreBuild(solution, new DotNetCoreBuildSettings
123+
{
124+
Framework = framework,
125+
Configuration = configuration + "-" + framework,
126+
});
127+
}
128+
});
129+
130+
Task("Test")
131+
.Description("Runs all the tests on all the versions")
132+
.IsDependentOn("Build")
133+
.Does(() =>
134+
{
135+
EnsureDirectoryExists(artifactsDir);
136+
137+
foreach (var framework in frameworks.Where(x => x != "netstandard2.0"))
138+
{
139+
var assemblies = GetFiles((outputDir + Directory(configuration) + Directory(framework)).ToString() + "/*.UnitTests.dll");
140+
if (!assemblies.Any())
141+
{
142+
throw new FileNotFoundException("Could not find any test assemblies in: '" + configuration + "-" + framework + "'.");
143+
}
144+
145+
var resultPath = artifactsDir + File(configuration + "-" + framework + "-tests.xml");
146+
NUnit(assemblies, new NUnitSettings
147+
{
148+
ResultsFile = resultPath,
149+
Exclude = IsRunningOnWindows() ? null : "NuGet,NoMono",
150+
});
151+
152+
if (isAppveyor)
153+
{
154+
AppVeyor.UploadTestResults(resultPath, AppVeyorTestResultsType.NUnit);
155+
}
156+
}
157+
});
158+
159+
Task("Package")
160+
.Description("Create NuGet packages")
161+
.IsDependentOn("Build")
162+
.Does(() =>
163+
{
164+
EnsureDirectoryExists(artifactsDir);
165+
166+
foreach (var package in packages)
167+
{
168+
MSBuild(package, c => c
169+
.SetConfiguration("Release")
170+
.SetVerbosity(Verbosity.Minimal)
171+
.UseToolVersion(MSBuildToolVersion.VS2017)
172+
.WithProperty("NoBuild", "true")
173+
.WithProperty("Version", gitVersion.NuGetVersion)
174+
.WithTarget("Pack"));
175+
}
176+
177+
MoveFiles((outputDir + Directory(configuration)).ToString() + "/*.nupkg", artifactsDir);
178+
});
179+
180+
Task("UploadAppVeyorArtifacts")
181+
.Description("Uploads artifacts to AppVeyor")
182+
.IsDependentOn("Package")
183+
.Does(() =>
184+
{
185+
foreach (var zip in System.IO.Directory.GetFiles(artifactsDir, "*.nupkg"))
186+
{
187+
AppVeyor.UploadArtifact(zip);
188+
}
189+
});
190+
191+
Task("PublishNuGetPackages")
192+
.Description("Publishes .nupkg files to nuget.org")
193+
.IsDependentOn("Package")
194+
.WithCriteria(() =>
195+
{
196+
var branchName = gitVersion.BranchName.Trim();
197+
return branchName == "master" || branchName == "develop";
198+
})
199+
.Does(() =>
200+
{
201+
if (String.IsNullOrEmpty(nugetOrgApiKey))
202+
{
203+
throw new ArgumentNullException("nugetOrgApiKey");
204+
}
205+
206+
var nugetFiles = GetFiles(artifactsDir.ToString() + "/*.nupkg");
207+
NuGetPush(nugetFiles, new NuGetPushSettings
208+
{
209+
ApiKey = nugetOrgApiKey,
210+
Source = "https://api.nuget.org/v3/index.json"
211+
});
212+
});
213+
214+
//////////////////////////////////////////////////////////////////////
215+
// META TASKS
216+
//////////////////////////////////////////////////////////////////////
217+
218+
Task("Rebuild")
219+
.Description("Rebuilds all versions")
220+
.IsDependentOn("Clean")
221+
.IsDependentOn("Build");
222+
223+
Task("Appveyor")
224+
.Description("Builds, tests and publishes packages on AppVeyor")
225+
.IsDependentOn("UploadAppVeyorArtifacts")
226+
.IsDependentOn("PublishNuGetPackages");
227+
228+
Task("Travis")
229+
.Description("Builds and tests on Travis")
230+
.IsDependentOn("Test");
231+
232+
Task("Default")
233+
.Description("Builds all versions")
234+
.IsDependentOn("Build");
235+
236+
//////////////////////////////////////////////////////////////////////
237+
// EXECUTION
238+
//////////////////////////////////////////////////////////////////////
239+
240+
RunTarget(target);

0 commit comments

Comments
 (0)