Skip to content

Commit 8a7a5f2

Browse files
committed
adding branch feature
1 parent dcae3b7 commit 8a7a5f2

File tree

8 files changed

+35
-23
lines changed

8 files changed

+35
-23
lines changed

src/CodeQLToolkit.Features/Templates/Test/Actions/run-unit-tests.liquid

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
name: ⚙️ CodeQL - Run Unit Tests ({{language}})
2-
{% raw %}
2+
33

44
on:
55
push:
66
branches:
7-
- '**'
7+
- '{{branch}}'
88
pull_request:
99
branches:
10-
- '**'
10+
- '{{branch}}'
1111
workflow_dispatch:
1212

13+
{% raw %}
1314
jobs:
1415
create-unit-test-matrix:
1516
name: Create CodeQL Unit Test Matrix

src/CodeQLToolkit.Features/Templates/Validation/Actions/validate-query-metadata.liquid

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
name: ⚙️ CodeQL - Validate Queries ({{language}})
2-
{% raw %}
2+
33
on:
44
push:
55
branches:
6-
- '**'
6+
- '{{ branch }}'
77
pull_request:
88
branches:
9-
- '**'
9+
- '{{ branch }}'
1010
workflow_dispatch:
1111

12+
{% raw %}
1213
jobs:
1314
create-matrix:
1415
name: Create CodeQL Test Matrix

src/CodeQLToolkit.Features/Test/Lifecycle/BaseLifecycleTarget.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ abstract public class BaseLifecycleTarget : ILifecycleTarget
1313

1414
public string ExtraArgs { get; set; }
1515

16-
16+
1717

1818
}
1919
}

src/CodeQLToolkit.Features/Test/Lifecycle/Targets/Actions/InitLifecycleTarget.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public override void Run()
2121
var tmpLanguage = Language;
2222
Language = null;
2323

24-
var codeqlArgs = "--threads=0";
24+
var EXcodeqlArgs = "--threads=0";
2525

26-
if(ExtraArgs!= null && ExtraArgs.Length > 0)
27-
{
28-
codeqlArgs = $"{codeqlArgs} {ExtraArgs}";
29-
}
26+
//if(ExtraArgs!= null && ExtraArgs.Length > 0)
27+
//{
28+
// codeqlArgs = $"{codeqlArgs} {ExtraArgs}";
29+
//}
3030

3131
WriteTemplateIfOverwriteOrNotExists("install-codeql", Path.Combine(Base, ".github", "actions", "install-codeql", "action.yml"), "install-codeql action");
3232
WriteTemplateIfOverwriteOrNotExists("install-qlt", Path.Combine(Base, ".github", "actions", "install-qlt", "action.yml"), "install-qlt action");
@@ -35,8 +35,10 @@ public override void Run()
3535
numThreads = NumThreads,
3636
useRunner = UseRunner,
3737
language = tmpLanguage,
38-
codeqlArgs = codeqlArgs,
39-
devMode = DevMode
38+
codeqlArgs = EXcodeqlArgs,
39+
devMode = DevMode,
40+
branch = Branch
41+
4042
});
4143

4244
Language = tmpLanguage;

src/CodeQLToolkit.Features/Test/Lifecycle/TestLifecycleFeature.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,21 @@ public void Register(Command parentCommand)
3737
var numThreadsOption = new Option<int>("--num-threads", () => 4, "Number of threads to use during test execution.");
3838
var useRunnerOption = new Option<string>("--use-runner", () => "ubuntu-latest", "The runner(s) to use. Should be a comma-seperated list of actions runners.");
3939
var languageOption = new Option<string>("--language", $"The language to generate automation for.") { IsRequired = true }.FromAmong(SupportedLangauges.Select(x => x.ToOptionString()).ToArray());
40-
var extraCodeQLOptions = new Option<string>("--codeql-args", $"Extra arguments to pass to CodeQL.") { IsRequired = false };
40+
//var extraCodeQLOptions = new Option<string>("--codeql-args", $"Extra arguments to pass to CodeQL.") { IsRequired = false };
41+
var branchOption = new Option<string>("--branch", () => "main", "Branch to use as the target for triggering automation.");
4142

4243
initCommand.AddOption(overwriteExistingOption);
4344
initCommand.AddOption(numThreadsOption);
4445
initCommand.AddOption(useRunnerOption);
4546
initCommand.AddOption(languageOption);
46-
initCommand.AddOption(extraCodeQLOptions);
47-
47+
//initCommand.AddOption(extraCodeQLOptions);
48+
initCommand.AddOption(branchOption);
4849

4950
parentCommand.Add(initCommand);
5051

5152

5253

53-
initCommand.SetHandler((devMode, basePath, automationType, overwriteExisting, numThreads, useRunner, language, extraArgs) =>
54+
initCommand.SetHandler((devMode, basePath, automationType, overwriteExisting, numThreads, useRunner, language, branch) =>
5455
{
5556
Log<TestLifecycleFeature>.G().LogInformation("Executing init command...");
5657

@@ -66,11 +67,12 @@ public void Register(Command parentCommand)
6667
featureTarget.NumThreads = numThreads;
6768
featureTarget.UseRunner = useRunner;
6869
featureTarget.Language = language;
69-
featureTarget.ExtraArgs = extraArgs;
70+
//featureTarget.ExtraArgs = extraArgs;
7071
featureTarget.DevMode = devMode;
72+
featureTarget.Branch = branch;
7173
featureTarget.Run();
7274

73-
}, Globals.Development, Globals.BasePathOption, Globals.AutomationTypeOption, overwriteExistingOption, numThreadsOption, useRunnerOption, languageOption, extraCodeQLOptions);
75+
}, Globals.Development, Globals.BasePathOption, Globals.AutomationTypeOption, overwriteExistingOption, numThreadsOption, useRunnerOption, languageOption, branchOption);
7476

7577
}
7678

src/CodeQLToolkit.Features/Validation/Lifecycle/Targets/Actions/InitLifecycleTarget.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public override void Run()
2626
{
2727
useRunner = UseRunner,
2828
language = tmpLanguage,
29-
devMode = DevMode
29+
devMode = DevMode,
30+
branch = Branch
3031
});
3132

3233
Language = tmpLanguage;

src/CodeQLToolkit.Features/Validation/Lifecycle/ValidationLifecycleFeature.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ public void Register(Command parentCommand)
3939
var overwriteExistingOption = new Option<bool>("--overwrite-existing", () => false, "Overwrite exiting files (if they exist).");
4040
var languageOption = new Option<string>("--language", $"The language to generate automation for.") { IsRequired = true }.FromAmong(SupportedLangauges.Select(x => x.ToOptionString()).ToArray());
4141
var useRunnerOption = new Option<string>("--use-runner", () => "ubuntu-latest", "The runner(s) to use. Should be a comma-seperated list of actions runners.");
42+
var branchOption = new Option<string>("--branch", () => "main", "Branch to use as the target for triggering automation.");
4243

4344
initCommand.AddOption(overwriteExistingOption);
4445
initCommand.AddOption(languageOption);
4546
initCommand.AddOption(useRunnerOption);
47+
initCommand.AddOption(branchOption);
4648

4749
parentCommand.Add(initCommand);
4850

49-
initCommand.SetHandler((devMode, basePath, automationType, overwriteExisting, language, useRunner) =>
51+
initCommand.SetHandler((devMode, basePath, automationType, overwriteExisting, language, useRunner, branch) =>
5052
{
5153
Log<TestLifecycleFeature>.G().LogInformation("Executing init command...");
5254

@@ -62,9 +64,10 @@ public void Register(Command parentCommand)
6264
featureTarget.OverwriteExisting = overwriteExisting;
6365
featureTarget.Language = language;
6466
featureTarget.DevMode = devMode;
67+
featureTarget.Branch = branch;
6568
featureTarget.Run();
6669

67-
}, Globals.Development, Globals.BasePathOption, Globals.AutomationTypeOption, overwriteExistingOption, languageOption, useRunnerOption);
70+
}, Globals.Development, Globals.BasePathOption, Globals.AutomationTypeOption, overwriteExistingOption, languageOption, useRunnerOption, branchOption);
6871

6972
}
7073

src/CodeQLToolkit.Shared/Target/ILifecycleTarget.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ public abstract class ILifecycleTarget : ITarget
1212
public string Language { get; set; }
1313
public bool OverwriteExisting { get; set; }
1414
public string FeatureName { get; set; }
15+
public string Branch { get; set; }
16+
1517
public bool DevMode { get; set; }
1618
public AutomationType AutomationType { get; set; } = AutomationType.ANY;
1719

0 commit comments

Comments
 (0)