Fixed error handling
This commit is contained in:
@@ -14,7 +14,7 @@ inputs:
|
||||
types:
|
||||
description: "Types of packages (e.g. Container, PyPi, NuGet)"
|
||||
required: false
|
||||
default: "Container,PyPi,NuGet"
|
||||
default: "container,pypi,nuget,npm"
|
||||
api_token:
|
||||
description: "API token for authentication"
|
||||
required: true
|
||||
|
||||
@@ -22,6 +22,29 @@ public class PackageFilterTests
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestPackageNameParsing()
|
||||
{
|
||||
var inputString =
|
||||
"@sh-edraft.de/core, sh-edraft.core.api, sh-edraft.core.api.auth, sh-edraft.core.api.configuration, sh-edraft.core.api.db, sh-edraft.core.api.graphql, sh-edraft.core.api.service, sh-edraft.core.utils";
|
||||
List<string> expected = [
|
||||
"@sh-edraft.de/core",
|
||||
"sh-edraft.core.api",
|
||||
"sh-edraft.core.api.auth",
|
||||
"sh-edraft.core.api.configuration",
|
||||
"sh-edraft.core.api.db",
|
||||
"sh-edraft.core.api.graphql",
|
||||
"sh-edraft.core.api.service",
|
||||
"sh-edraft.core.utils"
|
||||
];
|
||||
|
||||
var actual = inputString
|
||||
.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||
|
||||
Assert.Equal(expected.Count, actual.Length);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestFilterPackagesToDelete()
|
||||
{
|
||||
@@ -102,7 +125,26 @@ public class PackageFilterTests
|
||||
"2024.8.10.0-exp",
|
||||
"2024.8.10.1-exp",
|
||||
"2024.8.11.0-exp",
|
||||
"2024.8.11.2-exp"
|
||||
"2024.8.11.2-exp",
|
||||
"2026.2.21.27-dev",
|
||||
"2026.2.21.26-dev",
|
||||
"2026.2.21.25-dev",
|
||||
"2026.2.21.24-dev",
|
||||
"2026.2.21.23-dev",
|
||||
"2026.2.21.22-dev",
|
||||
"2026.2.21.21-dev",
|
||||
"2026.2.21.20-dev",
|
||||
"2026.2.21.19-dev",
|
||||
"2026.2.21.18-dev",
|
||||
"2026.2.21.17-dev",
|
||||
"2026.2.21.15-dev",
|
||||
"2026.2.21.14-dev",
|
||||
"2026.2.21.13-dev",
|
||||
"2026.2.21.12-dev",
|
||||
"2026.2.21.11-dev",
|
||||
"2026.2.21.10-dev",
|
||||
"2026.2.21.9-dev",
|
||||
"2026.2.21.8-dev",
|
||||
];
|
||||
|
||||
private readonly List<string> _versionsToHold =
|
||||
@@ -139,7 +181,9 @@ public class PackageFilterTests
|
||||
"0.1.1-exp",
|
||||
"0.1.2-exp",
|
||||
"2024.8.11.0-exp",
|
||||
"2024.8.11.2-exp"
|
||||
"2024.8.11.2-exp",
|
||||
"2026.2.21.27-dev",
|
||||
"2026.2.21.26-dev",
|
||||
];
|
||||
|
||||
private List<string> _expectDeleted => _versions.Except(_versionsToHold).ToList();
|
||||
|
||||
@@ -56,8 +56,12 @@ public class Worker(
|
||||
return;
|
||||
}
|
||||
|
||||
logger.LogInformation("Deleting {count} packages: {names}", names.Length, string.Join(", ", names));
|
||||
|
||||
// Process each name separately: collect -> filter -> delete
|
||||
foreach (var name in names)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogInformation("Processing packages for name '{Name}'", name);
|
||||
|
||||
@@ -73,6 +77,11 @@ public class Worker(
|
||||
|
||||
logger.LogInformation("Cleanup finished for name '{Name}'", name);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Failed to delete package {PackageName}", name);
|
||||
}
|
||||
}
|
||||
|
||||
logger.LogInformation("All package names processed successfully");
|
||||
}
|
||||
|
||||
4
sh.actions.sln.DotSettings.user
Normal file
4
sh.actions.sln.DotSettings.user
Normal file
@@ -0,0 +1,4 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=6fbf28ff_002Db08e_002D4d2b_002D8694_002D3f25abc9fe16/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from &lt;sh.actions.package-cleanup.Tests&gt;" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
|
||||
<Project Location="/home/sven/dev/git_sh-edraft_de/actions/sh.actions.package-cleanup.Tests" Presentation="&lt;sh.actions.package-cleanup.Tests&gt;" />
|
||||
</SessionState></s:String></wpf:ResourceDictionary>
|
||||
Reference in New Issue
Block a user