Skip to content

Set-DbaLogin - Stop eating the caller loop on an invalid parameter co… #2985

Set-DbaLogin - Stop eating the caller loop on an invalid parameter co…

Set-DbaLogin - Stop eating the caller loop on an invalid parameter co… #2985

Workflow file for this run

name: Test version in Gallery
on:
workflow_dispatch:
push:
branches-ignore:
- master
tags-ignore:
- '**'
paths-ignore:
- '**/*.md'
- '**/*.json'
- '!.github/dbatools-library-version.json'
- 'docs/**'
- '.github/FUNDING.yml'
- '.github/ISSUE_TEMPLATE/**'
- '.github/PULL_REQUEST_TEMPLATE.md'
- '.aider/**'
- '.devcontainer/**'
- '.vscode/**'
- 'bin/**'
- 'en-us/**'
defaults:
run:
shell: pwsh
permissions:
contents: read
concurrency:
group: gallery-${{ github.ref }}
cancel-in-progress: true
jobs:
linux-tests:
env:
SMODefaultModuleName: dbatools
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Read dbatools.library version
id: get-version
shell: pwsh
run: |
$versionConfig = Get-Content '.github/dbatools-library-version.json' | ConvertFrom-Json
$version = $versionConfig.version
$isPreview = $version -like "*preview*"
Write-Output "version=$version" >> $env:GITHUB_OUTPUT
Write-Output "is_preview=$isPreview" >> $env:GITHUB_OUTPUT
Write-Output "Using dbatools.library version: $version"
Write-Output "Is preview version: $isPreview"
- name: Install dbatools.library (stable versions)
if: steps.get-version.outputs.is_preview == 'False'
shell: pwsh
run: |
Write-Output "Stable version detected, bypassing PSModuleCache in this secret-bearing job"
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
./.github/scripts/install-dbatools-library.ps1
- name: Install dbatools.library (preview versions)
if: steps.get-version.outputs.is_preview == 'True'
shell: pwsh
run: |
Write-Output "Preview version detected, bypassing PSModuleCache and using install script"
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
./.github/scripts/install-dbatools-library.ps1
- name: Download dbatools from Gallery
run: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module dbatools -AllowPrerelease
- name: Set encryption values
run: |
Import-Module dbatools
Set-DbatoolsInsecureConnection
Install-DbaSqlPackage
- name: Setup docker images
run: |
# create a shared network
docker network create localnet
# Expose engine and endpoint then setup a shared path for migrations
docker run -p 1433:1433 --volume shared:/shared:z --name mssql1 --hostname mssql1 --network localnet -e MSSQL_MEMORY_LIMIT_MB=1536 -d dbatools/sqlinstance
# Expose second engine and endpoint on different port
docker run -p 14333:1433 --volume shared:/shared:z --name mssql2 --hostname mssql2 --network localnet -e MSSQL_MEMORY_LIMIT_MB=1536 -d dbatools/sqlinstance2
# Keep the runner topology in parity with integration-tests.yml
docker run -p 14334:1433 --volume shared:/shared:z --name mssql3 --hostname mssql3 --network localnet -e MSSQL_MEMORY_LIMIT_MB=1024 -d dbatools/sqlinstance2
- name: Wait for the SQL Server containers to be ready
run: |
# The containers start detached and nothing waited for them, so the first test that needed the second
# instance failed whenever it was still starting (#10590). A login is not enough for the mirroring test:
# the mirroring endpoint on mssql2 has to be listening as well, so every instance is polled until it
# accepts a login and every mirroring endpoint it has reports STARTED (state 0 in sys.endpoints).
Import-Module dbatools
$password = ConvertTo-SecureString "dbatools.IO" -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sqladmin", $password
foreach ($instance in "localhost", "localhost:14333", "localhost:14334") {
$ready = $false
foreach ($attempt in 1..36) {
try {
$server = Connect-DbaInstance -SqlInstance $instance -SqlCredential $cred -TrustServerCertificate
$endpointsNotStarted = $server.Query("SELECT name FROM sys.database_mirroring_endpoints WHERE state <> 0")
if (-not $endpointsNotStarted) {
Write-Host "$instance is ready (version $($server.VersionString))"
$ready = $true
break
}
Write-Host "Attempt $attempt of 36: $instance accepts logins, but its mirroring endpoint has not started yet"
} catch {
Write-Host "Attempt $attempt of 36: $instance is not ready yet ($($PSItem.Exception.Message))"
}
Start-Sleep -Seconds 5
}
if (-not $ready) {
throw "$instance did not become ready in time"
}
}
- name: 👥 Clone appveyor repo
working-directory: /tmp
run: |
gh repo clone dataplat/appveyor-lab
- name: Run tests
env:
TENANTID: ${{secrets.TENANTID}}
CLIENTID: ${{secrets.CLIENTID}}
CLIENTSECRET: ${{secrets.CLIENTSECRET}}
CLIENT_GUID: ${{secrets.CLIENT_GUID}}
CLIENT_GUID_SECRET: ${{secrets.CLIENT_GUID_SECRET}}
DBATOOLS_GALLERY_TEST: "true"
run: |
Import-Module dbatools -Force
$result = Invoke-Pester .github/scripts/gh-actions.ps1 -Output Detailed -PassThru
if ($result.Result -ne "Passed" -or $result.FailedCount -gt 0) {
throw "Gallery integration tests failed with result $($result.Result) and $($result.FailedCount) failed test(s)."
}