diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 1ef2c6d..2ea40c8 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -15,12 +15,22 @@ jobs: services: mysql: + image: mysql:latest + env: + MYSQL_ALLOW_EMPTY_PASSWORD: yes + MYSQL_DATABASE: gangs + ports: + - 3306:3306 + options: --health-cmd "mysqladmin ping --silent" --health-interval 10s + + mariadb: image: mariadb:latest env: MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: yes MARIADB_DATABASE: gangs ports: - - 3306:3306 + - 3307:3306 + options: --health-cmd "mysqladmin ping --silent" --health-interval 10s steps: - uses: actions/checkout@v4 @@ -37,11 +47,19 @@ jobs: key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} restore-keys: | ${{ runner.os }}-nuget- + - name: Restore dependencies run: dotnet restore - name: Build run: dotnet build --no-restore - - name: Test - run: dotnet test GangsTest/GangsTest.csproj --no-build --verbosity normal \ No newline at end of file + - name: Test with MySQL + env: + DB_CONNECTION_STRING: "Server=localhost;Port=3306;Database=gangs;User=root" + run: dotnet test GangsTest/GangsTest.csproj --no-build --verbosity normal + + - name: Test with MariaDB + env: + DB_CONNECTION_STRING: "Server=localhost;Port=3307;Database=gangs;User=root" + run: dotnet test GangsTest/GangsTest.csproj --no-build --verbosity normal diff --git a/GangsTest/StatTests/StatManagerData.cs b/GangsTest/StatTests/StatManagerData.cs index 9b5baa6..09c4629 100644 --- a/GangsTest/StatTests/StatManagerData.cs +++ b/GangsTest/StatTests/StatManagerData.cs @@ -9,8 +9,9 @@ namespace GangsTest.StatTests; public class StatManagerData : IEnumerable { private readonly IBehavior[] behaviors = [ new MockStatManager(), - new SQLStatManager("Server=localhost;User=root;Database=gangs", - "gang_unit_test"), + new SQLStatManager( + Environment.GetEnvironmentVariable("DB_CONNECTION_STRING") + ?? "Server=localhost;User=root;Database=gangs", "gang_unit_test"), new SQLiteStatManager("Data Source=:memory:", "gang_unit_test") ];