Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a289481
Refactor Docker container management to use Testcontainers
glucaci Dec 23, 2025
cb37705
chore: add nuget.config and update xunit.runner.visualstudio reference
glucaci Dec 23, 2025
23ff843
fix: correct property name for test build configuration in all.csproj…
glucaci Dec 23, 2025
481b7be
fix: correct typo in test command parameter in CI workflow
glucaci Dec 23, 2025
2422ca4
chore: add concurrency settings to CI workflow
glucaci Dec 23, 2025
e6d2b08
refactor: remove Docker registry configuration and related authentica…
glucaci Dec 23, 2025
4743b63
fix: remove unnecessary registry configuration from TestWebServerOptions
glucaci Dec 23, 2025
dc21a00
fix: trim leading slash from container name in PopulateInstanceDetail…
glucaci Dec 23, 2025
d355d90
fix: correct port mapping order in ConfigurePortBindings method
glucaci Dec 23, 2025
9d94d9d
refactor: enhance CI workflow to dynamically discover and build test …
glucaci Dec 23, 2025
91d3515
fix: downgrade xunit.runner.visualstudio to version 2.8.2
glucaci Dec 23, 2025
3229149
refactor: enhance test project discovery in CI workflow with improved…
glucaci Dec 23, 2025
3def98b
refactor: simplify test project discovery logic in CI workflow
glucaci Dec 23, 2025
1e137e8
fix: remove unnecessary build dependency from tests job in CI workflow
glucaci Dec 23, 2025
bbf9ea9
refactor: add dynamic naming for test jobs in CI workflow
glucaci Dec 23, 2025
c0aea06
fix: remove unnecessary --no-build option from test command in CI wor…
glucaci Dec 23, 2025
52a6a36
refactor: enhance InvokeCommandAsync with retry support and update us…
glucaci Dec 23, 2025
797c9cd
fix: add timeout to tests job in CI workflow
glucaci Dec 23, 2025
dfa63bf
fix: correct resource name for embedded files and add error handling …
glucaci Dec 23, 2025
e3bbd34
fix: set world-readable permissions when copying files to container
glucaci Dec 23, 2025
938758e
refactor: streamline CI workflow by removing discover-tests job and u…
glucaci Dec 24, 2025
70707d6
refactor: update CI workflow to use matrix strategy for .NET versions…
glucaci Dec 24, 2025
e6b4ba8
chore: add emoji to run-name for CI and Release workflows
glucaci Dec 24, 2025
b575cd1
fix: correct resource name for embedded files and ensure proper error…
glucaci Dec 25, 2025
5e129e8
refactor: remove legacy xunit.runner.json files and update project re…
glucaci Dec 25, 2025
98b2c36
fix: increase CI job timeout and refine test command for better perfo…
glucaci Dec 25, 2025
b58b059
fix: add RootNamespace to test project files for consistency
glucaci Dec 25, 2025
0149efe
fix: specify target framework for build and test commands in CI workflow
glucaci Dec 25, 2025
5b79444
refactor: simplify Docker configuration handling and remove unused code
glucaci Dec 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
name: CI
run-name: CI ${{ github.event.pull_request.title }}
run-name: CI 🔍 ${{ github.event.pull_request.title }}

on:
pull_request:

concurrency:
group: ci-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
tests:
runs-on: ubuntu-latest
name: Tests dotnet ${{ matrix.dotnet-version }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
dotnet-version: [8, 9, 10]
steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8
9
10
dotnet-version: ${{ matrix.dotnet-version }}

- name: Docker Information
run: |
Expand All @@ -28,9 +35,9 @@ jobs:
shell: bash

- name: Build projects
run: dotnet build ./all.csproj
shell: bash
run: dotnet build ./all.csproj -f net${{ matrix.dotnet-version }}.0

- name: Run tests
run: dotnet test ./all.csproj /p:BuildTestOnly=true
shell: bash
shell: bash
run: dotnet test ./all.csproj /p:BuildTestsOnly=true --no-build -f net${{ matrix.dotnet-version }}.0 -- RunConfiguration.MaxCpuCount=1
21 changes: 11 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Release
run-name: Release ${{ github.ref_name }}
run-name: Release 🚀 ${{ github.ref_name }}

on:
push:
Expand All @@ -9,17 +9,20 @@ on:
jobs:
release:
runs-on: ubuntu-latest
strategy:
matrix:
project: ['.']
steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8
9
10

- name: Build projects
shell: bash
working-directory: ${{ matrix.project }}
run: dotnet build ./all.csproj -c Release

- name: Extract version
id: extract_version
Expand All @@ -32,12 +35,9 @@ jobs:
echo "Package Version: $PACKAGE_VERSION"
echo "Assembly Version: $ASSEMBLY_VERSION"

- name: Build projects
shell: bash
run: dotnet build ./all.csproj -c Release

- name: Pack
shell: bash
working-directory: ${{ matrix.project }}
run: |
dotnet pack ./all.csproj \
-c Release \
Expand All @@ -52,5 +52,6 @@ jobs:

- name: Push
shell: bash
working-directory: ${{ matrix.project }}
run: |
find . -name '*.nupkg' | grep -v '.sources.nupkg' | parallel --jobs 0 'dotnet nuget push {} --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json'
16 changes: 11 additions & 5 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.core" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="FluentAssertions" Version="7.2.0" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
Expand All @@ -50,10 +50,16 @@

<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="5.0.0" />

<PackageVersion Include="Docker.DotNet.Enhanced" Version="3.131.0" />
<PackageVersion Include="Testcontainers" Version="4.3.0" />
<PackageVersion Include="Testcontainers.MongoDb" Version="4.3.0" />
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.3.0" />
<PackageVersion Include="Testcontainers.Redis" Version="4.3.0" />
<PackageVersion Include="Testcontainers.RabbitMq" Version="4.3.0" />
<PackageVersion Include="Testcontainers.MySql" Version="4.3.0" />
<PackageVersion Include="Testcontainers.MsSql" Version="4.3.0" />
<PackageVersion Include="Testcontainers.Elasticsearch" Version="4.3.0" />
<PackageVersion Include="Testcontainers.MariaDb" Version="4.3.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="Polly" Version="8.5.2" />
<PackageVersion Include="SharpZipLib" Version="1.4.2" />

<PackageVersion Include="MongoDB.Driver" Version="3.0.0" />
<PackageVersion Include="MySqlConnector" Version="2.4.0" />
Expand Down Expand Up @@ -83,7 +89,7 @@
<PackageVersion Include="Typesense" Version="7.33.0" />

<PackageVersion Include="FluentFTP" Version="35.0.4" />
<PackageVersion Include="SSH.NET" Version="2023.0.0" />
<PackageVersion Include="SSH.NET" Version="2024.2.0" />


<PackageVersion Include="ServiceStack.Text" Version="8.8.0" />
Expand Down
10 changes: 5 additions & 5 deletions all.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.Build.Traversal/4.1.82">

<PropertyGroup>
<BuildTestOnly>false</BuildTestOnly>
<BuildTestsOnly>false</BuildTestsOnly>
<IncludeInSolutionFile>false</IncludeInSolutionFile>
</PropertyGroup>

<ItemGroup Condition="$(BuildTestOnly) != 'true'">
<ItemGroup Condition="'$(BuildTestsOnly)' != 'true'">
<ProjectReference Include="**/*.csproj" />
</ItemGroup>

<ItemGroup Condition="$(BuildTestOnly) != 'true'">
<ProjectReference Include="**/test/*.csproj" />
<ItemGroup Condition="'$(BuildTestsOnly)' == 'true'">
<ProjectReference Include="**/test/**/*.csproj" />
</ItemGroup>

</Project>
</Project>
7 changes: 7 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
22 changes: 6 additions & 16 deletions src/Core/ChmodCommand.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

using System;
using Docker.DotNet.Models;

namespace Squadron;

Expand All @@ -17,36 +16,27 @@ public static class ChmodCommand
/// <param name="group"><see cref="Permission"/> for group</param>
/// <param name="public"><see cref="Permission"/> for public</param>
/// <param name="recursive">Apply recursive</param>
public static ContainerExecCreateParameters Set(
public static string[] Set(
string pathInContainer,
Permission owner = Permission.None,
Permission group = Permission.None,
Permission @public = Permission.None,
bool recursive = false)
{
var cmd = $"chmod {(recursive ? "-R " : "")}{owner:d}{group:d}{@public:d} {pathInContainer}";

return new ContainerExecCreateParameters
{
AttachStderr = true,
AttachStdin = false,
AttachStdout = true,
Cmd = cmd.Split(' '),
Privileged = true,
User = "root"
};
return cmd.Split(' ');
}

public static ContainerExecCreateParameters ReadOnly(string pathInContainer, bool recursive = false)
public static string[] ReadOnly(string pathInContainer, bool recursive = false)
=> Set(pathInContainer, Permission.Read, Permission.Read, Permission.Read, recursive);

public static ContainerExecCreateParameters FullAccess(string pathInContainer, bool recursive = false)
public static string[] FullAccess(string pathInContainer, bool recursive = false)
=> Set(pathInContainer, Permission.FullAccess, Permission.FullAccess, Permission.FullAccess, recursive);

public static ContainerExecCreateParameters Execute(string pathInContainer, bool recursive = false)
public static string[] Execute(string pathInContainer, bool recursive = false)
=> Set(pathInContainer, Permission.Execute, Permission.Execute, Permission.Execute, recursive);

public static ContainerExecCreateParameters ReadWrite(string pathInContainer, bool recursive = false)
public static string[] ReadWrite(string pathInContainer, bool recursive = false)
=> Set(pathInContainer, Permission.ReadWrite, Permission.ReadWrite, Permission.ReadWrite, recursive);

[Flags]
Expand Down
7 changes: 1 addition & 6 deletions src/Core/ContainerInstance.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using Docker.DotNet;

namespace Squadron;

/// <summary>Respresents a created docker container</summary>
/// <summary>Represents a created docker container</summary>
public class ContainerInstance : IDisposable
{
/// <summary>
Expand Down Expand Up @@ -67,10 +65,7 @@ public class ContainerInstance : IDisposable
/// </value>
public IList<string> Logs { get; set; } = new List<string>();

internal MultiplexedStream? LogStream { get; set; }

public void Dispose()
{
LogStream?.Dispose();
}
}
4 changes: 1 addition & 3 deletions src/Core/ContainerResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ protected virtual void SetupContainerResource()
OnSettingsBuilded(Settings);
ValidateSettings(Settings);

DockerConfiguration dockerConfig = Settings.DockerConfigResolver();

Manager = new DockerContainerManager(Settings, dockerConfig);
Manager = new TestcontainersDockerManager(Settings);
Initializer = new ContainerInitializer(Manager, Settings);
}

Expand Down
31 changes: 0 additions & 31 deletions src/Core/ContainerResourceBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,6 @@ public ContainerResourceBuilder Image(string image)
return this;
}

/// <summary>
/// Container registry name as defined in configurations
/// Default is DockerHub
/// </summary>
/// <param name="registryName">Name of the registry.</param>
/// <returns></returns>
public ContainerResourceBuilder Registry(string registryName)
{
_options.RegistryName = registryName;
return this;
}

public ContainerResourceBuilder AddressMode(ContainerAddressMode mode)
{
_options.AddressMode = mode;
return this;
}

/// <summary>
/// Adds an environment variable.
/// </summary>
Expand Down Expand Up @@ -342,18 +324,6 @@ public ContainerResourceBuilder WaitTimeout(int seconds)
return this;
}

/// <summary>
/// Sets the docker configuration resolver.
/// </summary>
/// <param name="resolver">The resolver.</param>
/// <returns></returns>
public ContainerResourceBuilder SetDockerConfigResolver(
Func<DockerConfiguration> resolver)
{
_options.DockerConfigResolver = resolver;
return this;
}

/// <summary>
/// Adds a network of which the container should be part of.
/// </summary>
Expand Down Expand Up @@ -420,7 +390,6 @@ public virtual ContainerResourceSettings Build()
_logLevel = overriddenLogLevel;
}

_options.DockerConfigResolver ??= ContainerResourceOptions.DefaultDockerConfigResolver;
_options.Logger = new Logger(_logLevel, _options);
_options.Cmd = _cmd;
return _options;
Expand Down
Loading
Loading