diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 18198a1..26798d9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,77 +2,12 @@ name: CI on: push: + branches: + - '**' # Ignores pushes of tags pull_request: workflow_dispatch: jobs: build: - runs-on: windows-latest # Use Ubuntu in v5.0 - - env: - DOTNET_NOLOGO: true - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Avoid pre-populating the NuGet package cache - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # all - - - name: Setup .NET 2.0 # Remove in v5.0 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 2.0.x - - - name: Setup .NET 8.0 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 8.0.x - - - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v0 - with: - versionSpec: '5.x' - - - name: Run GitVersion - id: gitversion - uses: gittools/actions/gitversion/execute@v0 - - - name: Display SemVer - run: | - echo "SemVer: $env:GitVersion_SemVer" - - - name: Add DbUp NuGet Source - run: dotnet nuget add source --name DbUp --username DbUp --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text https://nuget.pkg.github.com/DbUp/index.json - - - name: Restore - run: dotnet restore - working-directory: src - - - name: Build - run: dotnet build -c Release --no-restore /p:Version=$env:GitVersion_SemVer - working-directory: src - - - name: Test - run: dotnet test --no-build -c Release --logger trx --logger "console;verbosity=detailed" --results-directory ../artifacts - working-directory: src - - - name: Pack - run: dotnet pack --no-build -c Release -o ../artifacts /p:Version=$env:GitVersion_SemVer - working-directory: src - - - name: Push NuGet packages to GitHub Packages ⬆️ - working-directory: artifacts - run: dotnet nuget push *.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "https://nuget.pkg.github.com/DbUp/index.json" - - - name: Push NuGet packages to NuGet ⬆️ - if: ${{ steps.gitversion.outputs.preReleaseLabel == '' }} - working-directory: artifacts - run: dotnet nuget push *.nupkg --api-key ${{ secrets.NUGET_APIKEY }} --source https://api.nuget.org/v3/index.json - - - name: Test Report 🧪 - uses: dorny/test-reporter@v1 - if: ${{ always() }} - with: - name: Tests - path: artifacts/*.trx - reporter: dotnet-trx + name: Build + uses: DbUp/Universe/.github/workflows/build.yml@main diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 0000000..eb5e03f --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,12 @@ +name: Publish DbUp Packages to NuGet + +on: + release: + types: [ published ] + workflow_dispatch: + +jobs: + publish: + name: Publish Package + uses: DbUp/Universe/.github/workflows/publish-release.yml@main + secrets: inherit diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml new file mode 100644 index 0000000..e8c9f8f --- /dev/null +++ b/.github/workflows/test-report.yml @@ -0,0 +1,12 @@ +name: Test Report +run-name: Generate Test Report for run `${{ github.event.workflow_run.run_number }}` branch `${{ github.event.workflow_run.head_branch }}` + +on: + workflow_run: + workflows: ["CI", "build"] + types: [completed] + +jobs: + report: + name: Test Report 🧪 + uses: DbUp/Universe/.github/workflows/test-report.yml@main \ No newline at end of file diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 070fc1e..35884bc 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -10,18 +10,4 @@ latest true - - - - - true - - - true - - - embedded - - - diff --git a/src/Sample/Sample.csproj b/src/Sample/Sample.csproj index 3809095..7793a6a 100644 --- a/src/Sample/Sample.csproj +++ b/src/Sample/Sample.csproj @@ -1,13 +1,13 @@  - net7.0 + net8.0 Exe false - + diff --git a/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.verified.txt b/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.approved.txt similarity index 94% rename from src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.verified.txt rename to src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.approved.txt index dc21488..a7762ce 100644 --- a/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.verified.txt +++ b/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.approved.txt @@ -1,11 +1,11 @@ DB Operation: Open connection Info: Beginning database upgrade -Info: Checking whether journal table exists.. +Info: Checking whether journal table exists DB Operation: Execute scalar command: select 1 from RDB$RELATIONS where RDB$SYSTEM_FLAG = 0 and RDB$RELATION_NAME = 'schemaversions' DB Operation: Dispose command Info: Journal table does not exist Info: Executing Database Server script 'Script0001.sql' -Info: Checking whether journal table exists.. +Info: Checking whether journal table exists DB Operation: Execute scalar command: select 1 from RDB$RELATIONS where RDB$SYSTEM_FLAG = 0 and RDB$RELATION_NAME = 'schemaversions' DB Operation: Dispose command Info: Creating the "schemaversions" table diff --git a/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.verified.txt b/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.approved.txt similarity index 94% rename from src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.verified.txt rename to src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.approved.txt index c0696bf..d4bec87 100644 --- a/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.verified.txt +++ b/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.approved.txt @@ -1,11 +1,11 @@ DB Operation: Open connection Info: Beginning database upgrade -Info: Checking whether journal table exists.. +Info: Checking whether journal table exists DB Operation: Execute scalar command: select 1 from RDB$RELATIONS where RDB$SYSTEM_FLAG = 0 and RDB$RELATION_NAME = 'TestSchemaVersions' DB Operation: Dispose command Info: Journal table does not exist Info: Executing Database Server script 'Script0001.sql' -Info: Checking whether journal table exists.. +Info: Checking whether journal table exists DB Operation: Execute scalar command: select 1 from RDB$RELATIONS where RDB$SYSTEM_FLAG = 0 and RDB$RELATION_NAME = 'TestSchemaVersions' DB Operation: Dispose command Info: Creating the "TestSchemaVersions" table diff --git a/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.verified.txt b/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.approved.txt similarity index 94% rename from src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.verified.txt rename to src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.approved.txt index 1cbac5a..31f2661 100644 --- a/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.verified.txt +++ b/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.approved.txt @@ -1,11 +1,11 @@ DB Operation: Open connection Info: Beginning database upgrade -Info: Checking whether journal table exists.. +Info: Checking whether journal table exists DB Operation: Execute scalar command: select 1 from RDB$RELATIONS where RDB$SYSTEM_FLAG = 0 and RDB$RELATION_NAME = 'schemaversions' DB Operation: Dispose command Info: Journal table does not exist Info: Executing Database Server script 'Script0001.sql' -Info: Checking whether journal table exists.. +Info: Checking whether journal table exists DB Operation: Execute scalar command: select 1 from RDB$RELATIONS where RDB$SYSTEM_FLAG = 0 and RDB$RELATION_NAME = 'schemaversions' DB Operation: Dispose command Info: Creating the "schemaversions" table diff --git a/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.Net.verified.cs b/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.Net.verified.cs deleted file mode 100644 index d9d6dfa..0000000 --- a/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.Net.verified.cs +++ /dev/null @@ -1,45 +0,0 @@ -[assembly: System.CLSCompliantAttribute(true)] -[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)] - -public static class FirebirdExtensions -{ - public static DbUp.Builder.UpgradeEngineBuilder FirebirdDatabase(DbUp.Engine.Transactions.IConnectionManager connectionManager) { } - public static DbUp.Builder.UpgradeEngineBuilder FirebirdDatabase(this DbUp.Builder.SupportedDatabases supported, string connectionString) { } - public static DbUp.Builder.UpgradeEngineBuilder FirebirdDatabase(this DbUp.Builder.SupportedDatabases supported, DbUp.Engine.Transactions.IConnectionManager connectionManager) { } - public static void FirebirdDatabase(this DbUp.SupportedDatabasesForEnsureDatabase supported, string connectionString, DbUp.Engine.Output.IUpgradeLog logger = null) { } - public static void FirebirdDatabase(this DbUp.SupportedDatabasesForDropDatabase supported, string connectionString, DbUp.Engine.Output.IUpgradeLog logger = null) { } -} -namespace DbUp.Firebird -{ - public class FirebirdConnectionManager : DbUp.Engine.Transactions.DatabaseConnectionManager, DbUp.Engine.Transactions.IConnectionManager - { - public FirebirdConnectionManager(string connectionString) { } - protected override DbUp.Engine.Transactions.AllowedTransactionMode AllowedTransactionModes { get; } - public override System.Collections.Generic.IEnumerable SplitScriptIntoCommands(string scriptContents) { } - } - public class FirebirdObjectParser : DbUp.Support.SqlObjectParser, DbUp.Engine.ISqlObjectParser - { - public FirebirdObjectParser() { } - } - public class FirebirdPreprocessor : DbUp.Engine.IScriptPreprocessor - { - public FirebirdPreprocessor() { } - public string Process(string contents) { } - } - public class FirebirdScriptExecutor : DbUp.Support.ScriptExecutor, DbUp.Engine.IScriptExecutor - { - public FirebirdScriptExecutor(System.Func connectionManagerFactory, System.Func log, string schema, System.Func variablesEnabled, System.Collections.Generic.IEnumerable scriptPreprocessors, System.Func journal) { } - protected override bool UseTheSameTransactionForJournalTableAndScripts { get; } - protected override void ExecuteCommandsWithinExceptionHandler(int index, DbUp.Engine.SqlScript script, System.Action executeCommand) { } - protected override string GetVerifySchemaSql(string schema) { } - } - public class FirebirdTableJournal : DbUp.Support.TableJournal, DbUp.Engine.IJournal - { - public FirebirdTableJournal(System.Func connectionManager, System.Func logger, string tableName) { } - protected override string CreateSchemaTableSql(string quotedPrimaryKeyName) { } - protected override string DoesTableExistSql() { } - protected override string GetInsertJournalEntrySql(string scriptName, string applied) { } - protected override string GetJournalEntriesSql() { } - protected override void OnTableCreated(System.Func dbCommandFactory) { } - } -} diff --git a/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.DotNet.verified.cs b/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.approved.cs similarity index 100% rename from src/Tests/ApprovalFiles/NoPublicApiChanges.Run.DotNet.verified.cs rename to src/Tests/ApprovalFiles/NoPublicApiChanges.Run.approved.cs diff --git a/src/Tests/DatabaseSupportTests.cs b/src/Tests/DatabaseSupportTests.cs index e6a40ef..a0e5857 100644 --- a/src/Tests/DatabaseSupportTests.cs +++ b/src/Tests/DatabaseSupportTests.cs @@ -1,5 +1,4 @@ -#if !NETCORE -using DbUp.Builder; +using DbUp.Builder; using DbUp.Firebird; using DbUp.Tests.Common; @@ -20,4 +19,3 @@ protected override UpgradeEngineBuilder AddCustomNamedJournalToBuilder(UpgradeEn => new FirebirdTableJournal(connectionManagerFactory, logFactory, tableName) ); } -#endif diff --git a/src/Tests/NoPublicApiChanges.cs b/src/Tests/NoPublicApiChanges.cs index 3f3da54..dabb880 100644 --- a/src/Tests/NoPublicApiChanges.cs +++ b/src/Tests/NoPublicApiChanges.cs @@ -1,5 +1,4 @@ -#if !NETCORE -using DbUp.Tests.Common; +using DbUp.Tests.Common; namespace DbUp.Tests.Providers.Firebird; @@ -10,4 +9,3 @@ public NoPublicApiChanges() { } } -#endif diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj index ddb89dc..cb06322 100644 --- a/src/Tests/Tests.csproj +++ b/src/Tests/Tests.csproj @@ -1,19 +1,19 @@ - net462;net8 + net8 Tests DbUp.Firebird.Tests - + enable enable - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/dbup-firebird.sln.DotSettings b/src/dbup-firebird.sln.DotSettings index 2c78c0a..d3334fb 100644 --- a/src/dbup-firebird.sln.DotSettings +++ b/src/dbup-firebird.sln.DotSettings @@ -5,5 +5,8 @@ SQ <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> + True <data><IncludeFilters /><ExcludeFilters /></data> <data /> \ No newline at end of file diff --git a/src/dbup-firebird/FirebirdExtensions.cs b/src/dbup-firebird/FirebirdExtensions.cs index 35be25e..62d301c 100644 --- a/src/dbup-firebird/FirebirdExtensions.cs +++ b/src/dbup-firebird/FirebirdExtensions.cs @@ -82,11 +82,11 @@ public static void FirebirdDatabase(this SupportedDatabasesForEnsureDatabase sup if (!File.Exists(builder.Database)) { FbConnection.CreateDatabase(builder.ToString()); - logger.WriteInformation("Created database {0}", builder.Database); + logger.LogInformation("Created database {0}", builder.Database); } else { - logger.WriteInformation("Database {0} already exists", builder.Database); + logger.LogInformation("Database {0} already exists", builder.Database); } } else @@ -96,26 +96,26 @@ public static void FirebirdDatabase(this SupportedDatabasesForEnsureDatabase sup { conn.Open(); conn.Close(); - logger.WriteInformation("Database {0} already exists", builder.Database); + logger.LogInformation("Database {0} already exists", builder.Database); } catch (FbException ex) when (ex.ErrorCode == FbIoError) { FbConnection.CreateDatabase(builder.ToString()); - logger.WriteInformation("Created database {0}", builder.Database); + logger.LogInformation("Created database {0}", builder.Database); } catch (FbException ex) when (ex.ErrorCode == FbNetworkError) { - logger.WriteError("Could not access server. The server: {0} is probably not started.", builder.DataSource); + logger.LogError("Could not access server. The server: {0} is probably not started.", builder.DataSource); throw; } catch (FbException) { - logger.WriteError("Ensure Database: Unknown firebird error when trying to access the server: {0}.", builder.DataSource); + logger.LogError("Ensure Database: Unknown firebird error when trying to access the server: {0}.", builder.DataSource); throw; } catch (Exception) { - logger.WriteError("Ensure Database: Unknown error when trying to access the server: {0}.", builder.DataSource); + logger.LogError("Ensure Database: Unknown error when trying to access the server: {0}.", builder.DataSource); throw; } } @@ -140,7 +140,7 @@ public static void FirebirdDatabase(this SupportedDatabasesForDropDatabase suppo if (File.Exists(builder.Database)) { FbConnection.DropDatabase(builder.ToString()); - logger.WriteInformation("Dropped database {0}", builder.Database); + logger.LogInformation("Dropped database {0}", builder.Database); } } else @@ -150,25 +150,25 @@ public static void FirebirdDatabase(this SupportedDatabasesForDropDatabase suppo //There seems to be an error in the FirebirdClient when trying to drop a database that does not exist. //It gives a NullRefException instead of the expected FbException. FbConnection.DropDatabase(builder.ToString()); - logger.WriteInformation("Dropped database {0}", builder.Database); + logger.LogInformation("Dropped database {0}", builder.Database); } catch (FbException ex) when (ex.ErrorCode == FbIoError) { - logger.WriteWarning("Nothing to Drop. No database found."); + logger.LogWarning("Nothing to Drop. No database found."); } catch (FbException ex) when (ex.ErrorCode == FbLockTimeout) { - logger.WriteError("Can't drop database. Are there still an active connection?"); + logger.LogError("Can't drop database. Are there still an active connection?"); throw; } catch (FbException) { - logger.WriteError("Drop Database: Unknown firebird error when trying to access the server: {0}.", builder.DataSource); + logger.LogError("Drop Database: Unknown firebird error when trying to access the server: {0}.", builder.DataSource); throw; } catch (Exception) { - logger.WriteError("Drop Database: Unknown error when trying to access the server: {0}.", builder.DataSource); + logger.LogError("Drop Database: Unknown error when trying to access the server: {0}.", builder.DataSource); throw; } } diff --git a/src/dbup-firebird/FirebirdScriptExecutor.cs b/src/dbup-firebird/FirebirdScriptExecutor.cs index b336e7d..f8c01d3 100644 --- a/src/dbup-firebird/FirebirdScriptExecutor.cs +++ b/src/dbup-firebird/FirebirdScriptExecutor.cs @@ -47,9 +47,9 @@ protected override void ExecuteCommandsWithinExceptionHandler(int index, SqlScri } catch (FbException fbException) { - Log().WriteInformation("Firebird exception has occured in script: '{0}'", script.Name); - Log().WriteError("Script block number: {0}; Firebird error code: {1}; SQLSTATE {2}; Message: {3}", index, fbException.ErrorCode, fbException.SQLSTATE, fbException.Message); - Log().WriteError(fbException.ToString()); + Log().LogInformation("Firebird exception has occured in script: '{0}'", script.Name); + Log().LogError("Script block number: {0}; Firebird error code: {1}; SQLSTATE {2}; Message: {3}", index, fbException.ErrorCode, fbException.SQLSTATE, fbException.Message); + Log().LogError(fbException.ToString()); throw; } } diff --git a/src/dbup-firebird/FirebirdTableJournal.cs b/src/dbup-firebird/FirebirdTableJournal.cs index 9bcb5e2..8172e26 100644 --- a/src/dbup-firebird/FirebirdTableJournal.cs +++ b/src/dbup-firebird/FirebirdTableJournal.cs @@ -55,9 +55,9 @@ protected override void OnTableCreated(Func dbCommandFactory) { var unquotedTableName = UnquoteSqlObjectName(FqSchemaTableName); ExecuteCommand(dbCommandFactory, CreateGeneratorSql(unquotedTableName)); - Log().WriteInformation($"The {GeneratorName(unquotedTableName)} generator has been created"); + Log().LogInformation($"The {GeneratorName(unquotedTableName)} generator has been created"); ExecuteCommand(dbCommandFactory, CreateTriggerSql(unquotedTableName)); - Log().WriteInformation($"The {TriggerName(unquotedTableName)} trigger has been created"); + Log().LogInformation($"The {TriggerName(unquotedTableName)} trigger has been created"); } protected override string DoesTableExistSql() diff --git a/src/dbup-firebird/dbup-firebird.csproj b/src/dbup-firebird/dbup-firebird.csproj index f83dc8c..4c4c46c 100644 --- a/src/dbup-firebird/dbup-firebird.csproj +++ b/src/dbup-firebird/dbup-firebird.csproj @@ -6,7 +6,7 @@ DbUp Contributors DbUp Copyright © DbUp Contributors 2015 - net462;netstandard2.0 + netstandard2.0 dbup-firebird DbUp.Firebird dbup-firebird @@ -17,9 +17,15 @@ true + + true + true + embedded + + - - + +