| 1 |
name: CI (Windows) |
| 2 |
on: |
| 3 |
workflow_dispatch: |
| 4 |
push: |
| 5 |
branches: |
| 6 |
- main |
| 7 |
- stable-* |
| 8 |
paths-ignore: |
| 9 |
- .github/workflows/docs*.yml |
| 10 |
- .github/workflows/github-release.yml |
| 11 |
- changelogs/fragments/*.yml |
| 12 |
- .vscode/* |
| 13 |
pull_request: |
| 14 |
paths-ignore: |
| 15 |
- .github/workflows/docs*.yml |
| 16 |
- .github/workflows/github-release.yml |
| 17 |
- changelogs/fragments/*.yml |
| 18 |
- .vscode/* |
| 19 |
|
| 20 |
# Run CI once per day (at 06:00 UTC) |
| 21 |
# This ensures that even if there haven't been commits that we are still testing against latest version of ansible-test for each ansible-base version |
| 22 |
schedule: |
| 23 |
- cron: "0 8 * * *" |
| 24 |
|
| 25 |
# Cancel existing runs on new commits to a branch |
| 26 |
concurrency: |
| 27 |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 28 |
cancel-in-progress: true |
| 29 |
|
| 30 |
# Deny all permissions at workflow level - scope per job |
| 31 |
permissions: {} |
| 32 |
|
| 33 |
env: |
| 34 |
NAMESPACE: lowlydba |
| 35 |
COLLECTION_NAME: sqlserver |
| 36 |
DBATOOLS_VERSION: "2.0.0" |
| 37 |
|
| 38 |
jobs: |
| 39 |
### |
| 40 |
# Integration tests (RECOMMENDED) |
| 41 |
# |
| 42 |
# https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html |
| 43 |
|
| 44 |
integration: |
| 45 |
runs-on: ${{ matrix.os }} |
| 46 |
name: I (Ⓐ${{ matrix.ansible }}+win-2022|grp${{ matrix.group }}) |
| 47 |
continue-on-error: ${{ matrix.ansible == 'devel' }} |
| 48 |
strategy: |
| 49 |
fail-fast: false |
| 50 |
matrix: |
| 51 |
os: |
| 52 |
- windows-2022 |
| 53 |
wsl: |
| 54 |
- Ubuntu-24.04 |
| 55 |
ansible: |
| 56 |
- stable-2.19 |
| 57 |
- stable-2.20 |
| 58 |
- devel |
| 59 |
python: |
| 60 |
- python3 |
| 61 |
group: # windows/group/#/ |
| 62 |
- "1" |
| 63 |
- "2" |
| 64 |
#- '3' |
| 65 |
defaults: |
| 66 |
run: |
| 67 |
shell: wsl-bash {0} |
| 68 |
|
| 69 |
permissions: |
| 70 |
# Required for uploading coverage reports |
| 71 |
contents: write # Required for uploading coverage reports |
| 72 |
# Required for OIDC token authentication |
| 73 |
id-token: write # Required for OIDC token authentication |
| 74 |
env: |
| 75 |
NAMESPACE: lowlydba # zizmor: ignore[template-injection] -- Static value |
| 76 |
COLLECTION_NAME: sqlserver # zizmor: ignore[template-injection] -- Static value |
| 77 |
GROUP: ${{ matrix.group }} # zizmor: ignore[template-injection] -- Matrix value from controlled environment |
| 78 |
PYTHON: python3 |
| 79 |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} # zizmor: ignore[secrets-outside-env] -- Codecov token needed for coverage uploads; environment protection would block PR-triggered runs |
| 80 |
WORKSPACE: ${{ github.workspace }} |
| 81 |
|
| 82 |
steps: |
| 83 |
- name: Check out code |
| 84 |
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 85 |
with: |
| 86 |
path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} |
| 87 |
persist-credentials: false |
| 88 |
|
| 89 |
- name: Create an admin user # zizmor: ignore[misfeature] -- Windows-specific cmd required for net user commands; pwsh cannot create local users |
| 90 |
shell: cmd |
| 91 |
run: | |
| 92 |
net user admin pass123@ /add /y |
| 93 |
net localgroup Administrators admin /add |
| 94 |
|
| 95 |
- name: Set up the runner for PowerShell remoting |
| 96 |
shell: powershell |
| 97 |
run: | |
| 98 |
$sb = [ScriptBlock]::Create((New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/ansible/ansible/38e50c9f819a045ea4d40068f83e78adbfaf2e68/examples/scripts/ConfigureRemotingForAnsible.ps1')) |
| 99 |
& $sb -Verbose -ForceNewSSLCert 4>&1 |
| 100 |
|
| 101 |
- name: Enable winrm |
| 102 |
shell: powershell |
| 103 |
run: | |
| 104 |
winrm quickconfig -force |
| 105 |
|
| 106 |
- name: Why is MongoDB running? Disable it. |
| 107 |
shell: powershell |
| 108 |
run: | |
| 109 |
Get-Service -Name MongoDB | Where-Object Status -eq 'Running' | Stop-Service -Force |
| 110 |
|
| 111 |
- name: Add a hosts entry # zizmor: ignore[misfeature] -- Windows-specific cmd required for hosts file modification |
| 112 |
shell: cmd |
| 113 |
run: echo 127.0.0.1 sqlserver >> "%WinDir%\System32\Drivers\etc\hosts" |
| 114 |
|
| 115 |
- uses: Vampire/setup-wsl@887f39deb6c0976365e546926fe66f41b77d65ff # v6.1.0 |
| 116 |
with: |
| 117 |
distribution: ${{ matrix.wsl }} |
| 118 |
update: "false" |
| 119 |
use-cache: "true" |
| 120 |
wsl-version: 1 |
| 121 |
additional-packages: | |
| 122 |
git |
| 123 |
${{ matrix.python }} |
| 124 |
python3-pip |
| 125 |
openssh-client |
| 126 |
|
| 127 |
- name: Get Linux workspace path |
| 128 |
shell: pwsh |
| 129 |
run: | |
| 130 |
# $ws = & wslpath --% -u -a "$env:WORKSPACE"" |
| 131 |
# seems wslpath is not available on server 2019 |
| 132 |
|
| 133 |
function ConvertTo-LinuxPathCrappy { |
| 134 |
[CmdletBinding()] |
| 135 |
param( |
| 136 |
[Parameter(Mandatory)] |
| 137 |
[ValidateNotNullOrEmpty()] |
| 138 |
[string] |
| 139 |
$LiteralPath |
| 140 |
) |
| 141 |
|
| 142 |
End { |
| 143 |
$resolved = Resolve-Path -LiteralPath $LiteralPath |
| 144 |
$drive = ($resolved | Split-Path -Qualifier).TrimEnd(':').ToLower() |
| 145 |
$rooted = ($resolved | Split-Path -NoQualifier).Replace('\', '/').TrimStart('/') |
| 146 |
|
| 147 |
'/mnt/{0}/{1}' -f $drive, $rooted |
| 148 |
} |
| 149 |
} |
| 150 |
$ws = ConvertTo-LinuxPathCrappy -LiteralPath "$env:WORKSPACE" |
| 151 |
Add-Content -LiteralPath $env:GITHUB_ENV -Value "GHWS=$ws" |
| 152 |
|
| 153 |
# Override break-sys-pkg defaults, because we don't need to bother with python venv for CI |
| 154 |
- name: Install ansible-base (${{ matrix.ansible }}) # zizmor: ignore[template-injection] -- matrix.ansible is a controlled enum value (stable-2.19, stable-2.20, devel) |
| 155 |
run: | |
| 156 |
python3 -m pip config set global.break-system-packages true |
| 157 |
python3 -m pip install --upgrade setuptools pypsrp --disable-pip-version-check --retries 10 |
| 158 |
python3 -m pip install "https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz" --disable-pip-version-check --retries 10 |
| 159 |
|
| 160 |
- name: Install collection dependencies |
| 161 |
id: collection-dependency |
| 162 |
# zizmor: ignore[template-injection] -- GHWS is dynamically computed earlier in the workflow |
| 163 |
run: ansible-galaxy collection install ansible.windows -p "${{ env.GHWS }}" |
| 164 |
continue-on-error: true |
| 165 |
|
| 166 |
- name: Retry install collection dependencies |
| 167 |
if: steps.collection-dependency.outcome == 'failure' |
| 168 |
# zizmor: ignore[template-injection] -- GHWS is dynamically computed earlier in the workflow |
| 169 |
run: ansible-galaxy collection install ansible.windows -p "${{ env.GHWS }}" |
| 170 |
|
| 171 |
- name: Set integration test options |
| 172 |
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/tests/integration |
| 173 |
run: | |
| 174 |
cp integration_config.sample.yml integration_config.yml |
| 175 |
cp inventory.winrm.ci inventory.winrm |
| 176 |
|
| 177 |
- name: Install SQL Server |
| 178 |
continue-on-error: true |
| 179 |
id: mssqlsuite |
| 180 |
uses: potatoqualitee/mssqlsuite@2291d923e83859edd871679c05b379037376761f # v1.12 |
| 181 |
with: |
| 182 |
install: sqlengine |
| 183 |
sa-password: L0wlydb4 |
| 184 |
version: 2022 |
| 185 |
|
| 186 |
- name: Retry SQL Server install |
| 187 |
id: retry1 |
| 188 |
if: steps.mssqlsuite.outcome == 'failure' |
| 189 |
uses: potatoqualitee/mssqlsuite@2291d923e83859edd871679c05b379037376761f # v1.12 |
| 190 |
with: |
| 191 |
install: sqlengine |
| 192 |
sa-password: L0wlydb4 |
| 193 |
version: 2022 |
| 194 |
|
| 195 |
- name: Run integration test # zizmor: ignore[template-injection] -- env.GHWS is a computed path; matrix values are controlled enums |
| 196 |
run: | |
| 197 |
pushd "${{ env.GHWS }}/ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}" |
| 198 |
ansible-test windows-integration -v --color --retry-on-error --continue-on-error --diff --coverage --requirements windows/group/${{ matrix.group }}/ |
| 199 |
|
| 200 |
- name: Generate coverage report # zizmor: ignore[template-injection] -- env.GHWS is a computed path |
| 201 |
run: | |
| 202 |
pushd "${{ env.GHWS }}/ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}" |
| 203 |
ansible-test coverage xml -v --requirements |
| 204 |
|
| 205 |
# See the reports at https://codecov.io/gh/lowlydba/lowlydba.sqlserver |
| 206 |
- uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0 |
| 207 |
with: |
| 208 |
fail_ci_if_error: false |
| 209 |
|
| 210 |
win-ci-test-rollup: |
| 211 |
name: Are we good? |
| 212 |
runs-on: ubuntu-slim |
| 213 |
needs: [integration] |
| 214 |
if: always() |
| 215 |
steps: |
| 216 |
- uses: lowlydba/are-we-good@7efad05442f92a1203940ca8b79dd4fb930e75d4 # v1.0.2 |
| 217 |
with: |
| 218 |
jobs: ${{ toJSON(needs) }} |