Skip to content

Commit 6ebf339

Browse files
combine and publish
1 parent e5e2569 commit 6ebf339

2 files changed

Lines changed: 100 additions & 160 deletions

File tree

.github/workflows/build-release.yml

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,107 @@ jobs:
9292
name: dbatools-library-zip
9393
path: dbatools.library.zip
9494

95-
create-preview-release:
95+
test-sqlpackage:
96+
name: Test SqlPackage on ${{ matrix.os }}
97+
runs-on: ${{ matrix.os }}
9698
needs: build-windows
99+
strategy:
100+
fail-fast: false
101+
matrix:
102+
os: [ubuntu-latest, windows-latest, macOS-latest]
103+
104+
steps:
105+
- uses: actions/checkout@v4
106+
107+
- name: Download library artifacts
108+
uses: actions/download-artifact@v4
109+
with:
110+
name: dbatools-library
111+
112+
- name: Test SqlPackage
113+
shell: pwsh
114+
run: |
115+
# Import the built module
116+
Import-Module ./dbatools.library.psd1 -Force -ErrorAction Stop
117+
118+
# Get module info
119+
$module = Get-Module dbatools.library
120+
Write-Host "Loaded dbatools.library version: $($module.Version)"
121+
122+
# Display module version info
123+
Write-Host "Module loaded successfully with version: $($module.Version)"
124+
Write-Host "Module path: $($module.ModuleBase)"
125+
126+
# Determine SqlPackage path based on OS
127+
$modulePath = $module.ModuleBase
128+
if ($IsWindows -or $PSVersionTable.PSVersion.Major -eq 5) {
129+
Write-Host "Testing Windows SqlPackage..."
130+
$dacPath = Join-Path $modulePath "lib/win-dac"
131+
$sqlPackageName = "SqlPackage.exe"
132+
} elseif ($IsLinux) {
133+
Write-Host "Testing Linux SqlPackage..."
134+
$dacPath = Join-Path $modulePath "lib/linux-dac"
135+
$sqlPackageName = "SqlPackage"
136+
} elseif ($IsMacOS) {
137+
Write-Host "Testing macOS SqlPackage..."
138+
$dacPath = Join-Path $modulePath "lib/mac-dac"
139+
$sqlPackageName = "SqlPackage"
140+
} else {
141+
Write-Error "Unknown operating system"
142+
exit 1
143+
}
144+
145+
# Check if SqlPackage directory exists
146+
if (-not (Test-Path $dacPath)) {
147+
Write-Error "SqlPackage directory not found: $dacPath"
148+
Write-Host "Available directories in lib:"
149+
Get-ChildItem (Join-Path $modulePath "lib") -Directory | ForEach-Object { Write-Host " - $($_.Name)" }
150+
exit 1
151+
}
152+
153+
# Check if SqlPackage executable exists
154+
$sqlPackagePath = Join-Path $dacPath $sqlPackageName
155+
if (-not (Test-Path $sqlPackagePath)) {
156+
Write-Error "SqlPackage executable not found: $sqlPackagePath"
157+
Write-Host "Files in $dacPath :"
158+
Get-ChildItem $dacPath | ForEach-Object { Write-Host " - $($_.Name)" }
159+
exit 1
160+
}
161+
162+
Write-Host "SqlPackage found at: $sqlPackagePath"
163+
164+
# Make SqlPackage executable on non-Windows platforms
165+
if ($IsLinux -or $IsMacOS) {
166+
chmod +x $sqlPackagePath
167+
}
168+
169+
# Test SqlPackage execution
170+
try {
171+
Write-Host "Testing SqlPackage execution..."
172+
$versionOutput = & $sqlPackagePath /Version 2>&1
173+
Write-Host "SqlPackage version: $versionOutput"
174+
175+
# Basic functionality test - show help
176+
Write-Host "`nTesting SqlPackage help command..."
177+
$helpOutput = & $sqlPackagePath /? 2>&1 | Select-Object -First 10
178+
$helpOutput | ForEach-Object { Write-Host $_ }
179+
Write-Host "... (output truncated)"
180+
181+
# Verify expected output from help
182+
$helpString = $helpOutput -join "`n"
183+
if ($helpString -match "Specifies a name value pair" -or $helpString -match "SqlPackage" -or $helpString -match "Command") {
184+
Write-Host "`nSqlPackage test completed successfully!"
185+
} else {
186+
Write-Error "SqlPackage help output does not contain expected content"
187+
exit 1
188+
}
189+
} catch {
190+
Write-Error "Failed to execute SqlPackage: $_"
191+
exit 1
192+
}
193+
194+
create-preview-release:
195+
needs: [build-windows, test-sqlpackage]
97196
runs-on: windows-latest
98197
# Create release if manually triggered OR if version contains "preview"
99198
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'

.github/workflows/sqlpackage.yml

Lines changed: 0 additions & 159 deletions
This file was deleted.

0 commit comments

Comments
 (0)