Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
58 changes: 58 additions & 0 deletions .github/workflows/cd-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,61 @@ jobs:

printf '%s\n' "version=$VERSION" >> $GITHUB_OUTPUT
printf '%s\n' "packages=$PACKAGES_JSON" >> $GITHUB_OUTPUT

integration-tests:
needs: validate-source
name: Integration Tests
runs-on: ubuntu-latest
env:
DOTNET_VERSION: ${{ vars.DOTNET_VERSION || '10.0.x' }}
SOLUTION_PATH: ${{ vars.SOLUTION_PATH }}

steps:
- uses: actions/checkout@v4

- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Configure GitHub packages
env:
NUGET_AUTH_TOKEN: ${{ secrets.PUBLISH_PAT }}
run: |
dotnet nuget add source \
"https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \
--name github \
--username "${{ github.actor }}" \
--password "$NUGET_AUTH_TOKEN" \
--store-password-in-clear-text

- name: Resolve RunSettings
id: runsettings
shell: bash
run: |
RUNSETTINGS="${{ vars.ITESTS_RUNSETTINGS_PATH }}"

if [ -n "$RUNSETTINGS" ] && [ -f "$RUNSETTINGS" ]; then
echo "Using repository RunSettings: $RUNSETTINGS"

echo "path=$RUNSETTINGS" >> $GITHUB_OUTPUT
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "Repository RunSettings not found"

EOF
echo "path=$GENERATED" >> $GITHUB_OUTPUT
echo "exists=false" >> $GITHUB_OUTPUT
fi

- name: Setup Databases
if: steps.runsettings.outputs.exists == 'false'
working-directory: ${{ env.SOLUTION_PATH }}
run: |
dotnet tool install --global csm_devkit


- name: Run integration tests
working-directory: ${{ env.SOLUTION_PATH }}/Integration Tests/
run: |
dotnet test --configuration Release --verbosity normal
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public abstract partial class DatabaseBase<TDatabase>
public virtual string Signature { get; protected set; } = "";

/// <inheritdoc/>
public virtual DatabaseProviders Provider { get; protected set; } = DatabaseProviders.PostgreSQL;
public virtual DatabaseProviders Provider { get; protected set; } = DatabaseProviders.PostgresSQL;

/// <summary>
/// Database model options.
Expand Down Expand Up @@ -140,24 +140,32 @@ protected EntityBase[] GetEntityModels() {
/// <inheritdoc/>
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
string connectionString = Options.ConnectionOptions!.ConnectionString;
string databaseProject = GetType().Assembly.GetName().Name!;

switch (Options.Provider) {
case DatabaseProviders.SQLServer:
optionsBuilder.UseSqlServer(
connectionString,
builder => {
if (Options.Migrations is not null) {
builder.MigrationsAssembly(Options.Migrations);

if(Options.Migrations != null)
builder.MigrationsAssembly(Options.Migrations);
else
builder.MigrationsAssembly($"{databaseProject}.{DatabaseProviders.SQLServer}");
}
}
);
break;
case DatabaseProviders.PostgreSQL:
case DatabaseProviders.PostgresSQL:
optionsBuilder.UseNpgsql(
connectionString,
builder => {
if(Options.Migrations is not null) {
builder.MigrationsAssembly(Options.Migrations);
if (Options.Migrations != null)
builder.MigrationsAssembly(Options.Migrations);
else
builder.MigrationsAssembly($"{databaseProject}.{DatabaseProviders.PostgresSQL}");
}
}
);
Expand Down Expand Up @@ -297,7 +305,7 @@ void CompleteOptions() {
Options.Signature ??= Signature;

// When current options provider is the default one.
if (Options.Provider == DatabaseProviders.PostgreSQL) {
if (Options.Provider == DatabaseProviders.PostgresSQL) {
Options.Provider = Provider;
}

Expand Down Expand Up @@ -353,4 +361,4 @@ public abstract partial class EntityBase {
/// Don't describe <see cref="IEntity"/> properties they are being auto-described by the [CSM] engine, <see cref="IEntity.Id"/>, <see cref="IEntity.Timestamp"/> and <see cref="IEntity.Name"/>.
/// </remarks>
protected internal virtual void DesignEntity(EntityTypeBuilder etBuilder) { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ public enum DatabaseProviders {
/// <summary>
/// Represents a PostgreSQL database provider.
/// </summary>
PostgreSQL,
PostgresSQL,
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public partial record DatabaseOptions<TDatabase>
/// <summary>
/// Database provider.
/// </summary>
public DatabaseProviders Provider { get; set; } = DatabaseProviders.PostgreSQL;
public DatabaseProviders Provider { get; set; } = DatabaseProviders.PostgresSQL;

/// <summary>
/// Whether the logging service is enabled.
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion csmpackage.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.0",
"version": "1.0.1",
"packages": [
"csharp_database_extension/CSharp Database Extension",
"csharp_database_extension/CSharp Database Extension Testing"
Expand Down
Loading