Skip to content

Commit 3579f31

Browse files
authored
Merge pull request #3386 from arturcic/feature/build-agents
move build agents to a separate lib out of core
2 parents 3cb12bc + 4c6b6f0 commit 3579f31

File tree

71 files changed

+392
-359
lines changed

Some content is hidden

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

71 files changed

+392
-359
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ src/Docker/**/content
126126
config.wyam.dll
127127
config.wyam.hash
128128
config.wyam.packages.xml
129-
/tests/integration/core/build
130-
/tests/integration/full/build
129+
/tests/integration/build
131130
docs/output
132131

133132
# NPM

build/artifacts/Tasks/ArtifactsMsBuildCoreTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public override void Run(BuildContext context)
3737
_ => targetFramework
3838
};
3939

40-
var cmd = $"{rootPrefix}/scripts/test-msbuild-task.sh --version {version} --nugetPath {rootPrefix}/nuget --repoPath {rootPrefix}/repo/tests/integration/core --targetframework {targetFramework}";
40+
var cmd = $"{rootPrefix}/scripts/test-msbuild-task.sh --version {version} --nugetPath {rootPrefix}/nuget --repoPath {rootPrefix}/repo/tests/integration --targetframework {targetFramework}";
4141

4242
context.DockerTestArtifact(dockerImage, cmd);
4343
}

build/artifacts/Tasks/ArtifactsMsBuildFullTest.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ public override void Run(BuildContext context)
2222

2323
var nugetSource = context.MakeAbsolute(Paths.Nuget).FullPath;
2424

25-
context.Information("\nTesting msbuild task with dotnet build (for .net core)\n");
25+
context.Information("\nTesting msbuild task with dotnet build\n");
2626
var frameworks = new[] { Constants.NetVersion60, Constants.NetVersion70 };
2727
foreach (var framework in frameworks)
2828
{
2929
var dotnetMsBuildSettings = new DotNetMSBuildSettings();
30-
dotnetMsBuildSettings.WithProperty("TargetFrameworks", framework);
31-
dotnetMsBuildSettings.WithProperty("TargetFramework", framework);
30+
dotnetMsBuildSettings.SetTargetFramework(framework);
3231
dotnetMsBuildSettings.WithProperty("GitVersionMsBuildVersion", version);
33-
var projPath = context.MakeAbsolute(Paths.Integration.Combine("core"));
32+
var projPath = context.MakeAbsolute(Paths.Integration);
3433

3534
context.DotNetBuild(projPath.FullPath, new DotNetBuildSettings
3635
{
@@ -40,8 +39,8 @@ public override void Run(BuildContext context)
4039
Sources = new[] { nugetSource }
4140
});
4241

43-
var netcoreExe = Paths.Integration.Combine("core").Combine("build").Combine(framework).CombineWithFilePath("app.dll");
44-
context.ValidateOutput("dotnet", netcoreExe.FullPath, context.Version.GitVersion.FullSemVer);
42+
var exe = Paths.Integration.Combine("build").Combine(framework).CombineWithFilePath("app.dll");
43+
context.ValidateOutput("dotnet", exe.FullPath, context.Version.GitVersion.FullSemVer);
4544
}
4645
}
4746
}

build/build/Tasks/Package/PackageNuget.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ private static void PackageWithCli(BuildContext context)
2525

2626
// GitVersion.MsBuild, global tool & core
2727
context.DotNetPack("./src/GitVersion.Core", settings);
28+
context.DotNetPack("./src/GitVersion.BuildAgents", settings);
2829

2930
settings.ArgumentCustomization = arg => arg.Append("/p:PackAsTool=true");
3031
context.DotNetPack("./src/GitVersion.App", settings);

src/GitTools.Testing/Internal/ProcessHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ void IDisposable.Dispose()
196196
{
197197
try
198198
{
199-
SetErrorMode(this.oldMode);
199+
_ = SetErrorMode(this.oldMode);
200200
}
201201
catch (Exception ex) when (ex is EntryPointNotFoundException or DllNotFoundException)
202202
{

src/GitVersion.App.Tests/ArgumentParserOnBuildServerTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public void EmptyOnFetchDisabledBuildServerMeansNoFetchIsTrue()
3131

3232
private class MockBuildAgent : ICurrentBuildAgent
3333
{
34+
public bool IsDefault => false;
3435
public bool CanApplyToCurrentContext() => throw new NotImplementedException();
3536

3637
public void WriteIntegration(Action<string> writer, VersionVariables variables, bool updateBuildNumber = true) => throw new NotImplementedException();

src/GitVersion.App.Tests/Helpers/ProgramFixture.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public ProgramFixture(string workingDirectory = "")
2727

2828
this.environment = new TestEnvironment();
2929

30-
Overrides.Add(services =>
30+
WithOverrides(services =>
3131
{
3232
services.AddSingleton(log);
3333
services.AddSingleton(consoleAdapter);
@@ -46,6 +46,8 @@ public void WithEnv(params KeyValuePair<string, string>[] envs)
4646
}
4747
}
4848

49+
public void WithOverrides(Action<IServiceCollection> action) => Overrides.Add(action);
50+
4951
public Task<ProgramFixtureResult> Run(string arg)
5052
{
5153
var args = arg.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();

src/GitVersion.App.Tests/PullRequestInBuildAgentTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using GitVersion.BuildAgents;
22
using GitVersion.Core.Tests.Helpers;
3+
using GitVersion.Extensions;
34
using LibGit2Sharp;
45

56
namespace GitVersion.App.Tests;
@@ -166,6 +167,7 @@ private static async Task VerifyPullRequestVersionIsCalculatedProperly(string pu
166167
}
167168

168169
var programFixture = new ProgramFixture(fixture.RepositoryPath);
170+
programFixture.WithOverrides(services => services.AddModule(new GitVersionBuildAgentsModule()));
169171
programFixture.WithEnv(env.ToArray());
170172

171173
var result = await programFixture.Run();

src/GitVersion.App/GitVersion.App.csproj

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,21 @@
2121
</PropertyGroup>
2222

2323
<ItemGroup>
24-
<PackageReference Include="Microsoft.Extensions.Hosting"/>
25-
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing"/>
24+
<PackageReference Include="Microsoft.Extensions.Hosting" />
25+
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" />
2626
</ItemGroup>
2727

2828
<ItemGroup>
29-
<ProjectReference Include="..\GitVersion.LibGit2Sharp\GitVersion.LibGit2Sharp.csproj"/>
30-
<ProjectReference Include="..\GitVersion.Core\GitVersion.Core.csproj"/>
29+
<ProjectReference Include="..\GitVersion.BuildAgents\GitVersion.BuildAgents.csproj" />
30+
<ProjectReference Include="..\GitVersion.LibGit2Sharp\GitVersion.LibGit2Sharp.csproj" />
31+
<ProjectReference Include="..\GitVersion.Core\GitVersion.Core.csproj" />
3132
</ItemGroup>
3233

3334
<ItemGroup>
34-
<EmbeddedResource Include="../../docs/input/docs/usage/cli/arguments.md"/>
35+
<EmbeddedResource Include="../../docs/input/docs/usage/cli/arguments.md" />
3536
</ItemGroup>
3637

3738
<ItemGroup>
38-
<InternalsVisibleTo Include="GitVersion.App.Tests"/>
39+
<InternalsVisibleTo Include="GitVersion.App.Tests" />
3940
</ItemGroup>
4041
</Project>

src/GitVersion.App/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using GitVersion.BuildAgents;
12
using GitVersion.Extensions;
23
using Microsoft.Extensions.Configuration;
34
using Microsoft.Extensions.DependencyInjection;
@@ -23,6 +24,7 @@ private IHostBuilder CreateHostBuilder(string[] args) =>
2324
{
2425
services.AddModule(new GitVersionCoreModule());
2526
services.AddModule(new GitVersionLibGit2SharpModule());
27+
services.AddModule(new GitVersionBuildAgentsModule());
2628
services.AddModule(new GitVersionAppModule());
2729

2830
services.AddSingleton(sp =>

0 commit comments

Comments
 (0)