Skip to content

Commit 1c56597

Browse files
authored
Merge pull request #155 from dataplat/development
v0.9.0
2 parents 028959d + cd54045 commit 1c56597

File tree

144 files changed

+5575
-12007
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+5575
-12007
lines changed

.github/workflows/CI.yml

+67-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: CI
2-
on: [pull_request]
2+
on: [push]
33

44
jobs:
5-
build:
5+
import:
66
name: Module imports on all platforms
77
runs-on: ${{ matrix.os }}
88
strategy:
@@ -15,3 +15,68 @@ jobs:
1515
- name: Perform the import
1616
shell: pwsh
1717
run: Install-Module PSFramework -Force; Import-Module ./dbops.psd1 -ErrorAction Stop
18+
19+
functional-tests:
20+
name: Functional tests
21+
runs-on: ubuntu-latest
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
type: [sqlserver, postgresql, oracle, mysql]
26+
include:
27+
- image: dbatools/sqlinstance
28+
port: 1433
29+
type: sqlserver
30+
env: {}
31+
- image: postgres:14
32+
port: 5432
33+
type: postgresql
34+
env:
35+
POSTGRES_PASSWORD: Password12!
36+
POSTGRES_HOST_AUTH_METHOD: md5
37+
- image: mysql:8.0
38+
port: 3306
39+
type: mysql
40+
env:
41+
MYSQL_ROOT_PASSWORD: Password12!
42+
- image: wnameless/oracle-xe-11g-r2
43+
port: 1521
44+
type: oracle
45+
env:
46+
ORACLE_ALLOW_REMOTE: true
47+
services:
48+
db:
49+
image: ${{ matrix.image }}
50+
ports:
51+
- ${{ matrix.port }}:${{ matrix.port }}
52+
env: ${{ matrix.env }}
53+
env:
54+
TZ: UTC
55+
steps:
56+
- uses: actions/checkout@v1
57+
- name: Prepare
58+
shell: pwsh
59+
run: tests/functional.prep.ps1 -Type ${{ matrix.type }}
60+
- name: Run tests
61+
shell: pwsh
62+
run: tests/ci.pester.ps1 -Tag FunctionalTests -Type ${{ matrix.type }}
63+
64+
unit-tests:
65+
name: Unit tests
66+
runs-on: ubuntu-latest
67+
strategy:
68+
fail-fast: false
69+
steps:
70+
- uses: actions/checkout@v1
71+
- name: Prepare
72+
shell: pwsh
73+
run: tests/pester.prep.ps1
74+
- name: Run unittests
75+
shell: pwsh
76+
run: tests/ci.pester.ps1 -Tag UnitTests
77+
- name: Run integration tests
78+
shell: pwsh
79+
run: tests/ci.pester.ps1 -Tag IntegrationTests
80+
- name: Run compliance tests
81+
shell: pwsh
82+
run: tests/ci.pester.ps1 -Tag ComplianceTests

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -368,4 +368,7 @@ MigrationBackup/
368368
.ionide/
369369

370370
# Fody - auto-generated XML schema
371-
FodyWeavers.xsd
371+
FodyWeavers.xsd
372+
373+
# build folder
374+
tests/build

appveyor.yml

+22-55
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ only_commits:
1717

1818
image:
1919
- Visual Studio 2019
20-
- Ubuntu
2120

2221
# Set build info
2322
environment:
@@ -27,59 +26,27 @@ environment:
2726
PGPASSWORD: Password12!
2827
AssentNonInteractive: true
2928
IGNORE_NORMALISATION_GIT_HEAD_MOVE: 1
29+
mssql_instance: localhost\SQL2017
30+
scenario: windows
31+
32+
services:
33+
- mssql2017
34+
- mysql
35+
- postgresql
36+
37+
before_build:
38+
- ps: .\build\build_prep.ps1
39+
build_script:
40+
- ps: .\build\build.ps1 -Script .\build.cake
41+
after_build:
42+
- ps: .\build\copy_build_files.ps1
43+
44+
before_test:
45+
- SET PATH=C:\Program Files\PostgreSQL\9.6\bin\;%PATH%
46+
- psql -c "CREATE USER sa WITH SUPERUSER PASSWORD 'Password12!';" -U postgres
47+
- ps: .\tests\pester.prep.ps1
3048

31-
for:
32-
- matrix:
33-
only:
34-
- image: Visual Studio 2019
35-
environment:
36-
mssql_instance: localhost\SQL2017
37-
scenario: windows
38-
services:
39-
- mssql2017
40-
- mysql
41-
- postgresql
42-
before_build:
43-
- ps: .\build\build_prep.ps1
44-
build_script:
45-
- ps: .\build\build.ps1 -Script .\build.cake
46-
after_build:
47-
- ps: .\build\copy_build_files.ps1
48-
49-
before_test:
50-
- SET PATH=C:\Program Files\PostgreSQL\9.6\bin\;%PATH%
51-
- psql -c "CREATE USER sa WITH SUPERUSER PASSWORD 'Password12!';" -U postgres
52-
- ps: .\tests\appveyor.prep.ps1
53-
54-
55-
- matrix:
56-
only:
57-
- image: Ubuntu
58-
environment:
59-
mssql_instance: localhost
60-
scenario: all
61-
TZ: GMT
62-
services:
63-
- mssql
64-
- mysql
65-
- postgresql
66-
before_test:
67-
- sudo -u postgres psql -c "CREATE USER sa WITH SUPERUSER PASSWORD 'Password12!';"
68-
- ps: .\tests\appveyor.prep.ps1
69-
- docker run --name dbops-oracle -d -p 1521:1521 -e ORACLE_ALLOW_REMOTE=true wnameless/oracle-xe-11g-r2
70-
71-
after_test:
72-
- ps: .\tests\appveyor.post.ps1
7349
test_script:
74-
- ps: .\tests\appveyor.pester.ps1
75-
# Collecting results
76-
- ps: .\tests\appveyor.pester.ps1 -Finalize
77-
78-
79-
# Set alternative clone folder
80-
#clone_folder: c:\github\dbops
81-
82-
83-
84-
#on_finish:
85-
# - ps:
50+
- ps: .\tests\ci.pester.ps1 -Type SqlServer, Postgresql, MySQL -Tag UnitTests, IntegrationTests, ComplianceTests
51+
- ps: .\tests\install_dependencies.ps1 -Load -Type SqlServer, Postgresql, MySQL
52+
- ps: .\tests\ci.pester.ps1 -Type SqlServer, Postgresql, MySQL -Tag FunctionalTests

azure-main.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ jobs:
2626
filePath: .\build\bump_version.ps1
2727
arguments: .\dbops.psd1
2828
env:
29-
git_user_email: $(gitUserEmail)
30-
git_username: $(gitUsername)
29+
GIT_USER_EMAIL: $(gitUserEmail)
30+
GIT_USERNAME: $(gitUsername)
3131
MY_ACCESS_TOKEN: $(System.AccessToken)

dbops.psd1

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
@{
22

33
# Script module or binary module file associated with this manifest
4-
RootModule = 'dbops.psm1'
4+
RootModule = '.\dbops.psm1'
55

66
# Version number of this module.
7-
ModuleVersion = '0.8.0'
7+
ModuleVersion = '0.9.0'
88

99
# ID used to uniquely identify this module
1010
GUID = '16dff216-533a-4fa3-9b2e-4408dbe15e63'
@@ -53,10 +53,10 @@
5353
ScriptsToProcess = @()
5454

5555
# Type files (.ps1xml) to be loaded when importing this module
56-
TypesToProcess = @('internal\xml\dbops.types.ps1xml')
56+
TypesToProcess = @()
5757

5858
# Format files (.ps1xml) to be loaded when importing this module
59-
FormatsToProcess = @('internal\xml\dbops.format.ps1xml')
59+
FormatsToProcess = @()
6060

6161
# Modules to import as nested modules of the module specified in
6262
# ModuleToProcess

dbops.psm1

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,21 @@ foreach ($bin in (Get-DBOModuleFileList -Type Libraries -Edition $PSVersionTable
55
if ($PSVersionTable.Platform -eq 'Win32NT') {
66
Unblock-File -Path $bin -ErrorAction SilentlyContinue
77
}
8-
Add-Type -Path $bin
8+
Add-Type -Path $bin -ErrorAction SilentlyContinue
99
}
1010

1111
'Functions', 'Internal' | ForEach-Object {
1212
foreach ($function in (Get-DBOModuleFileList -Type $_).FullName) {
1313
. $function
1414
}
1515
}
16+
# import type and format data
17+
if (!(Get-TypeData -TypeName DBOpsPackageFile)) {
18+
Update-TypeData -Path $PSScriptRoot\internal\xml\dbops.types.ps1xml
19+
}
20+
if (!(Get-FormatData -TypeName DBOpsPackageFile)) {
21+
Update-FormatData -Path $PSScriptRoot\internal\xml\dbops.format.ps1xml
22+
}
1623

1724
# defining validations
1825

docs/changelog.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Release notes for v0.9.0:
2+
- ### Pester 5 and redesigned test structure (#152) by @nvarscar
3+
- ### Adding AlwaysRollback deployment method (#154) by @nvarscar
14
# Release notes for v0.8.1:
25
- ### Wrapper around dotnet call to filter output (#148) by @nvarscar
36
# Release notes for v0.8.0:

functions/Add-DBOBuild.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ function Add-DBOBuild {
149149
Write-PSFMessage -Level Verbose -Message "Adding file '$($buildScript.FullName)' to $currentBuild as $($buildScript.GetPackagePath())"
150150
}
151151

152-
if ($pscmdlet.ShouldProcess($package, "Writing new build $currentBuild into the original package")) {
152+
if ($pscmdlet.ShouldProcess([string]$package, "Writing new build $currentBuild into the original package")) {
153153
$currentBuild.Alter()
154154
}
155155
}

functions/Copy-DBOPackageArtifact.ps1

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ Function Copy-DBOPackageArtifact {
22
<#
33
.SYNOPSIS
44
Copies a DBOps package file stored in the specific artifact repository to the specified location.
5-
5+
66
.DESCRIPTION
77
Copies a DBOps package file from an artifact repository created by Publish-DBOPackageArtifact to the specified location.
8-
8+
99
.PARAMETER Name
1010
Name of the DBOps package
1111
1212
Aliases: FileName, Package
13-
13+
1414
.PARAMETER Repository
1515
Path to the artifact repository - a folder or a network share
1616
@@ -24,7 +24,7 @@ Function Copy-DBOPackageArtifact {
2424
2525
.PARAMETER Passthru
2626
Returns a filesystem object after excecution
27-
27+
2828
.PARAMETER Confirm
2929
Prompts to confirm certain actions
3030
@@ -34,13 +34,13 @@ Function Copy-DBOPackageArtifact {
3434
.EXAMPLE
3535
# Copies the latest version of the package myPackage.zip from the repository \\data\repo to the local folder .\
3636
Copy-DBOPackageArtifact -Name myPackage.zip -Repository \\data\repo -Destination .
37-
37+
3838
.EXAMPLE
3939
# Copies a specific version of the package myPackage.zip from the repository \\data\repo to the folder c:\workspace
4040
Copy-DBOPackageArtifact -Name myPackage -Repository \\data\repo -Version 2.2.1 -Destination c:\workspace
41-
41+
4242
.NOTES
43-
43+
4444
#>
4545
[CmdletBinding(SupportsShouldProcess)]
4646
Param(
@@ -59,7 +59,7 @@ Function Copy-DBOPackageArtifact {
5959
}
6060
process {
6161
if ($src) {
62-
if ($PSCmdlet.ShouldProcess($src, "Copying file to the destination $Destination")) {
62+
if ($PSCmdlet.ShouldProcess([string]$src, "Copying file to the destination $Destination")) {
6363
Copy-Item -Path $src -Destination $Destination -Passthru:$Passthru
6464
}
6565
}

functions/Export-DBOConfig.ps1

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<#
33
.SYNOPSIS
44
Exports configuration file from existing DBOps package or DBOps config
5-
5+
66
.DESCRIPTION
77
Exports configuration file from existing DBOps package or DBOps config to a json file.
8-
8+
99
.PARAMETER Path
1010
Path to the target json file.
1111
@@ -29,7 +29,7 @@
2929
.EXAMPLE
3030
# Export configuration from a package file to a json file
3131
Get-Item 'mypackage.zip'| Export-DBOConfig .\config.json
32-
32+
3333
#>
3434
[CmdletBinding(SupportsShouldProcess)]
3535
Param (
@@ -44,7 +44,7 @@
4444
process {
4545
$config = Get-DBOConfig -InputObject $InputObject
4646

47-
if ($pscmdlet.ShouldProcess($config, "Saving the config file")) {
47+
if ($pscmdlet.ShouldProcess($Path, "Saving the config file")) {
4848
$config.SaveToFile($Path)
4949
}
5050
}

functions/Install-DBOPackage.ps1

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- SingleTransaction: wrap all the deployment scripts into a single transaction and rollback whole deployment on error
2828
- TransactionPerScript: wrap each script into a separate transaction; rollback single script deployment in case of error
2929
- NoTransaction: deploy as is
30+
- AlwaysRollback: deploy as a single transaction, but rollback changes after the deployment is done
3031
3132
Default: NoTransaction
3233
@@ -149,7 +150,7 @@
149150
[string]$SqlInstance,
150151
[Parameter(Position = 3)]
151152
[string]$Database,
152-
[ValidateSet('SingleTransaction', 'TransactionPerScript', 'NoTransaction')]
153+
[ValidateSet('SingleTransaction', 'TransactionPerScript', 'NoTransaction', 'AlwaysRollback')]
153154
[string]$DeploymentMethod = 'NoTransaction',
154155
[int]$ConnectionTimeout,
155156
[int]$ExecutionTimeout,

functions/Install-DBOScript.ps1

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- SingleTransaction: wrap all the deployment scripts into a single transaction and rollback whole deployment on error
2828
- TransactionPerScript: wrap each script into a separate transaction; rollback single script deployment in case of error
2929
- NoTransaction: deploy as is
30+
- AlwaysRollback: deploy as a single transaction, but rollback changes after the deployment is done
3031
3132
Default: NoTransaction
3233
@@ -158,7 +159,7 @@
158159
[string]$SqlInstance,
159160
[Parameter(Position = 3)]
160161
[string]$Database,
161-
[ValidateSet('SingleTransaction', 'TransactionPerScript', 'NoTransaction')]
162+
[ValidateSet('SingleTransaction', 'TransactionPerScript', 'NoTransaction', 'AlwaysRollback')]
162163
[string]$DeploymentMethod = 'NoTransaction',
163164
[int]$ConnectionTimeout,
164165
[int]$ExecutionTimeout,

functions/Invoke-DBOPackageCI.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function Invoke-DBOPackageCI {
140140
Build = $pkgVersion.ToString(3)
141141
}
142142
if ($pkg) {
143-
if ($PSCmdlet.ShouldProcess($pkg, "Adding new build to existing package")) {
143+
if ($PSCmdlet.ShouldProcess([string]$pkg, "Adding new build to existing package")) {
144144
Add-DBOBuild @ciSplat -Package $pkg -Type $Type
145145
}
146146
}

0 commit comments

Comments
 (0)