Skip to content

Commit 1b63945

Browse files
committed
add delete container logic before every functional tests
1 parent 1e7ffc5 commit 1b63945

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

build/LocalStack.Build/LocalStack.Build.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<NoWarn>CA1303</NoWarn>
88
</PropertyGroup>
99
<ItemGroup>
10+
<PackageReference Include="Cake.Docker" Version="1.0.0" />
1011
<PackageReference Include="Cake.Frosting" Version="1.3.0" />
1112
</ItemGroup>
1213
</Project>

build/LocalStack.Build/Program.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
return new CakeHost()
1+
using Cake.Docker;
2+
3+
return new CakeHost()
24
.UseContext<BuildContext>()
35
.Run(args);
46

@@ -84,6 +86,29 @@ public override void Run(BuildContext context)
8486
context.Warning($"=============Running {targetFramework.ToUpper()} tests for {testProj.AssemblyName}=============");
8587
settings.Framework = targetFramework;
8688

89+
if (testProj.AssemblyName == "LocalStack.Client.Functional.Tests")
90+
{
91+
context.Warning("Deleting running docker containers");
92+
93+
try
94+
{
95+
string psOutput = context.DockerPs(new DockerContainerPsSettings() { All = true, Quiet = true});
96+
97+
if (!string.IsNullOrEmpty(psOutput))
98+
{
99+
context.Warning(psOutput);
100+
101+
string[] containers = psOutput.Split(new[]{ Environment.NewLine }, StringSplitOptions.None);
102+
context.DockerRm(containers);
103+
}
104+
}
105+
catch
106+
{
107+
// ignored
108+
}
109+
}
110+
111+
87112
if (context.IsRunningOnUnix() && targetFramework == "net461")
88113
{
89114
context.RunXUnitUsingMono(targetFramework, $"{testProj.DirectoryPath}/bin/{context.BuildConfiguration}/{targetFramework}/{testProj.AssemblyName}.dll");

0 commit comments

Comments
 (0)