Skip to content

Commit

Permalink
Merge pull request #26 from max-ieremenko/release/4.1.1
Browse files Browse the repository at this point in the history
Release/4.1.1
  • Loading branch information
max-ieremenko committed Nov 27, 2022
2 parents 0c7476f + de381f7 commit 00959dc
Show file tree
Hide file tree
Showing 561 changed files with 14,428 additions and 15,359 deletions.
10 changes: 5 additions & 5 deletions Build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
build.ps1 is designed to run on windows

- PowerShell Desktop 5.1
- PowerShell [7.3.0](https://github.com/PowerShell/PowerShell/releases/tag/v7.3.0) for .net 7.0 tests
- PowerShell [7.2.1](https://github.com/PowerShell/PowerShell/releases/tag/v7.2.1) for .net 6.0 tests
- PowerShell [7.1.5](https://github.com/PowerShell/PowerShell/releases/tag/v7.1.5) for .net 5.0 tests
- PowerShell [7.0.8](https://github.com/PowerShell/PowerShell/releases/tag/v7.0.8) for .net core 3.1 tests
- Install-Module -Name InvokeBuild -RequiredVersion 5.8.7
- ThirdPartyLibraries https://www.nuget.org/packages/ThirdPartyLibraries.GlobalTool/
- Install-Module -Name [InvokeBuild](https://www.powershellgallery.com/packages/InvokeBuild/5.9.12) -RequiredVersion 5.9.12
- Install-Module -Name [ThirdPartyLibraries](https://www.powershellgallery.com/packages/ThirdPartyLibraries/3.1.2) -RequiredVersion 3.1.2
- .net framework 4.7.2+ sdk
- .net core 3.1 sdk
- .net 5.0 sdk
- .net 7.0 sdk
- docker, switched to linux containers

## How to build
Expand All @@ -19,7 +19,7 @@ build.ps1 is designed to run on windows
PS> git clone https://github.com/max-ieremenko/SqlDatabase.git
# build required docker images
PS> .\Build\create-images.ps1
PS> .\Build\create-images.ps1
# run build
PS> .\Build\build.ps1
Expand Down
35 changes: 19 additions & 16 deletions Build/build-scripts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ function Get-AssemblyVersion($assemblyInfoCsPath) {
}

function Get-RepositoryCommitId {
$response = (Invoke-RestMethod -Uri "https://api.github.com/repos/max-ieremenko/SqlDatabase/commits/master")
return $response.sha
git rev-parse HEAD
}

function Start-Mssql {
Expand Down Expand Up @@ -157,26 +156,30 @@ function Wait-Connection {
$timeout = 50
)

$connection = New-Object -TypeName $connectionName -ArgumentList $connectionString
try {
for ($i = 0; $i -lt $timeout; $i++) {
try {
$connection.Open()
return
}
catch {
Start-Sleep -Seconds 1
}
function Test-Connection {
$connection = New-Object -TypeName $connectionName -ArgumentList $connectionString
try {
$connection.Open()
}
finally {
$connection.Dispose()
}
}

for ($i = 0; $i -lt $timeout; $i++) {
try {
$connection.Open()
Test-Connection
return
}
catch {
throw "$connectionName $connectionString"
Start-Sleep -Seconds 1
}
}
finally {
$connection.Dispose()

try {
Test-Connection
}
catch {
throw "$connectionName $connectionString"
}
}
2 changes: 1 addition & 1 deletion Build/build-tasks.it-tool-linux.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ task RunTest {
$test = (Join-Path $settings.integrationTests $database) + ":/test"

exec {
docker run --rm `
docker run -it --rm `
-v $app `
-v $test `
--env connectionString=$connectionString `
Expand Down
58 changes: 27 additions & 31 deletions Build/build-tasks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ task Build {
}

task ThirdPartyNotices {
Invoke-Build -File build-tasks.third-party.ps1 -Task "ThirdParty" -settings $settings
Invoke-Build -File build-tasks.third-party.ps1 -settings $settings
}

task PackGlobalTool {
Expand Down Expand Up @@ -103,25 +103,16 @@ task PackManualDownload PackGlobalTool, PackPoweShellModule, {
$thirdParty = Join-Path $settings.bin "ThirdPartyNotices.txt"
$packageVersion = $settings.version

$destination = Join-Path $out "SqlDatabase.$packageVersion-net452.zip"
$source = Join-Path $settings.bin "SqlDatabase\net452\*"
Compress-Archive -Path $source, $lic, $thirdParty -DestinationPath $destination

$destination = Join-Path $out "SqlDatabase.$packageVersion-PowerShell.zip"
$source = Join-Path $settings.artifactsPowerShell "*"
Compress-Archive -Path $source -DestinationPath $destination

$destination = Join-Path $out "SqlDatabase.$packageVersion-netcore31.zip"
$source = Join-Path $settings.bin "SqlDatabase\netcoreapp3.1\publish\*"
Compress-Archive -Path $source, $lic, $thirdParty -DestinationPath $destination

$destination = Join-Path $out "SqlDatabase.$packageVersion-net50.zip"
$source = Join-Path $settings.bin "SqlDatabase\net5.0\publish\*"
Compress-Archive -Path $source, $lic, $thirdParty -DestinationPath $destination

$destination = Join-Path $out "SqlDatabase.$packageVersion-net60.zip"
$source = Join-Path $settings.bin "SqlDatabase\net6.0\publish\*"
Compress-Archive -Path $source, $lic, $thirdParty -DestinationPath $destination
$targets = "net452", "netcoreapp3.1", "net5.0", "net6.0", "net7.0"
foreach ($target in $targets) {
$destination = Join-Path $out "SqlDatabase.$packageVersion-$target.zip"
$source = Join-Path $settings.bin "SqlDatabase\$target\*"
Compress-Archive -Path $source, $lic, $thirdParty -DestinationPath $destination
}
}

task UnitTest {
Expand All @@ -130,6 +121,7 @@ task UnitTest {
@{ File = "build-tasks.unit-test.ps1"; Task = "Test"; settings = $settings; targetFramework = "netcoreapp3.1" }
@{ File = "build-tasks.unit-test.ps1"; Task = "Test"; settings = $settings; targetFramework = "net5.0" }
@{ File = "build-tasks.unit-test.ps1"; Task = "Test"; settings = $settings; targetFramework = "net6.0" }
@{ File = "build-tasks.unit-test.ps1"; Task = "Test"; settings = $settings; targetFramework = "net7.0" }
)

Build-Parallel $builds -ShowParameter targetFramework -MaximumBuilds 4
Expand Down Expand Up @@ -179,14 +171,14 @@ task PsCoreTest {
# show-powershell-images.ps1
$images = $(
"mcr.microsoft.com/powershell:6.1.0-ubuntu-18.04"
, "mcr.microsoft.com/powershell:6.1.1-alpine-3.8"
, "mcr.microsoft.com/powershell:6.1.2-alpine-3.8"
, "mcr.microsoft.com/powershell:6.1.3-alpine-3.8"
, "mcr.microsoft.com/powershell:6.2.0-alpine-3.8"
, "mcr.microsoft.com/powershell:6.2.1-alpine-3.8"
, "mcr.microsoft.com/powershell:6.2.2-alpine-3.8"
, "mcr.microsoft.com/powershell:6.1.1-ubuntu-18.04"
, "mcr.microsoft.com/powershell:6.1.2-ubuntu-18.04"
, "mcr.microsoft.com/powershell:6.1.3-ubuntu-18.04"
, "mcr.microsoft.com/powershell:6.2.0-ubuntu-18.04"
, "mcr.microsoft.com/powershell:6.2.1-ubuntu-18.04"
, "mcr.microsoft.com/powershell:6.2.2-ubuntu-18.04"
, "mcr.microsoft.com/powershell:6.2.3-ubuntu-18.04"
, "mcr.microsoft.com/powershell:6.2.4-alpine-3.8"
, "mcr.microsoft.com/powershell:6.2.4-ubuntu-18.04"
, "mcr.microsoft.com/powershell:7.0.0-ubuntu-18.04"
, "mcr.microsoft.com/powershell:7.0.1-ubuntu-18.04"
, "mcr.microsoft.com/powershell:7.0.2-ubuntu-18.04"
Expand All @@ -198,7 +190,8 @@ task PsCoreTest {
, "mcr.microsoft.com/powershell:7.1.4-ubuntu-20.04"
, "mcr.microsoft.com/powershell:7.2.0-ubuntu-20.04"
, "mcr.microsoft.com/powershell:7.2.1-ubuntu-20.04"
, "mcr.microsoft.com/powershell:7.3.0-preview.1-ubuntu-20.04")
, "mcr.microsoft.com/powershell:7.2.2-ubuntu-20.04"
, "mcr.microsoft.com/powershell:7.3-ubuntu-20.04")

$builds = @()
foreach ($image in $images) {
Expand All @@ -220,7 +213,8 @@ task SdkToolTest {
$images = $(
"sqldatabase/dotnet_pwsh:3.1-sdk"
, "sqldatabase/dotnet_pwsh:5.0-sdk"
, "sqldatabase/dotnet_pwsh:6.0-sdk")
, "sqldatabase/dotnet_pwsh:6.0-sdk"
, "sqldatabase/dotnet_pwsh:7.0-sdk")

$builds = @()
foreach ($image in $images) {
Expand All @@ -240,9 +234,10 @@ task SdkToolTest {

task NetRuntimeLinuxTest {
$testCases = $(
@{ targetFramework = "netcore31"; image = "sqldatabase/dotnet_pwsh:3.1-runtime" }
, @{ targetFramework = "net50"; image = "sqldatabase/dotnet_pwsh:5.0-runtime" }
, @{ targetFramework = "net60"; image = "sqldatabase/dotnet_pwsh:6.0-runtime" }
@{ targetFramework = "netcoreapp3.1"; image = "sqldatabase/dotnet_pwsh:3.1-runtime" }
, @{ targetFramework = "net5.0"; image = "sqldatabase/dotnet_pwsh:5.0-runtime" }
, @{ targetFramework = "net6.0"; image = "sqldatabase/dotnet_pwsh:6.0-runtime" }
, @{ targetFramework = "net7.0"; image = "sqldatabase/dotnet_pwsh:7.0-runtime" }
)

$builds = @()
Expand All @@ -265,9 +260,10 @@ task NetRuntimeLinuxTest {
task NetRuntimeWindowsTest {
$testCases = $(
"net452"
, "netcore31"
, "net50"
, "net60"
, "netcoreapp3.1"
, "net5.0"
, "net6.0"
, "net7.0"
)

$builds = @()
Expand Down
57 changes: 21 additions & 36 deletions Build/build-tasks.third-party.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,32 @@ param(
$settings
)

function Write-ThirdPartyNotices($appName, $sources, $repository, $out) {
$source = $sources | ForEach-Object {"-source", $_}
$outTemp = Join-Path $out "Temp"
task Default Update, Test, Publish

Exec {
ThirdPartyLibraries update `
-appName $appName `
$source `
-repository $repository
}
Enter-Build {
$repository = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot "third-party-libraries"))

Exec {
ThirdPartyLibraries validate `
-appName $appName `
$source `
-repository $repository
}

Exec {
ThirdPartyLibraries generate `
-appName $appName `
-repository $repository `
-to $outTemp
}

Move-Item (Join-Path $outTemp "ThirdPartyNotices.txt") $out -Force
Remove-Item -Path $outTemp -Recurse -Force
}

task ThirdParty {
$sourceDir = $settings.sources
$thirdPartyRepository = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot "third-party-libraries"))
$binDir = $settings.bin

$sources = @(
(Join-Path $sourceDir "SqlDatabase"),
$sources = (Join-Path $sourceDir "SqlDatabase"),
(Join-Path $sourceDir "SqlDatabase.Test"),
(Join-Path $sourceDir "SqlDatabase.PowerShell"),
(Join-Path $sourceDir "SqlDatabase.PowerShell.Test"),
(Join-Path $sourceDir "SqlDatabase.Test")
)

Write-ThirdPartyNotices "SqlDatabase" $sources $thirdPartyRepository $binDir
}

task Update {
Update-ThirdPartyLibrariesRepository -AppName "SqlDatabase" -Source $sources -Repository $repository
}

task Test {
Test-ThirdPartyLibrariesRepository -AppName "SqlDatabase" -Source $sources -Repository $repository
}

task Publish {
$outTemp = Join-Path $settings.bin "Temp"
$title = "SqlDatabase " + $settings.version
Publish-ThirdPartyNotices -AppName "SqlDatabase" -Repository $repository -Title $title -To $outTemp

Move-Item (Join-Path $outTemp "ThirdPartyNotices.txt") $settings.bin -Force
Remove-Item -Path $outTemp -Recurse -Force
}
4 changes: 3 additions & 1 deletion Build/build.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#Requires -Modules @{ModuleName='InvokeBuild'; RequiredVersion='5.8.7'}
#Requires -Version "7.0"
#Requires -Modules @{ ModuleName="InvokeBuild"; ModuleVersion="5.9.12" }

Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

$file = Join-Path $PSScriptRoot "build-tasks.ps1"
Invoke-Build -File $file
20 changes: 20 additions & 0 deletions Build/create-images-tasks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ task Default `
, BuildDotnetRuntime50 `
, BuildDotnetSdk60 `
, BuildDotnetRuntime60 `
, BuildDotnetSdk70 `
, BuildDotnetRuntime70 `
, BuildMsSqlDatabase `
, BuildPgSqlDatabase `
, BuildMySqlDatabase
Expand Down Expand Up @@ -92,3 +94,21 @@ task BuildDotnetRuntime60 {
.
}
}

task BuildDotnetSdk70 {
exec {
docker build `
-f image-dotnet-sdk-7.0.dockerfile `
-t sqldatabase/dotnet_pwsh:7.0-sdk `
.
}
}

task BuildDotnetRuntime70 {
exec {
docker build `
-f image-dotnet-runtime-7.0.dockerfile `
-t sqldatabase/dotnet_pwsh:7.0-runtime `
.
}
}
3 changes: 2 additions & 1 deletion Build/create-images.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#Requires -Modules @{ModuleName='InvokeBuild'; RequiredVersion='5.8.7'}
#Requires -Version "7.0"
#Requires -Modules @{ ModuleName="InvokeBuild"; ModuleVersion="5.9.12" }

Set-StrictMode -Version Latest

Expand Down
8 changes: 8 additions & 0 deletions Build/image-dotnet-runtime-7.0.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM mcr.microsoft.com/dotnet/runtime:7.0

RUN apt-get update && \
apt-get install -y curl && \
curl -L https://github.com/PowerShell/PowerShell/releases/download/v7.3.0/powershell_7.3.0-1.deb_amd64.deb --output powershell.deb && \
dpkg -i powershell.deb && \
apt-get install -f && \
rm -f powershell.deb
7 changes: 7 additions & 0 deletions Build/image-dotnet-sdk-7.0.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0

RUN apt-get update && \
curl -L https://github.com/PowerShell/PowerShell/releases/download/v7.3.0/powershell_7.3.0-1.deb_amd64.deb --output powershell.deb && \
dpkg -i powershell.deb && \
apt-get install -f && \
rm -f powershell.deb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SqlDatabase
************
{{Title}}
{% for i in (1..Title.size) %}*{% endfor %}

THIRD-PARTY SOFTWARE NOTICES AND INFORMATION

Expand Down
Loading

0 comments on commit 00959dc

Please sign in to comment.