Skip to content

Commit

Permalink
adding branch feature
Browse files Browse the repository at this point in the history
  • Loading branch information
jsinglet committed Jan 22, 2024
1 parent dcae3b7 commit 8a7a5f2
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
name: ⚙️ CodeQL - Run Unit Tests ({{language}})
{% raw %}


on:
push:
branches:
- '**'
- '{{branch}}'
pull_request:
branches:
- '**'
- '{{branch}}'
workflow_dispatch:

{% raw %}
jobs:
create-unit-test-matrix:
name: Create CodeQL Unit Test Matrix
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
name: ⚙️ CodeQL - Validate Queries ({{language}})
{% raw %}

on:
push:
branches:
- '**'
- '{{ branch }}'
pull_request:
branches:
- '**'
- '{{ branch }}'
workflow_dispatch:

{% raw %}
jobs:
create-matrix:
name: Create CodeQL Test Matrix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ abstract public class BaseLifecycleTarget : ILifecycleTarget

public string ExtraArgs { get; set; }



}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public override void Run()
var tmpLanguage = Language;
Language = null;

var codeqlArgs = "--threads=0";
var EXcodeqlArgs = "--threads=0";

if(ExtraArgs!= null && ExtraArgs.Length > 0)
{
codeqlArgs = $"{codeqlArgs} {ExtraArgs}";
}
//if(ExtraArgs!= null && ExtraArgs.Length > 0)
//{
// codeqlArgs = $"{codeqlArgs} {ExtraArgs}";
//}

WriteTemplateIfOverwriteOrNotExists("install-codeql", Path.Combine(Base, ".github", "actions", "install-codeql", "action.yml"), "install-codeql action");
WriteTemplateIfOverwriteOrNotExists("install-qlt", Path.Combine(Base, ".github", "actions", "install-qlt", "action.yml"), "install-qlt action");
Expand All @@ -35,8 +35,10 @@ public override void Run()
numThreads = NumThreads,
useRunner = UseRunner,
language = tmpLanguage,
codeqlArgs = codeqlArgs,
devMode = DevMode
codeqlArgs = EXcodeqlArgs,
devMode = DevMode,
branch = Branch

});

Language = tmpLanguage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,21 @@ public void Register(Command parentCommand)
var numThreadsOption = new Option<int>("--num-threads", () => 4, "Number of threads to use during test execution.");
var useRunnerOption = new Option<string>("--use-runner", () => "ubuntu-latest", "The runner(s) to use. Should be a comma-seperated list of actions runners.");
var languageOption = new Option<string>("--language", $"The language to generate automation for.") { IsRequired = true }.FromAmong(SupportedLangauges.Select(x => x.ToOptionString()).ToArray());
var extraCodeQLOptions = new Option<string>("--codeql-args", $"Extra arguments to pass to CodeQL.") { IsRequired = false };
//var extraCodeQLOptions = new Option<string>("--codeql-args", $"Extra arguments to pass to CodeQL.") { IsRequired = false };
var branchOption = new Option<string>("--branch", () => "main", "Branch to use as the target for triggering automation.");

initCommand.AddOption(overwriteExistingOption);
initCommand.AddOption(numThreadsOption);
initCommand.AddOption(useRunnerOption);
initCommand.AddOption(languageOption);
initCommand.AddOption(extraCodeQLOptions);

//initCommand.AddOption(extraCodeQLOptions);
initCommand.AddOption(branchOption);

parentCommand.Add(initCommand);



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

Expand All @@ -66,11 +67,12 @@ public void Register(Command parentCommand)
featureTarget.NumThreads = numThreads;
featureTarget.UseRunner = useRunner;
featureTarget.Language = language;
featureTarget.ExtraArgs = extraArgs;
//featureTarget.ExtraArgs = extraArgs;
featureTarget.DevMode = devMode;
featureTarget.Branch = branch;
featureTarget.Run();

}, Globals.Development, Globals.BasePathOption, Globals.AutomationTypeOption, overwriteExistingOption, numThreadsOption, useRunnerOption, languageOption, extraCodeQLOptions);
}, Globals.Development, Globals.BasePathOption, Globals.AutomationTypeOption, overwriteExistingOption, numThreadsOption, useRunnerOption, languageOption, branchOption);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public override void Run()
{
useRunner = UseRunner,
language = tmpLanguage,
devMode = DevMode
devMode = DevMode,
branch = Branch
});

Language = tmpLanguage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ public void Register(Command parentCommand)
var overwriteExistingOption = new Option<bool>("--overwrite-existing", () => false, "Overwrite exiting files (if they exist).");
var languageOption = new Option<string>("--language", $"The language to generate automation for.") { IsRequired = true }.FromAmong(SupportedLangauges.Select(x => x.ToOptionString()).ToArray());
var useRunnerOption = new Option<string>("--use-runner", () => "ubuntu-latest", "The runner(s) to use. Should be a comma-seperated list of actions runners.");
var branchOption = new Option<string>("--branch", () => "main", "Branch to use as the target for triggering automation.");

initCommand.AddOption(overwriteExistingOption);
initCommand.AddOption(languageOption);
initCommand.AddOption(useRunnerOption);
initCommand.AddOption(branchOption);

parentCommand.Add(initCommand);

initCommand.SetHandler((devMode, basePath, automationType, overwriteExisting, language, useRunner) =>
initCommand.SetHandler((devMode, basePath, automationType, overwriteExisting, language, useRunner, branch) =>
{
Log<TestLifecycleFeature>.G().LogInformation("Executing init command...");

Expand All @@ -62,9 +64,10 @@ public void Register(Command parentCommand)
featureTarget.OverwriteExisting = overwriteExisting;
featureTarget.Language = language;
featureTarget.DevMode = devMode;
featureTarget.Branch = branch;
featureTarget.Run();

}, Globals.Development, Globals.BasePathOption, Globals.AutomationTypeOption, overwriteExistingOption, languageOption, useRunnerOption);
}, Globals.Development, Globals.BasePathOption, Globals.AutomationTypeOption, overwriteExistingOption, languageOption, useRunnerOption, branchOption);

}

Expand Down
2 changes: 2 additions & 0 deletions src/CodeQLToolkit.Shared/Target/ILifecycleTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public abstract class ILifecycleTarget : ITarget
public string Language { get; set; }
public bool OverwriteExisting { get; set; }
public string FeatureName { get; set; }
public string Branch { get; set; }

public bool DevMode { get; set; }
public AutomationType AutomationType { get; set; } = AutomationType.ANY;

Expand Down

0 comments on commit 8a7a5f2

Please sign in to comment.