Skip to content

Commit b03c4fd

Browse files
wip
1 parent a91b07a commit b03c4fd

File tree

6 files changed

+39
-10
lines changed

6 files changed

+39
-10
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
namespace Nullinside.Cicd.GitHub;
22

3+
/// <summary>
4+
/// Constants used throughout the appliction.
5+
/// </summary>
36
public static class Constants {
7+
/// <summary>
8+
/// The github project name
9+
/// </summary>
410
public const string GITHUB_ORG = "nullinside-development-group";
11+
12+
/// <summary>
13+
/// The github project's unique identifier on github.
14+
/// </summary>
515
public const int GITHUB_PROJECT_NUM = 1;
616
}

src/Nullinside.Cicd.GitHub/Nullinside.Cicd.GitHub.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
</PropertyGroup>
2020

2121
<ItemGroup>
22-
<PackageReference Include="log4net" Version="3.0.4" />
23-
<PackageReference Include="Octokit" Version="14.0.0" />
22+
<PackageReference Include="log4net" Version="3.0.4"/>
23+
<PackageReference Include="Octokit" Version="14.0.0"/>
2424
</ItemGroup>
2525

2626
<ItemGroup>
27-
<ProjectReference Include="..\octokit.graphql.net\src\Octokit.GraphQL\Octokit.GraphQL.csproj" />
27+
<ProjectReference Include="..\octokit.graphql.net\src\Octokit.GraphQL\Octokit.GraphQL.csproj"/>
2828
</ItemGroup>
2929

3030
</Project>

src/Nullinside.Cicd.GitHub/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
}
3939

4040
foreach (IRepoRule? rule in rules) {
41-
await rule.Handle(client, graphQl, projectId, repo);
41+
await rule!.Handle(client, graphQl, projectId, repo);
4242
}
4343
}
44-
44+
4545
Console.WriteLine("Waiting for next execution time...");
4646
Task.WaitAll(Task.Delay(TimeSpan.FromMinutes(5)));
4747
}

src/Nullinside.Cicd.GitHub/Rule/AssociateIssuesWithProject.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88

99
namespace Nullinside.Cicd.GitHub.Rule;
1010

11+
/// <summary>
12+
/// Handles associating issues with the project automatically.
13+
/// </summary>
1114
public class AssociateIssuesWithProject : IRepoRule {
15+
/// <inheritdoc />
1216
public async Task Handle(GitHubClient client, Connection graphQl, ID projectId, Repository repo) {
1317
if (!repo.HasIssues) {
1418
return;

src/Nullinside.Cicd.GitHub/Rule/CreateRulesets.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88

99
namespace Nullinside.Cicd.GitHub.Rule;
1010

11+
/// <summary>
12+
/// Creates the branch merging rules based on the code bases' language.
13+
/// </summary>
1114
public class CreateRulesets : IRepoRule {
15+
/// <inheritdoc />
1216
public async Task Handle(GitHubClient client, Connection graphQl, ID projectId, Repository repo) {
1317
// This currently doesn't run properly. You get an error about not specifying multiple Parameters on the status
1418
// checks. Waiting on an update from the source library to not include nulls in the compiled query.
@@ -18,19 +22,19 @@ public async Task Handle(GitHubClient client, Connection graphQl, ID projectId,
1822
.Rulesets()
1923
.AllPages()
2024
.Select(i => i.Name));
21-
25+
2226
string? expectedRuleset =
2327
rulesets.FirstOrDefault(r => "main".Equals(r, StringComparison.InvariantCultureIgnoreCase));
2428
if (null != expectedRuleset) {
2529
return;
2630
}
27-
31+
2832
ID id = await graphQl.Run(new Query()
2933
.Repository(repo.Name, Constants.GITHUB_ORG)
3034
.Select(i => i.Id));
31-
35+
3236
Console.WriteLine($"{repo.Name}: Creating default ruleset");
33-
StatusCheckConfigurationInput[] statusChecks = null;
37+
StatusCheckConfigurationInput[]? statusChecks = null;
3438
if ("Typescript".Equals(repo.Language, StringComparison.InvariantCultureIgnoreCase)) {
3539
statusChecks = new[] {
3640
new StatusCheckConfigurationInput {
@@ -90,7 +94,7 @@ public async Task Handle(GitHubClient client, Connection graphQl, ID projectId,
9094
}
9195
});
9296
}
93-
97+
9498
await graphQl.Run(new Mutation()
9599
.CreateRepositoryRuleset(new Arg<CreateRepositoryRulesetInput>(new CreateRepositoryRulesetInput {
96100
SourceId = id,

src/Nullinside.Cicd.GitHub/Rule/IRepoRule.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@
55

66
namespace Nullinside.Cicd.GitHub.Rule;
77

8+
/// <summary>
9+
/// Contracts for executing code against a project.
10+
/// </summary>
811
public interface IRepoRule {
12+
/// <summary>
13+
/// Handles performing the rule updates.
14+
/// </summary>
15+
/// <param name="client">The github rest api client.</param>
16+
/// <param name="graphQl">The github graphql client.</param>
17+
/// <param name="projectId">The unique identifier of the project.</param>
18+
/// <param name="repo">The git repo being updated.</param>
19+
/// <returns></returns>
920
Task Handle(GitHubClient client, Connection graphQl, ID projectId, Repository repo);
1021
}

0 commit comments

Comments
 (0)