Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
70fbb7f
DATA: Added Credentials
SlimAhmad Jul 14, 2026
780d600
DATA: Added properties to strategy
SlimAhmad Jul 14, 2026
c67a74f
DATA: Added Service
SlimAhmad Jul 14, 2026
4cda17a
DATA: extended job with services
SlimAhmad Jul 14, 2026
0eb4cef
CODERUB: Enhance JobBuilder with matrix and service configuration
SlimAhmad Jul 14, 2026
270c086
CODERUB: Added Matrix and Services sample
SlimAhmad Jul 14, 2026
76d1015
CODERUB: Fixed failing test
SlimAhmad Jul 14, 2026
9f2633f
CPDERUB: removed unused usings
SlimAhmad Jul 14, 2026
fe782cd
CODERUB: Code Cleanup
SlimAhmad Jul 14, 2026
f5eb222
DATA: Added include and exclude property With matrixV2
SlimAhmad Jul 14, 2026
a3557ef
CODERUB: Code cleanup
SlimAhmad Jul 14, 2026
b9d0b6d
CODERUB: updated strategy to use Exclide and include and returned ori…
SlimAhmad Jul 14, 2026
3497eb5
CODERUB: Removed comment and credentials
SlimAhmad Jul 14, 2026
795006e
ShouldBuildMatrixWithMultipleAxesThroughPipeline -> PASS
SlimAhmad Jul 14, 2026
68374ef
ShouldAppendMultipleMatrixIncludeEntriesThroughPipeline -> PASS
SlimAhmad Jul 14, 2026
a5fa98a
ShouldAppendMatrixExcludeEntryThroughPipeline -> PASS
SlimAhmad Jul 14, 2026
dfc7424
ShouldKeepIncludeAndExcludeIndependentThroughPipeline -> PASS
SlimAhmad Jul 14, 2026
dae5157
ShouldSetFailFastThroughPipeline -> PASS
SlimAhmad Jul 14, 2026
a6cfdf7
ShouldSetMaxParallelThroughPipeline -> PASS
SlimAhmad Jul 14, 2026
e80263f
ShouldAddServiceWithFullKeySetThroughPipeline -> PASS
SlimAhmad Jul 14, 2026
eb824d6
ShouldOverwriteServiceWhenSameIdAddedTwiceThroughPipeline -> PASS
SlimAhmad Jul 14, 2026
db5c0c2
Revert "CODERUB: Code Cleanup"
SlimAhmad Jul 14, 2026
7a0eb87
CODERUB: Code cleanup
SlimAhmad Jul 14, 2026
64fe840
DATA: Added StrategyV2 and cleaned up Strategy
SlimAhmad Jul 14, 2026
e0a6534
DATA: Added JobV2 and cleaned up Job
SlimAhmad Jul 14, 2026
d85f5a7
CODERUB: Added GithubPipelineV2
SlimAhmad Jul 14, 2026
29f1ff7
CODERUB: Added GithubPipelineBuilderV2 and cleaned up GithubPipelineB…
SlimAhmad Jul 14, 2026
cc36103
CODERUB: Added JobBuilderV2 and cleaned up JobBuilder
SlimAhmad Jul 14, 2026
47b7d80
CODERUB: Updated sample to use GitHubPipelineBuilderV2
SlimAhmad Jul 14, 2026
ac56ef8
CODERUB: cleaned up V1 unit test
SlimAhmad Jul 14, 2026
46fa07d
CODERUB: Added V2 unit test
SlimAhmad Jul 14, 2026
4c5534e
CODERUB: Code cleanup
SlimAhmad Jul 14, 2026
f53bb6d
CODERUB: Refactor GitHub pipeline configuration to use model-based st…
SlimAhmad Jul 26, 2026
9c59a36
Merge branch 'main' into users/slimahmad/foundations-add-matrix-strat…
SlimAhmad Jul 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ADotNet/Clients/Builders/GitHubPipelineBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace ADotNet.Clients.Builders
/// <summary>
/// Builder for creating a GitHub pipeline.
/// </summary>
[Obsolete("No longer in use. Please migrate to GitHubPipelineBuilderV2.")]
public class GitHubPipelineBuilder
{
private readonly GithubPipeline githubPipeline;
Expand Down
108 changes: 108 additions & 0 deletions ADotNet/Clients/Builders/GitHubPipelineBuilderV2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// ---------------------------------------------------------------------------
// Copyright (c) Hassan Habib & Shri Humrudha Jagathisun All rights reserved.
// Licensed under the MIT License.
// See License.txt in the project root for license information.
// ---------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using ADotNet.Models.Pipelines.GithubPipelines.DotNets;

namespace ADotNet.Clients.Builders
{
/// <summary>
/// Builder for creating a GitHub pipeline.
/// </summary>
public class GitHubPipelineBuilderV2
{
private readonly GithubPipelineV2 githubPipelineV2;
private readonly IADotNetClient aDotNetClient;

internal GitHubPipelineBuilderV2(IADotNetClient aDotNetClient)
{
this.githubPipelineV2 = new GithubPipelineV2
{
OnEvents = new Events(),
Jobs = new Dictionary<string, JobV2>()
};

this.aDotNetClient = aDotNetClient;
}

/// <summary>
/// Creates a new instance of the <see cref="GitHubPipelineBuilderV2"/> class
/// with a default <see cref="ADotNetClient"/>.
/// </summary>
/// <returns>A new instance of <see cref="GitHubPipelineBuilderV2"/>.</returns>
public static GitHubPipelineBuilderV2 CreateNewPipeline()
{
var aDotNetClient = new ADotNetClient();

return new GitHubPipelineBuilderV2(aDotNetClient);
}

/// <summary>
/// Sets the name of the GitHub pipeline.
/// </summary>
/// <param name="name">The name of the pipeline.</param>
/// <returns>The current instance of <see cref="GitHubPipelineBuilderV2"/>.</returns>
public GitHubPipelineBuilderV2 SetName(string name)
{
this.githubPipelineV2.Name = name;

return this;
}

/// <summary>
/// Configures the pipeline to trigger on push events for specified branches.
/// </summary>
/// <param name="branches">The branches to trigger on push events.</param>
/// <returns>The current instance of <see cref="GitHubPipelineBuilderV2"/>.</returns>
public GitHubPipelineBuilderV2 OnPush(params string[] branches)
{
this.githubPipelineV2.OnEvents.Push = new PushEvent
{
Branches = branches
};

return this;
}

/// <summary>
/// Configures the pipeline to trigger on pull request events for specified branches.
/// </summary>
/// <param name="branches">The branches to trigger on pull request events.</param>
/// <returns>The current instance of <see cref="GitHubPipelineBuilderV2"/>.</returns>
public GitHubPipelineBuilderV2 OnPullRequest(params string[] branches)
{
this.githubPipelineV2.OnEvents.PullRequest = new PullRequestEvent
{
Branches = branches
};

return this;
}

/// <summary>
/// Adds a job to the GitHub pipeline.
/// </summary>
/// <param name="jobIdentifier">The unique identifier for the job.</param>
/// <param name="configureJob">The action to configure the job.</param>
/// <returns>The current instance of <see cref="GitHubPipelineBuilderV2"/>.</returns>
public GitHubPipelineBuilderV2 AddJob(string jobIdentifier, Action<JobBuilderV2> configureJob)
{
var jobBuilder = new JobBuilderV2();
configureJob(jobBuilder);
this.githubPipelineV2.Jobs[jobIdentifier] = jobBuilder.Build();

return this;
}

/// <summary>
/// Saves the configured pipeline (yml) to the specified file path.
/// </summary>
/// <param name="path">The file path where the pipeline will be saved.</param>
public void SaveToFile(string path) =>
this.aDotNetClient.SerializeAndWriteToFile(this.githubPipelineV2, path);
}
}
2 changes: 2 additions & 0 deletions ADotNet/Clients/Builders/JobBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// See License.txt in the project root for license information.
// ---------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using ADotNet.Models.Pipelines.GithubPipelines.DotNets;
using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks;
Expand All @@ -14,6 +15,7 @@ namespace ADotNet.Clients.Builders
/// <summary>
/// A builder to create a job for a GitHub Actions workflow.
/// </summary>
[Obsolete("No longer in use. Please migrate to JobBuilderV2.")]
public class JobBuilder
{
private readonly Job job;
Expand Down
195 changes: 195 additions & 0 deletions ADotNet/Clients/Builders/JobBuilderV2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
// ---------------------------------------------------------------------------
// Copyright (c) Hassan Habib & Shri Humrudha Jagathisun All rights reserved.
// Licensed under the MIT License.
// See License.txt in the project root for license information.
// ---------------------------------------------------------------------------

using System.Collections.Generic;
using ADotNet.Models.Pipelines.GithubPipelines.DotNets;
using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks;
using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks.SetupDotNetTaskV5s;

namespace ADotNet.Clients.Builders
{
/// <summary>
/// A builder to create a job for a GitHub Actions workflow.
/// </summary>
public class JobBuilderV2
{
private readonly JobV2 job;

internal JobBuilderV2()
{
this.job = new JobV2
{
Steps = new List<GithubTask>(),
EnvironmentVariables = null
};
}

/// <summary>
/// Sets the name of the job.
/// </summary>
/// <param name="name">The name of the job.</param>
/// <returns>The current instance of <see cref="JobBuilderV2"/>.</returns>
public JobBuilderV2 WithName(string name)
{
this.job.Name = name;

return this;
}

/// <summary>
/// Specifies the machine on which the job will run.
/// </summary>
/// <param name="machine">The machine or environment to run the job on.</param>
/// <returns>The current instance of <see cref="JobBuilderV2"/>.</returns>
public JobBuilderV2 RunsOn(string machine)
{
this.job.RunsOn = machine;

return this;
}

/// <summary>
/// Adds an environment variable to the job.
/// </summary>
/// <param name="key">The key of the environment variable.</param>
/// <param name="value">The value of the environment variable.</param>
/// <returns>The current instance of <see cref="JobBuilderV2"/>.</returns>
public JobBuilderV2 AddEnvironmentVariable(string key, string value)
{
this.job.EnvironmentVariables ??= new Dictionary<string, string>();

this.job.EnvironmentVariables[key] = value;

return this;
}

/// <summary>
/// Adds multiple environment variables to the job.
/// </summary>
/// <param name="variables">A dictionary of environment variables to add.</param>
/// <returns>The current instance of <see cref="JobBuilderV2"/>.</returns>
public JobBuilderV2 AddEnvironmentVariables(Dictionary<string, string> variables)
{
this.job.EnvironmentVariables ??= new Dictionary<string, string>();

foreach (var variable in variables)
{
this.job.EnvironmentVariables[variable.Key] = variable.Value;
}

return this;
}

/// <summary>
/// Adds a checkout step to the job.
/// </summary>
/// <param name="name">The name of the checkout step (default: "Check out").</param>
/// <returns>The current instance of <see cref="JobBuilderV2"/>.</returns>
public JobBuilderV2 AddCheckoutStep(string name = "Check out")
{
this.job.Steps.Add(new CheckoutTaskV5 { Name = name });

return this;
}

/// <summary>
/// Adds a setup step for a specific .NET version to the job.
/// </summary>
/// <param name="version">The version of .NET to set up.</param>
/// <param name="stepName">The name of the setup step (default: "Setup Dot Net Version").</param>
/// <param name="includePrerelease">Specifies whether to include prerelease versions.</param>
/// <returns>The current instance of <see cref="JobBuilderV2"/>.</returns>
public JobBuilderV2 AddSetupDotNetStep(
string version,
string stepName = "Setup Dot Net Version",
bool includePrerelease = false)
{
this.job.Steps.Add(new SetupDotNetTaskV5
{
Name = stepName,
With = new TargetDotNetVersionV5
{
DotNetVersion = version,
}
});

return this;
}

/// <summary>
/// Adds a restore step to the job.
/// </summary>
/// <param name="name">The name of the restore step (default: "Restore").</param>
/// <returns>The current instance of <see cref="JobBuilderV2"/>.</returns>
public JobBuilderV2 AddRestoreStep(string name = "Restore")
{
this.job.Steps.Add(new RestoreTask { Name = name });

return this;
}

/// <summary>
/// Adds a build step to the job.
/// </summary>
/// <param name="name">The name of the build step (default: "Build").</param>
/// <returns>The current instance of <see cref="JobBuilderV2"/>.</returns>
public JobBuilderV2 AddBuildStep(string name = "Build")
{
this.job.Steps.Add(new DotNetBuildTask { Name = name });

return this;
}

/// <summary>
/// Adds a test step to the job.
/// </summary>
/// <param name="name">The name of the test step (default: "Test").</param>
/// <param name="command">The command to execute the test
/// (default: "dotnet test --no-build --verbosity normal").</param>
/// <returns>The current instance of <see cref="JobBuilderV2"/>.</returns>
public JobBuilderV2 AddTestStep(string name = "Test", string command = null)
{
this.job.Steps.Add(new TestTask
{
Name = name,
Run = command ?? "dotnet test --no-build --verbosity normal"
});

return this;
}

/// <summary>
/// Adds a generic run-based step, optionally with an id so later steps can reference its outputs.
/// </summary>
/// <param name="name">The name of the step.</param>
/// <param name="runCommand">The command to execute for this step.</param>
/// <param name="id">The id of the step.</param>
/// <param name="shell">The shell to use for the step.</param>
/// <returns>The current instance of <see cref="JobBuilderV2"/>.</returns>
public JobBuilderV2 AddGenericStep(
string name,
string runCommand,
string id = null,
string shell = null)
{
this.job.Steps.Add(new GithubTask
{
Id = id,
Name = name,
Run = runCommand,
Shell = shell
});

return this;
}

/// <summary>
/// Builds and returns the configured job.
/// </summary>
/// <returns>The configured <see cref="JobV2"/> instance.</returns>
public JobV2 Build() => this.job;
}
}
19 changes: 19 additions & 0 deletions ADotNet/Models/Pipelines/GithubPipelines/DotNets/Credentials.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// ---------------------------------------------------------------------------
// Copyright (c) Hassan Habib & Shri Humrudha Jagathisun All rights reserved.
// Licensed under the MIT License.
// See License.txt in the project root for license information.
// ---------------------------------------------------------------------------

using YamlDotNet.Serialization;

namespace ADotNet.Models.Pipelines.GithubPipelines.DotNets
{
public class Credentials
{
[YamlMember(Order = 0, Alias = "username", DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public string Username { get; set; }

[YamlMember(Order = 1, Alias = "password", DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public string Password { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ---------------------------------------------------------------------------
// Copyright (c) Hassan Habib & Shri Humrudha Jagathisun All rights reserved.
// Licensed under the MIT License.
// See License.txt in the project root for license information.
// ---------------------------------------------------------------------------

using System.Collections.Generic;
using YamlDotNet.Serialization;

namespace ADotNet.Models.Pipelines.GithubPipelines.DotNets
{
public class GithubPipelineV2
{
public string Name { get; set; }

[YamlMember(Alias = "on")]
public Events OnEvents { get; set; }

[YamlMember(Alias = "env", DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public Dictionary<string, string> EnvironmentVariables { get; set; }

[YamlMember(Alias = "jobs")]
public Dictionary<string, JobV2> Jobs { get; set; }
}
}
4 changes: 3 additions & 1 deletion ADotNet/Models/Pipelines/GithubPipelines/DotNets/Job.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// Copyright (c) Hassan Habib & Shri Humrudha Jagathisun All rights reserved.
// Licensed under the MIT License.
// See License.txt in the project root for license information.
// ---------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.ComponentModel;
using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks;
using YamlDotNet.Serialization;

namespace ADotNet.Models.Pipelines.GithubPipelines.DotNets
{
[Obsolete("No longer in use. Please migrate to JobV2.")]
public class Job
{
[YamlMember(Order = 0, DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
Expand Down
Loading
Loading