Skip to content

Commit

Permalink
Add debug logging via newer CICD package + fix for GitHub (#40)
Browse files Browse the repository at this point in the history
* Add logging argument & update of CICD package

* Add debug option

* Update of CICD package with possible fix

* Prepare for release and update to released CICD package
  • Loading branch information
MichielOda authored Aug 7, 2023
1 parent 6b8a89a commit 9aff7a7
Show file tree
Hide file tree
Showing 10 changed files with 327 additions and 206 deletions.
5 changes: 5 additions & 0 deletions Actions/Dockerfile/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ inputs:
build-number:
description: 'The build number of a workflow run. Only required for a development run. Required for stages Upload and All if no version was provided instead.'
required: false
debug:
description: 'Option to enable debug logging. Optional'
required: false
outputs:
artifact-id:
description: 'The artifact Id of the artifact has been uploaded'
Expand All @@ -56,5 +59,7 @@ runs:
- ${{ inputs.artifact-id }}
- --build-number
- ${{ inputs.build-number }}
- --debug
- ${{ inputs.debug }}


160 changes: 124 additions & 36 deletions GitHubAction/GitHubAction.UnitTest/ParseInputsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ public void ParseAndValidateInputs_HappyFlow_All_Release()
"--artifact-id",
artifactId,
"--base-path",
""
};
"",
"--debug",
"false"
};

// When
var inputs = _inputParserService.ParseAndValidateInputs(args)!;
Expand All @@ -79,6 +81,7 @@ public void ParseAndValidateInputs_HappyFlow_All_Release()
Assert.AreEqual(TimeSpan.FromSeconds(int.Parse(timeOut)), inputs.TimeOut);
Assert.AreEqual(Enum.Parse<Stage>(stage), inputs.Stage);
Assert.IsNull(inputs.ArtifactId);
Assert.IsFalse(inputs.Debug);
}

[Test]
Expand Down Expand Up @@ -110,8 +113,10 @@ public void ParseAndValidateInputs_HappyFlow_Upload_Release()
"--artifact-id",
artifactId,
"--base-path",
""
};
"",
"--debug",
"false"
};

// When
var inputs = _inputParserService.ParseAndValidateInputs(args)!;
Expand All @@ -128,6 +133,7 @@ public void ParseAndValidateInputs_HappyFlow_Upload_Release()
Assert.AreEqual(TimeSpan.FromSeconds(int.Parse(timeOut)), inputs.TimeOut);
Assert.AreEqual(Enum.Parse<Stage>(stage), inputs.Stage);
Assert.IsNull(inputs.ArtifactId);
Assert.IsFalse(inputs.Debug);
}


Expand Down Expand Up @@ -160,7 +166,9 @@ public void ParseAndValidateInputs_HappyFlow_All_Development()
"--artifact-id",
artifactId,
"--base-path",
""
"",
"--debug",
"false"
};

// When
Expand All @@ -177,6 +185,7 @@ public void ParseAndValidateInputs_HappyFlow_All_Development()
Assert.AreEqual(buildNumber, inputs.BuildNumber);
Assert.AreEqual(TimeSpan.FromSeconds(int.Parse(timeOut)), inputs.TimeOut);
Assert.AreEqual(Enum.Parse<Stage>(stage), inputs.Stage);
Assert.IsFalse(inputs.Debug);
Assert.IsNull(inputs.ArtifactId);
}

Expand Down Expand Up @@ -209,8 +218,10 @@ public void ParseAndValidateInputs_HappyFlow_Upload_Development()
"--artifact-id",
artifactId,
"--base-path",
""
};
"",
"--debug",
"true"
};

// When
var inputs = _inputParserService.ParseAndValidateInputs(args)!;
Expand All @@ -226,6 +237,7 @@ public void ParseAndValidateInputs_HappyFlow_Upload_Development()
Assert.AreEqual(buildNumber, inputs.BuildNumber);
Assert.AreEqual(TimeSpan.FromSeconds(int.Parse(timeOut)), inputs.TimeOut);
Assert.AreEqual(Enum.Parse<Stage>(stage), inputs.Stage);
Assert.IsTrue(inputs.Debug);
Assert.IsNull(inputs.ArtifactId);
}

Expand Down Expand Up @@ -260,8 +272,10 @@ public void ParseAndValidateInputs_HappyFlow_Deploy()
"--artifact-id",
artifactId,
"--base-path",
""
};
"",
"--debug",
"BLA"
};

// When
var inputs = _inputParserService.ParseAndValidateInputs(args)!;
Expand All @@ -278,6 +292,7 @@ public void ParseAndValidateInputs_HappyFlow_Deploy()
Assert.AreEqual(TimeSpan.FromSeconds(int.Parse(timeOut)), inputs.TimeOut);
Assert.AreEqual(Enum.Parse<Stage>(stage), inputs.Stage);
Assert.AreEqual(artifactId, inputs.ArtifactId);
Assert.IsFalse(inputs.Debug);
}

[Test]
Expand Down Expand Up @@ -318,8 +333,10 @@ public void ParseAndValidateInputs_EmptyStage()
"--artifact-id",
artifactId,
"--base-path",
""
};
"",
"--debug",
"false"
};

// When
var inputs = _inputParserService.ParseAndValidateInputs(args)!;
Expand All @@ -330,12 +347,59 @@ public void ParseAndValidateInputs_EmptyStage()
_inputParserPresenterMock.VerifyNoOtherCalls();

Assert.IsNull(inputs);
}
}

[Test]
[TestCase("All")]
[TestCase("Upload")]
[TestCase("Deploy")]
public void ParseAndValidateInputs_EmptyDebug(string stage)
{
// Given
var key = "some key";
var solutionFile = "solution-path";
var packageName = "TestPackage";
var version = "1.0.2";
var timeOut = "900";
var artifactId = "some string";

var args = new string[]
{
"--api-key",
key,
"--solution-path",
solutionFile,
"--artifact-name",
packageName,
"--version",
version,
"--timeout",
timeOut,
"--stage",
stage,
"--artifact-id",
artifactId,
"--base-path",
"",
"--debug",
""
};

// When
var inputs = _inputParserService.ParseAndValidateInputs(args)!;

// Then
_inputParserPresenterMock.Verify(p => p.PresentMissingArgument(InputArgurments.Debug), Times.Once);
_inputParserPresenterMock.Verify(p => p.PresentLogging(It.IsAny<string>()), Times.AtMost(100));
_inputParserPresenterMock.VerifyNoOtherCalls();

Assert.IsNull(inputs);
}

[Test]
[TestCase("All")]
[TestCase("Upload")]
[TestCase("Deploy")]
public void ParseAndValidateInputs_EmptyApiKey(string stage)
{
// Given
Expand Down Expand Up @@ -363,8 +427,10 @@ public void ParseAndValidateInputs_EmptyApiKey(string stage)
"--artifact-id",
artifactId,
"--base-path",
""
};
"",
"--debug",
"false"
};

// When
var inputs = _inputParserService.ParseAndValidateInputs(args)!;
Expand Down Expand Up @@ -408,8 +474,10 @@ public void ParseAndValidateInputs_EmptyTimeOut(string stage)
"--artifact-id",
artifactId,
"--base-path",
""
};
"",
"--debug",
"false"
};

// When
var inputs = _inputParserService.ParseAndValidateInputs(args)!;
Expand Down Expand Up @@ -453,8 +521,10 @@ public void ParseAndValidateInputs_EmptySolutionFile(string stage, bool required
"--artifact-id",
artifactId,
"--base-path",
""
};
"",
"--debug",
"false"
};

// When
var inputs = _inputParserService.ParseAndValidateInputs(args)!;
Expand Down Expand Up @@ -506,8 +576,10 @@ public void ParseAndValidateInputs_EmptyPackageName(string stage, bool required)
"--artifact-id",
artifactId,
"--base-path",
""
};
"",
"--debug",
"false"
};

// When
var inputs = _inputParserService.ParseAndValidateInputs(args)!;
Expand Down Expand Up @@ -558,8 +630,10 @@ public void ParseAndValidateInputs_EmptyVersionAndBuildNumber(string stage, bool
"--artifact-id",
artifactId,
"--base-path",
""
};
"",
"--debug",
"false"
};

// When
var inputs = _inputParserService.ParseAndValidateInputs(args)!;
Expand Down Expand Up @@ -608,8 +682,10 @@ public void ParseAndValidateInputs_InvalidTimeOut_NotAValidInt()
"--artifact-id",
artifactId,
"--base-path",
""
};
"",
"--debug",
"false"
};

// When
var inputs = _inputParserService.ParseAndValidateInputs(args)!;
Expand Down Expand Up @@ -651,8 +727,10 @@ public void ParseAndValidateInputs_InvalidTimeOut_ToLow()
"--artifact-id",
artifactId,
"--base-path",
""
};
"",
"--debug",
"false"
};

// When
var inputs = _inputParserService.ParseAndValidateInputs(args)!;
Expand Down Expand Up @@ -694,8 +772,10 @@ public void ParseAndValidateInputs_InvalidTimeOut_ToHigh()
"--artifact-id",
artifactId,
"--base-path",
""
};
"",
"--debug",
"false"
};

// When
var inputs = _inputParserService.ParseAndValidateInputs(args)!;
Expand Down Expand Up @@ -739,8 +819,10 @@ public void ParseAndValidateInputs_EmptyArtifactId(string stage, bool required)
"--artifact-id",
artifactId,
"--base-path",
""
};
"",
"--debug",
"false"
};

// When
var inputs = _inputParserService.ParseAndValidateInputs(args)!;
Expand Down Expand Up @@ -791,8 +873,10 @@ public void ParseAndValidateInputs_InvalidArgument()
"--base-path",
"",
"--some-unknown-key",
""
};
"",
"--debug",
"false"
};

// When
var inputs = _inputParserService.ParseAndValidateInputs(args)!;
Expand Down Expand Up @@ -832,8 +916,10 @@ public void ParseAndValidateInputs_MissingArgument()
"--stage",
stage,
"--base-path",
""
};
"",
"--debug",
"false"
};

// When
var inputs = _inputParserService.ParseAndValidateInputs(args)!;
Expand Down Expand Up @@ -875,8 +961,10 @@ public void ParseAndValidateInputs_InvalidStage()
"--artifact-id",
"",
"--base-path",
""
};
"",
"--debug",
"false"
};

// When
var inputs = _inputParserService.ParseAndValidateInputs(args)!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ public static class InputArgurments
public const string Stage = "stage";
public const string Timeout = "timeout";
public const string Version = "version";
public const string Debug = "debug";
}
2 changes: 2 additions & 0 deletions GitHubAction/GitHubAction.domain/Entities/Inputs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ public class Inputs
public string? ArtifactId { get; init; }

public string? BuildNumber { get; init; }

public bool? Debug { get; init; }
}
Loading

0 comments on commit 9aff7a7

Please sign in to comment.