Skip to content

Commit

Permalink
Added innerpowershell task support
Browse files Browse the repository at this point in the history
  • Loading branch information
samsmithnz committed Mar 1, 2021
1 parent dc4ff40 commit 90cb9c1
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ public GitHubActions.Step ProcessStep(AzurePipelines.Step step)
case "HUGOTASK@1":
gitHubStep = CreateHugoStep(step);
break;
case "INLINEPOWERSHELL@1":
gitHubStep = CreateInnerPowershellStep(step);
break;
//case "KUBERNETES@1":
// gitHubStep = CreateKubernetesStep(step);
// break;
Expand Down Expand Up @@ -2310,6 +2313,31 @@ private GitHubActions.Step CreateAzurePowershellStep(AzurePipelines.Step step)
return gitHubStep;
}

private GitHubActions.Step CreateInnerPowershellStep(AzurePipelines.Step step)
{

//From:
//- task: InlinePowershell@1
// displayName: 'old Powershell task'
// inputs:
// Script: |
// Write-Host 'Hello World'

//To:
//- name: old Powershell task
// run: |
// Write-Host 'Hello World'
// shell: powershell


string script = GetStepInput(step, "script");
step.script = script;

GitHubActions.Step gitHubStep = CreateScriptStep("powershell", step);

return gitHubStep;
}

private GitHubActions.Step CreateXamarinAndroidStep(AzurePipelines.Step step)
{
//coming from:
Expand Down
29 changes: 29 additions & 0 deletions src/AzurePipelinesToGitHubActionsConverter.Tests/StepsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,35 @@ public void HugoIndividualStepTest()
Assert.AreEqual(expected, gitHubOutput.actionsYaml);
}

[TestMethod]
public void InnerPowershellIndividualStepTest()
{
//Arrange
Conversion conversion = new Conversion();
string yaml = @"
- task: InlinePowershell@1
displayName: 'old Powershell task'
inputs:
Script: |
Write-Host 'Hello World'
Write-Host 'Hello World2'
";

//Act
ConversionResponse gitHubOutput = conversion.ConvertAzurePipelineTaskToGitHubActionTask(yaml);

//Assert
string expected = @"
- name: old Powershell task
run: |
Write-Host 'Hello World'
Write-Host 'Hello World2'
shell: powershell
";
expected = UtilityTests.TrimNewLines(expected);
Assert.AreEqual(expected, gitHubOutput.actionsYaml);
}

//[TestMethod]
//public void IISWebManagementStepTest()
//{
Expand Down

0 comments on commit 90cb9c1

Please sign in to comment.