name: CI (Windows) on: workflow_dispatch: push: branches: - main - stable-* paths-ignore: - .github/workflows/docs*.yml - .github/workflows/github-release.yml - changelogs/fragments/*.yml - .vscode/* pull_request: paths-ignore: - .github/workflows/docs*.yml - .github/workflows/github-release.yml - changelogs/fragments/*.yml - .vscode/* # Run CI once per day (at 06:00 UTC) # 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 schedule: - cron: "0 8 * * *" # Cancel existing runs on new commits to a branch concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true # Deny all permissions at workflow level - scope per job permissions: {} env: NAMESPACE: lowlydba COLLECTION_NAME: sqlserver DBATOOLS_VERSION: "2.0.0" jobs: ### # Integration tests (RECOMMENDED) # # https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html integration: runs-on: ${{ matrix.os }} name: I (Ⓐ${{ matrix.ansible }}+win-2022|grp${{ matrix.group }}) continue-on-error: ${{ matrix.ansible == 'devel' }} strategy: fail-fast: false matrix: os: - windows-2022 wsl: - Ubuntu-24.04 ansible: - stable-2.19 - stable-2.20 - devel python: - python3 group: # windows/group/#/ - "1" - "2" #- '3' defaults: run: shell: wsl-bash {0} permissions: # Required for uploading coverage reports contents: write # Required for uploading coverage reports # Required for OIDC token authentication id-token: write # Required for OIDC token authentication env: NAMESPACE: lowlydba # zizmor: ignore[template-injection] -- Static value COLLECTION_NAME: sqlserver # zizmor: ignore[template-injection] -- Static value GROUP: ${{ matrix.group }} # zizmor: ignore[template-injection] -- Matrix value from controlled environment PYTHON: python3 CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} # zizmor: ignore[secrets-outside-env] -- Codecov token needed for coverage uploads; environment protection would block PR-triggered runs WORKSPACE: ${{ github.workspace }} steps: - name: Check out code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} persist-credentials: false - name: Create an admin user # zizmor: ignore[misfeature] -- Windows-specific cmd required for net user commands; pwsh cannot create local users shell: cmd run: | net user admin pass123@ /add /y net localgroup Administrators admin /add - name: Set up the runner for PowerShell remoting shell: powershell run: | $sb = [ScriptBlock]::Create((New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/ansible/ansible/38e50c9f819a045ea4d40068f83e78adbfaf2e68/examples/scripts/ConfigureRemotingForAnsible.ps1')) & $sb -Verbose -ForceNewSSLCert 4>&1 - name: Enable winrm shell: powershell run: | winrm quickconfig -force - name: Why is MongoDB running? Disable it. shell: powershell run: | Get-Service -Name MongoDB | Where-Object Status -eq 'Running' | Stop-Service -Force - name: Add a hosts entry # zizmor: ignore[misfeature] -- Windows-specific cmd required for hosts file modification shell: cmd run: echo 127.0.0.1 sqlserver >> "%WinDir%\System32\Drivers\etc\hosts" - uses: Vampire/setup-wsl@887f39deb6c0976365e546926fe66f41b77d65ff # v6.1.0 with: distribution: ${{ matrix.wsl }} update: "false" use-cache: "true" wsl-version: 1 additional-packages: | git ${{ matrix.python }} python3-pip openssh-client - name: Get Linux workspace path shell: pwsh run: | # $ws = & wslpath --% -u -a "$env:WORKSPACE"" # seems wslpath is not available on server 2019 function ConvertTo-LinuxPathCrappy { [CmdletBinding()] param( [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string] $LiteralPath ) End { $resolved = Resolve-Path -LiteralPath $LiteralPath $drive = ($resolved | Split-Path -Qualifier).TrimEnd(':').ToLower() $rooted = ($resolved | Split-Path -NoQualifier).Replace('\', '/').TrimStart('/') '/mnt/{0}/{1}' -f $drive, $rooted } } $ws = ConvertTo-LinuxPathCrappy -LiteralPath "$env:WORKSPACE" Add-Content -LiteralPath $env:GITHUB_ENV -Value "GHWS=$ws" # Override break-sys-pkg defaults, because we don't need to bother with python venv for CI - name: Install ansible-base (${{ matrix.ansible }}) # zizmor: ignore[template-injection] -- matrix.ansible is a controlled enum value (stable-2.19, stable-2.20, devel) run: | python3 -m pip config set global.break-system-packages true python3 -m pip install --upgrade setuptools pypsrp --disable-pip-version-check --retries 10 python3 -m pip install "https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz" --disable-pip-version-check --retries 10 - name: Install collection dependencies id: collection-dependency # zizmor: ignore[template-injection] -- GHWS is dynamically computed earlier in the workflow run: ansible-galaxy collection install ansible.windows -p "${{ env.GHWS }}" continue-on-error: true - name: Retry install collection dependencies if: steps.collection-dependency.outcome == 'failure' # zizmor: ignore[template-injection] -- GHWS is dynamically computed earlier in the workflow run: ansible-galaxy collection install ansible.windows -p "${{ env.GHWS }}" - name: Set integration test options working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/tests/integration run: | cp integration_config.sample.yml integration_config.yml cp inventory.winrm.ci inventory.winrm - name: Install SQL Server continue-on-error: true id: mssqlsuite uses: potatoqualitee/mssqlsuite@2291d923e83859edd871679c05b379037376761f # v1.12 with: install: sqlengine sa-password: L0wlydb4 version: 2022 - name: Retry SQL Server install id: retry1 if: steps.mssqlsuite.outcome == 'failure' uses: potatoqualitee/mssqlsuite@2291d923e83859edd871679c05b379037376761f # v1.12 with: install: sqlengine sa-password: L0wlydb4 version: 2022 - name: Run integration test # zizmor: ignore[template-injection] -- env.GHWS is a computed path; matrix values are controlled enums run: | pushd "${{ env.GHWS }}/ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}" ansible-test windows-integration -v --color --retry-on-error --continue-on-error --diff --coverage --requirements windows/group/${{ matrix.group }}/ - name: Generate coverage report # zizmor: ignore[template-injection] -- env.GHWS is a computed path run: | pushd "${{ env.GHWS }}/ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}" ansible-test coverage xml -v --requirements # See the reports at https://codecov.io/gh/lowlydba/lowlydba.sqlserver - uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0 with: fail_ci_if_error: false win-ci-test-rollup: name: Are we good? runs-on: ubuntu-slim needs: [integration] if: always() steps: - uses: lowlydba/are-we-good@7efad05442f92a1203940ca8b79dd4fb930e75d4 # v1.0.2 with: jobs: ${{ toJSON(needs) }}