Skip to content

Commit

Permalink
Merge pull request #155 from dataplat/development
Browse files Browse the repository at this point in the history
v0.9.0
  • Loading branch information
nvarscar authored Dec 2, 2022
2 parents 028959d + cd54045 commit 1c56597
Show file tree
Hide file tree
Showing 144 changed files with 5,575 additions and 12,007 deletions.
69 changes: 67 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: CI
on: [pull_request]
on: [push]

jobs:
build:
import:
name: Module imports on all platforms
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -15,3 +15,68 @@ jobs:
- name: Perform the import
shell: pwsh
run: Install-Module PSFramework -Force; Import-Module ./dbops.psd1 -ErrorAction Stop

functional-tests:
name: Functional tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
type: [sqlserver, postgresql, oracle, mysql]
include:
- image: dbatools/sqlinstance
port: 1433
type: sqlserver
env: {}
- image: postgres:14
port: 5432
type: postgresql
env:
POSTGRES_PASSWORD: Password12!
POSTGRES_HOST_AUTH_METHOD: md5
- image: mysql:8.0
port: 3306
type: mysql
env:
MYSQL_ROOT_PASSWORD: Password12!
- image: wnameless/oracle-xe-11g-r2
port: 1521
type: oracle
env:
ORACLE_ALLOW_REMOTE: true
services:
db:
image: ${{ matrix.image }}
ports:
- ${{ matrix.port }}:${{ matrix.port }}
env: ${{ matrix.env }}
env:
TZ: UTC
steps:
- uses: actions/checkout@v1
- name: Prepare
shell: pwsh
run: tests/functional.prep.ps1 -Type ${{ matrix.type }}
- name: Run tests
shell: pwsh
run: tests/ci.pester.ps1 -Tag FunctionalTests -Type ${{ matrix.type }}

unit-tests:
name: Unit tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v1
- name: Prepare
shell: pwsh
run: tests/pester.prep.ps1
- name: Run unittests
shell: pwsh
run: tests/ci.pester.ps1 -Tag UnitTests
- name: Run integration tests
shell: pwsh
run: tests/ci.pester.ps1 -Tag IntegrationTests
- name: Run compliance tests
shell: pwsh
run: tests/ci.pester.ps1 -Tag ComplianceTests
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -368,4 +368,7 @@ MigrationBackup/
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd
FodyWeavers.xsd

# build folder
tests/build
77 changes: 22 additions & 55 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ only_commits:

image:
- Visual Studio 2019
- Ubuntu

# Set build info
environment:
Expand All @@ -27,59 +26,27 @@ environment:
PGPASSWORD: Password12!
AssentNonInteractive: true
IGNORE_NORMALISATION_GIT_HEAD_MOVE: 1
mssql_instance: localhost\SQL2017
scenario: windows

services:
- mssql2017
- mysql
- postgresql

before_build:
- ps: .\build\build_prep.ps1
build_script:
- ps: .\build\build.ps1 -Script .\build.cake
after_build:
- ps: .\build\copy_build_files.ps1

before_test:
- SET PATH=C:\Program Files\PostgreSQL\9.6\bin\;%PATH%
- psql -c "CREATE USER sa WITH SUPERUSER PASSWORD 'Password12!';" -U postgres
- ps: .\tests\pester.prep.ps1

for:
- matrix:
only:
- image: Visual Studio 2019
environment:
mssql_instance: localhost\SQL2017
scenario: windows
services:
- mssql2017
- mysql
- postgresql
before_build:
- ps: .\build\build_prep.ps1
build_script:
- ps: .\build\build.ps1 -Script .\build.cake
after_build:
- ps: .\build\copy_build_files.ps1

before_test:
- SET PATH=C:\Program Files\PostgreSQL\9.6\bin\;%PATH%
- psql -c "CREATE USER sa WITH SUPERUSER PASSWORD 'Password12!';" -U postgres
- ps: .\tests\appveyor.prep.ps1


- matrix:
only:
- image: Ubuntu
environment:
mssql_instance: localhost
scenario: all
TZ: GMT
services:
- mssql
- mysql
- postgresql
before_test:
- sudo -u postgres psql -c "CREATE USER sa WITH SUPERUSER PASSWORD 'Password12!';"
- ps: .\tests\appveyor.prep.ps1
- docker run --name dbops-oracle -d -p 1521:1521 -e ORACLE_ALLOW_REMOTE=true wnameless/oracle-xe-11g-r2

after_test:
- ps: .\tests\appveyor.post.ps1
test_script:
- ps: .\tests\appveyor.pester.ps1
# Collecting results
- ps: .\tests\appveyor.pester.ps1 -Finalize


# Set alternative clone folder
#clone_folder: c:\github\dbops



#on_finish:
# - ps:
- ps: .\tests\ci.pester.ps1 -Type SqlServer, Postgresql, MySQL -Tag UnitTests, IntegrationTests, ComplianceTests
- ps: .\tests\install_dependencies.ps1 -Load -Type SqlServer, Postgresql, MySQL
- ps: .\tests\ci.pester.ps1 -Type SqlServer, Postgresql, MySQL -Tag FunctionalTests
4 changes: 2 additions & 2 deletions azure-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ jobs:
filePath: .\build\bump_version.ps1
arguments: .\dbops.psd1
env:
git_user_email: $(gitUserEmail)
git_username: $(gitUsername)
GIT_USER_EMAIL: $(gitUserEmail)
GIT_USERNAME: $(gitUsername)
MY_ACCESS_TOKEN: $(System.AccessToken)
8 changes: 4 additions & 4 deletions dbops.psd1
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@{

# Script module or binary module file associated with this manifest
RootModule = 'dbops.psm1'
RootModule = '.\dbops.psm1'

# Version number of this module.
ModuleVersion = '0.8.0'
ModuleVersion = '0.9.0'

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

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

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

# Modules to import as nested modules of the module specified in
# ModuleToProcess
Expand Down
9 changes: 8 additions & 1 deletion dbops.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@ foreach ($bin in (Get-DBOModuleFileList -Type Libraries -Edition $PSVersionTable
if ($PSVersionTable.Platform -eq 'Win32NT') {
Unblock-File -Path $bin -ErrorAction SilentlyContinue
}
Add-Type -Path $bin
Add-Type -Path $bin -ErrorAction SilentlyContinue
}

'Functions', 'Internal' | ForEach-Object {
foreach ($function in (Get-DBOModuleFileList -Type $_).FullName) {
. $function
}
}
# import type and format data
if (!(Get-TypeData -TypeName DBOpsPackageFile)) {
Update-TypeData -Path $PSScriptRoot\internal\xml\dbops.types.ps1xml
}
if (!(Get-FormatData -TypeName DBOpsPackageFile)) {
Update-FormatData -Path $PSScriptRoot\internal\xml\dbops.format.ps1xml
}

# defining validations

Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Release notes for v0.9.0:
- ### Pester 5 and redesigned test structure (#152) by @nvarscar
- ### Adding AlwaysRollback deployment method (#154) by @nvarscar
# Release notes for v0.8.1:
- ### Wrapper around dotnet call to filter output (#148) by @nvarscar
# Release notes for v0.8.0:
Expand Down
2 changes: 1 addition & 1 deletion functions/Add-DBOBuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function Add-DBOBuild {
Write-PSFMessage -Level Verbose -Message "Adding file '$($buildScript.FullName)' to $currentBuild as $($buildScript.GetPackagePath())"
}

if ($pscmdlet.ShouldProcess($package, "Writing new build $currentBuild into the original package")) {
if ($pscmdlet.ShouldProcess([string]$package, "Writing new build $currentBuild into the original package")) {
$currentBuild.Alter()
}
}
Expand Down
16 changes: 8 additions & 8 deletions functions/Copy-DBOPackageArtifact.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ Function Copy-DBOPackageArtifact {
<#
.SYNOPSIS
Copies a DBOps package file stored in the specific artifact repository to the specified location.
.DESCRIPTION
Copies a DBOps package file from an artifact repository created by Publish-DBOPackageArtifact to the specified location.
.PARAMETER Name
Name of the DBOps package
Aliases: FileName, Package
.PARAMETER Repository
Path to the artifact repository - a folder or a network share
Expand All @@ -24,7 +24,7 @@ Function Copy-DBOPackageArtifact {
.PARAMETER Passthru
Returns a filesystem object after excecution
.PARAMETER Confirm
Prompts to confirm certain actions
Expand All @@ -34,13 +34,13 @@ Function Copy-DBOPackageArtifact {
.EXAMPLE
# Copies the latest version of the package myPackage.zip from the repository \\data\repo to the local folder .\
Copy-DBOPackageArtifact -Name myPackage.zip -Repository \\data\repo -Destination .
.EXAMPLE
# Copies a specific version of the package myPackage.zip from the repository \\data\repo to the folder c:\workspace
Copy-DBOPackageArtifact -Name myPackage -Repository \\data\repo -Version 2.2.1 -Destination c:\workspace
.NOTES
#>
[CmdletBinding(SupportsShouldProcess)]
Param(
Expand All @@ -59,7 +59,7 @@ Function Copy-DBOPackageArtifact {
}
process {
if ($src) {
if ($PSCmdlet.ShouldProcess($src, "Copying file to the destination $Destination")) {
if ($PSCmdlet.ShouldProcess([string]$src, "Copying file to the destination $Destination")) {
Copy-Item -Path $src -Destination $Destination -Passthru:$Passthru
}
}
Expand Down
8 changes: 4 additions & 4 deletions functions/Export-DBOConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<#
.SYNOPSIS
Exports configuration file from existing DBOps package or DBOps config
.DESCRIPTION
Exports configuration file from existing DBOps package or DBOps config to a json file.
.PARAMETER Path
Path to the target json file.
Expand All @@ -29,7 +29,7 @@
.EXAMPLE
# Export configuration from a package file to a json file
Get-Item 'mypackage.zip'| Export-DBOConfig .\config.json
#>
[CmdletBinding(SupportsShouldProcess)]
Param (
Expand All @@ -44,7 +44,7 @@
process {
$config = Get-DBOConfig -InputObject $InputObject

if ($pscmdlet.ShouldProcess($config, "Saving the config file")) {
if ($pscmdlet.ShouldProcess($Path, "Saving the config file")) {
$config.SaveToFile($Path)
}
}
Expand Down
3 changes: 2 additions & 1 deletion functions/Install-DBOPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- SingleTransaction: wrap all the deployment scripts into a single transaction and rollback whole deployment on error
- TransactionPerScript: wrap each script into a separate transaction; rollback single script deployment in case of error
- NoTransaction: deploy as is
- AlwaysRollback: deploy as a single transaction, but rollback changes after the deployment is done
Default: NoTransaction
Expand Down Expand Up @@ -149,7 +150,7 @@
[string]$SqlInstance,
[Parameter(Position = 3)]
[string]$Database,
[ValidateSet('SingleTransaction', 'TransactionPerScript', 'NoTransaction')]
[ValidateSet('SingleTransaction', 'TransactionPerScript', 'NoTransaction', 'AlwaysRollback')]
[string]$DeploymentMethod = 'NoTransaction',
[int]$ConnectionTimeout,
[int]$ExecutionTimeout,
Expand Down
3 changes: 2 additions & 1 deletion functions/Install-DBOScript.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- SingleTransaction: wrap all the deployment scripts into a single transaction and rollback whole deployment on error
- TransactionPerScript: wrap each script into a separate transaction; rollback single script deployment in case of error
- NoTransaction: deploy as is
- AlwaysRollback: deploy as a single transaction, but rollback changes after the deployment is done
Default: NoTransaction
Expand Down Expand Up @@ -158,7 +159,7 @@
[string]$SqlInstance,
[Parameter(Position = 3)]
[string]$Database,
[ValidateSet('SingleTransaction', 'TransactionPerScript', 'NoTransaction')]
[ValidateSet('SingleTransaction', 'TransactionPerScript', 'NoTransaction', 'AlwaysRollback')]
[string]$DeploymentMethod = 'NoTransaction',
[int]$ConnectionTimeout,
[int]$ExecutionTimeout,
Expand Down
2 changes: 1 addition & 1 deletion functions/Invoke-DBOPackageCI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function Invoke-DBOPackageCI {
Build = $pkgVersion.ToString(3)
}
if ($pkg) {
if ($PSCmdlet.ShouldProcess($pkg, "Adding new build to existing package")) {
if ($PSCmdlet.ShouldProcess([string]$pkg, "Adding new build to existing package")) {
Add-DBOBuild @ciSplat -Package $pkg -Type $Type
}
}
Expand Down
Loading

0 comments on commit 1c56597

Please sign in to comment.