Skip to content

Commit

Permalink
Use reusable workflow for build (#13)
Browse files Browse the repository at this point in the history
* Only target netstandard 2.0

* Removed install of net 2.0

* Moved CI optimisations into just the main project

* Fix Readme and template

* Build on Ubuntu (#12)

* Build on Ubuntu

* Used bash variables

* Used re-usable workflow

* Specified the branch

* Used .github/workflow/ path for workflows

* Fix name

* Used root workflow folder

* passed secret explicitly

* fix

* Not pass secret

* Changed branch
  • Loading branch information
droyad authored Mar 20, 2024
1 parent d0130b5 commit 5997347
Show file tree
Hide file tree
Showing 21 changed files with 92 additions and 220 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Checklist
- [ ] I have read the [Contributing Guide](https://github.com/DbUp/DbUp/blob/master/CONTRIBUTING.md)
- [ ] I have read the [Contributing Guide](https://github.com/DbUp/DbUp/blob/main/CONTRIBUTING.md)
- [ ] I have checked to ensure this does not introduce an unintended breaking changes
- [ ] I have considered appropriate testing for my change

Expand Down
71 changes: 2 additions & 69 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,72 +7,5 @@ on:

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@reusable
11 changes: 11 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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@reusable
13 changes: 13 additions & 0 deletions .github/workflows/test-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Test Report
run-name: Generate Test Report for workflow ${{ github.event.workflow_run.name }} run ${{ github.event.workflow_run.run_number }} branch ${{ github.event.workflow_run.head_branch }}

on:
workflow_run:
workflows: [ "CI" ]
types:
- completed

jobs:
report:
name: Test Report 🧪
uses: DbUp/Universe/.github/workflows/test-report.yml@reusable
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Please only log issue related to MySql support in this repo. For cross cutting i

# Contributing

See the [readme in our main repo](https://github.com/DbUp/DbUp/blob/master/README.md) for how to get started and contribute.
See the [readme in our main repo](https://github.com/DbUp/DbUp/blob/main/README.md) for how to get started and contribute.
13 changes: 0 additions & 13 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,4 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup Condition="'$(TF_BUILD)' == 'true' Or '$(CI)' == 'true'">

<!-- Perform a deterministic build, so our binaries aren't impacted by build server environmental factors (e.g. file paths). -->
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>

<!-- Embed source files that are not tracked by the source control manager in the PDB -->
<EmbedUntrackedSources>true</EmbedUntrackedSources>

<!-- Recommended: Embed symbols containing Source Link in the main file (exe/dll) -->
<DebugType>embedded</DebugType>

</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
DB Operation: Open connection
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 INFORMATION_SCHEMA.TABLES where TABLE_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 INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
DB Operation: Dispose command
Info: Creating the `schemaversions` table
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
DB Operation: Open connection
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 INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'TestSchemaVersions' and TABLE_SCHEMA = 'test'
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 INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'TestSchemaVersions' and TABLE_SCHEMA = 'test'
DB Operation: Dispose command
Info: Creating the `test`.`TestSchemaVersions` table
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
DB Operation: Open connection
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 INFORMATION_SCHEMA.TABLES where TABLE_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 INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
DB Operation: Dispose command
Info: Creating the `schemaversions` table
Expand Down
58 changes: 0 additions & 58 deletions src/Tests/ApprovalFiles/NoPublicApiChanges.Run.Net.verified.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[assembly: System.CLSCompliantAttribute(true)]
[assembly: System.CLSCompliantAttribute(true)]
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
[assembly: System.Runtime.InteropServices.GuidAttribute("b6988607-c547-4cbd-8012-f8162a25092f")]

Expand Down
7 changes: 2 additions & 5 deletions src/Tests/DatabaseSupportTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#if !NETCORE
using DbUp.Builder;
using DbUp.MySql;
using DbUp.Builder;
using DbUp.Tests.Common;

namespace DbUp.Tests.Providers.MySql;
namespace DbUp.MySql.Tests;

public class DatabaseSupportTests : DatabaseSupportTestsBase
{
Expand All @@ -20,4 +18,3 @@ protected override UpgradeEngineBuilder AddCustomNamedJournalToBuilder(UpgradeEn
=> new MySqlTableJournal(connectionManagerFactory, logFactory, schema, tableName)
);
}
#endif
4 changes: 1 addition & 3 deletions src/Tests/MySqlConnectionManagerTests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DbUp.MySql;
using Shouldly;
using Xunit;

namespace DbUp.Tests.Support.MySql
namespace DbUp.MySql.Tests
{
public class MySqlConnectionManagerTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
DB Operation: Open connection
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 INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
DB Operation: Dispose command
Info: Fetching list of already executed scripts.
DB Operation: Execute reader command: select scriptname from `schemaversions` order by scriptname
DB Operation: Dispose command
Info: Journal table does not exist
Info: Executing Database Server script 'Script0003'
Info: Checking whether journal table exists..
Info: Checking whether journal table exists
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
DB Operation: Dispose command
DB Operation: Execute non query command: USE `test`
DB Operation: Dispose command
DB Operation: Execute non query command: DROP procedure IF EXISTS `testSproc`
DB Operation: Dispose command
DB Operation: Execute non query command: USE `test`
DB Operation: Dispose command
DB Operation: Execute non query command: CREATE PROCEDURE `testSproc`(
Info: Creating the `schemaversions` table
DB Operation: Execute non query command: CREATE TABLE `schemaversions`
(
`schemaversionid` INT NOT NULL AUTO_INCREMENT,
`scriptname` VARCHAR(255) NOT NULL,
`applied` TIMESTAMP NOT NULL,
PRIMARY KEY (`schemaversionid`)
);
DB Operation: Dispose command
Info: The `schemaversions` table has been created
DB Operation: Execute non query command: USE `test`;
DROP procedure IF EXISTS `testSproc`;

DELIMITER $$

USE `test`$$
CREATE PROCEDURE `testSproc`(
IN ssn VARCHAR(32)
)
BEGIN
Expand All @@ -25,7 +33,7 @@ BEGIN
FROM customer as c
WHERE c.ssn = ssn ;

END
END$$
DB Operation: Dispose command
DB Operation: Create parameter
Info: DB Operation: Add parameter to command: scriptName=Script0003
Expand Down
15 changes: 6 additions & 9 deletions src/Tests/MySqlSupportTests.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
using System.Threading.Tasks;
using Assent;
using DbUp.Tests.Common;
using DbUp.Tests.Common.RecordingDb;
using Shouldly;
using VerifyXunit;
using Xunit;

namespace DbUp.Tests.Support.MySql
namespace DbUp.MySql.Tests
{
[UsesVerify]
public class MySqlSupportTests
{
[Fact]
public Task CanHandleDelimiter()
public void CanHandleDelimiter()
{
var logger = new CaptureLogsLogger();
var recordingDbConnection = new RecordingDbConnection(logger, "schemaversions");
recordingDbConnection.SetupRunScripts();
var recordingDbConnection = new RecordingDbConnection(logger);
var upgrader = DeployChanges.To
.MySqlDatabase(string.Empty)
.OverrideConnectionFactory(recordingDbConnection)
.MySqlDatabase(new TestConnectionManager(recordingDbConnection))
.LogTo(logger)
.WithScript("Script0003", @"USE `test`;
DROP procedure IF EXISTS `testSproc`;
Expand All @@ -40,7 +37,7 @@ FROM customer as c
var result = upgrader.PerformUpgrade();

result.Successful.ShouldBe(true);
return Verifier.Verify(logger.Log, VerifyHelper.GetVerifySettings());
this.Assent(logger.Log, new Configuration().UsingSanitiser(Scrubbers.ScrubDates));
}
}
}
6 changes: 2 additions & 4 deletions src/Tests/NoPublicApiChanges.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#if !NETCORE
using DbUp.Tests.Common;
using DbUp.Tests.Common;

namespace DbUp.Tests.Providers.MySql;
namespace DbUp.MySql.Tests;

public class NoPublicApiChanges : NoPublicApiChangesBase
{
Expand All @@ -10,4 +9,3 @@ public NoPublicApiChanges()
{
}
}
#endif
Loading

0 comments on commit 5997347

Please sign in to comment.