Skip to content

Commit

Permalink
Fix and reenable unit tests (#231)
Browse files Browse the repository at this point in the history
* fix unit tests

* fixes

* fixes

* remove trim tests

* remove selfupdate tests
  • Loading branch information
ChristopherHX authored Oct 7, 2023
1 parent c9e57de commit 1e26222
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 1,173 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ jobs:
name: runner-package-${{ matrix.runtime }}
path: |
_package
- name: Unit Tests
if: matrix.runtime != 'linux-arm64' && matrix.runtime != 'linux-arm' && matrix.runtime != 'osx-arm64'
run: |
${{ matrix.devScript }} test
working-directory: src

- name: Setup
if: 'false' # Disabled due to 403 of statuses api with this token and rate limit
shell: pwsh
Expand Down
2 changes: 0 additions & 2 deletions src/ActionsRunner.sln
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runner.Server", "Runner.Ser
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runner.Client", "Runner.Client\Runner.Client.csproj", "{20089019-022B-48F6-85A4-A524D7E8161D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "azuredevopsutility", "azuredevopsutility\azuredevopsutility.csproj", "{911D4E90-F306-4B56-87DD-A2642EB0BA95}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
2 changes: 1 addition & 1 deletion src/Runner.Worker/ActionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public Definition LoadAction(IExecutionContext executionContext, Pipelines.Actio
var repoAction = action.Reference as Pipelines.RepositoryPathReference;
if (string.Equals(repoAction.RepositoryType, Pipelines.PipelineConstants.SelfAlias, StringComparison.OrdinalIgnoreCase))
{
if(Path.IsPathFullyQualified(repoAction.Path)) {
if(!string.IsNullOrEmpty(repoAction?.Path) && Path.IsPathFullyQualified(repoAction.Path)) {
actionDirectory = repoAction.Path;
} else {
actionDirectory = executionContext.GetGitHubContext("workspace");
Expand Down
4 changes: 2 additions & 2 deletions src/Runner.Worker/Container/ContainerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public string TranslateToContainerPath(string path)
{
if (!string.IsNullOrEmpty(path))
{
foreach (var mapping in _pathMappings.Concat(_osPathMappings[Os]))
foreach (var mapping in _pathMappings.Concat(_osPathMappings[Os ?? "linux"]))
{
if(System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) {
var hostPath = path.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
Expand Down Expand Up @@ -194,7 +194,7 @@ public string TranslateToHostPath(string path)
{
if (!string.IsNullOrEmpty(path))
{
foreach (var mapping in _pathMappings.Concat(_osPathMappings[Os]))
foreach (var mapping in _pathMappings.Concat(_osPathMappings[Os ?? "linux"]))
{
if(System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) {
var comp = Os == "windows" ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
Expand Down
799 changes: 0 additions & 799 deletions src/Test/L0/Listener/SelfUpdaterL0.cs

This file was deleted.

277 changes: 0 additions & 277 deletions src/Test/L0/PackagesTrimL0.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Test/L0/Worker/ActionCommandManagerL0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public void AddMatcherTranslatesFilePath()
// Setup translation info
var container = new ContainerInfo();
var containerDirectory = "/some-container-directory";
var containerFile = Path.Combine(containerDirectory, "my-matcher.json");
var containerFile = $"{containerDirectory}/my-matcher.json";
container.AddPathTranslateMapping(hostDirectory, containerDirectory);

// Act
Expand Down
25 changes: 0 additions & 25 deletions src/Test/L0/Worker/ActionManifestManagerL0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -741,31 +741,6 @@ public void Load_ConditionalCompositeAction()
}
}

[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void Load_CompositeActionNoUsing()
{
try
{
//Arrange
Setup();

var actionManifest = new ActionManifestManager();
actionManifest.Initialize(_hc);
var action_path = Path.Combine(TestUtil.GetTestDataPath(), "composite_action_without_using_token.yml");

//Assert
var err = Assert.Throws<ArgumentException>(() => actionManifest.Load(_ec.Object, action_path));
Assert.Contains($"Fail to load {action_path}", err.Message);
_ec.Verify(x => x.AddIssue(It.Is<Issue>(s => s.Message.Contains("Missing 'using' value. 'using' requires 'composite', 'docker', 'node12', 'node16' or 'node20'.")), It.IsAny<ExecutionContextLogOptions>()), Times.Once);
}
finally
{
Teardown();
}
}

[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
Expand Down
1 change: 1 addition & 0 deletions src/Test/L0/Worker/ActionRunnerL0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ private void Setup([CallerMemberName] string name = "")
#else
_context["env"] = new CaseSensitiveDictionaryContextData();
#endif
_context["vars"] = new DictionaryContextData();

_ec = new Mock<IExecutionContext>();
_ec.Setup(x => x.Global).Returns(new GlobalContext());
Expand Down
Loading

0 comments on commit 1e26222

Please sign in to comment.