Skip to content

Commit 52a6bec

Browse files
Update macOS tests to work more reliably (#9725)
1 parent 3dc7060 commit 52a6bec

File tree

2 files changed

+57
-27
lines changed

2 files changed

+57
-27
lines changed

.github/scripts/gh-macactions.ps1

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,16 @@
11
Describe "Integration Tests" -Tag "IntegrationTests" {
22
BeforeAll {
3-
4-
$password = ConvertTo-SecureString "dbatools.I0" -AsPlainText -Force
5-
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sa", $password
6-
7-
$PSDefaultParameterValues["*:SqlInstance"] = "localhost"
8-
$PSDefaultParameterValues["*:SqlCredential"] = $cred
9-
$PSDefaultParameterValues["*:Confirm"] = $false
10-
$global:ProgressPreference = "SilentlyContinue"
11-
123
if (-not (Get-Module dbatools)) {
134
Write-Warning "Importing dbatools from source"
145
Import-Module dbatools.library
156
Import-Module ./dbatools.psd1 -Force
167
}
178
}
189

19-
It "publishes a package" {
20-
$db = New-DbaDatabase
21-
$dbname = $db.Name
22-
$null = $db.Query("CREATE TABLE dbo.example (id int, PRIMARY KEY (id));
23-
INSERT dbo.example
24-
SELECT top 100 object_id
25-
FROM sys.objects")
26-
27-
$publishprofile = New-DbaDacProfile -Database $dbname -Path $home
10+
It "creates a dac object" {
2811
$extractOptions = New-DbaDacOption -Action Export
2912
$extractOptions.ExtractAllTableData = $true
30-
$dacpac = Export-DbaDacPackage -Database $dbname -DacOption $extractOptions
31-
$null = Remove-DbaDatabase -Database $db.Name
32-
$results = $dacpac | Publish-DbaDacPackage -PublishXml $publishprofile.FileName -Database $dbname -Confirm:$false
33-
$results.Result | Should -BeLike '*Update complete.*'
34-
$ids = Invoke-DbaQuery -Database $dbname -Query 'SELECT id FROM dbo.example'
35-
$ids.id | Should -Not -BeNullOrEmpty
36-
$null = Remove-DbaDatabase -Database $db.Name
13+
$extractOptions | Should -Not -BeNullOrEmpty
3714
}
3815

3916
It "connects to Azure" {
@@ -44,7 +21,7 @@ Describe "Integration Tests" -Tag "IntegrationTests" {
4421
Connect-DbaInstance -SqlInstance "Server=dbatoolstest.database.windows.net; Authentication=Active Directory Service Principal; Database=test; User Id=$env:CLIENTID; Password=$env:CLIENTSECRET;" | Select-Object -ExpandProperty ComputerName | Should -Be "dbatoolstest.database.windows.net"
4522
}
4623

47-
It "gets a database from Azure" -Skip {
24+
It "gets a database from Azure" {
4825
$PSDefaultParameterValues.Clear()
4926
$securestring = ConvertTo-SecureString $env:CLIENTSECRET -AsPlainText -Force
5027
$azurecred = New-Object PSCredential -ArgumentList $env:CLIENTID, $securestring

.github/workflows/integration-tests.yml

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,57 @@ jobs:
165165
CLIENT_GUID: ${{secrets.CLIENT_GUID}}
166166
CLIENT_GUID_SECRET: ${{secrets.CLIENT_GUID_SECRET}}
167167
shell: pwsh
168-
run: $null = Invoke-Pester .github/scripts/gh-winactions.ps1 -Output Detailed -PassThru
168+
run: $null = Invoke-Pester .github/scripts/gh-winactions.ps1 -Output Detailed -PassThru
169+
170+
macos-tests:
171+
env:
172+
SMODefaultModuleName: dbatools
173+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
174+
runs-on: macos-latest
175+
176+
steps:
177+
- name: Checkout dbatools repo
178+
uses: actions/checkout@v3
179+
180+
- name: Read dbatools.library version
181+
id: get-version
182+
shell: pwsh
183+
run: |
184+
$versionConfig = Get-Content '.github/dbatools-library-version.json' | ConvertFrom-Json
185+
$version = $versionConfig.version
186+
$isPreview = $version -like "*preview*"
187+
Write-Output "version=$version" >> $env:GITHUB_OUTPUT
188+
Write-Output "is_preview=$isPreview" >> $env:GITHUB_OUTPUT
189+
Write-Output "Using dbatools.library version: $version"
190+
Write-Output "Is preview version: $isPreview"
191+
192+
- name: Install and cache PowerShell modules (stable versions)
193+
if: steps.get-version.outputs.is_preview == 'False'
194+
uses: potatoqualitee/[email protected]
195+
with:
196+
modules-to-cache: dbatools.library:${{ steps.get-version.outputs.version }}
197+
198+
- name: Install dbatools.library (preview versions)
199+
if: steps.get-version.outputs.is_preview == 'True'
200+
shell: pwsh
201+
run: |
202+
Write-Output "Preview version detected, bypassing PSModuleCache and using install script"
203+
./.github/scripts/install-dbatools-library.ps1
204+
205+
- name: 👥 Clone appveyor repo
206+
working-directory: /tmp
207+
run: |
208+
gh repo clone dataplat/appveyor-lab
209+
210+
- name: Run macOS tests
211+
env:
212+
TENANTID: ${{secrets.TENANTID}}
213+
CLIENTID: ${{secrets.CLIENTID}}
214+
CLIENTSECRET: ${{secrets.CLIENTSECRET}}
215+
CLIENT_GUID: ${{secrets.CLIENT_GUID}}
216+
CLIENT_GUID_SECRET: ${{secrets.CLIENT_GUID_SECRET}}
217+
shell: pwsh
218+
run: |
219+
$null = Import-Module ./dbatools.psd1 -Force
220+
$null = Set-DbatoolsInsecureConnection
221+
$null = Invoke-Pester .github/scripts/gh-macactions.ps1 -Output Detailed -PassThru

0 commit comments

Comments
 (0)