generated from ansible-collections/collection_template
-
-
Notifications
You must be signed in to change notification settings - Fork 12
187 lines (162 loc) · 6.11 KB
/
ansible-test-windows.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
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.ref }}
cancel-in-progress: true
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 }})
strategy:
fail-fast: false
matrix:
os:
- windows-2022
wsl:
- Ubuntu-24.04
ansible:
- stable-2.16
- stable-2.17
- devel
python:
- python3
group: # windows/group/#/
- "1"
- "2"
#- '3'
defaults:
run:
shell: wsl-bash {0}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
- name: Create an admin user
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
shell: cmd
run: echo 127.0.0.1 sqlserver >> "%WinDir%\System32\Drivers\etc\hosts"
- uses: Vampire/[email protected]
with:
distribution: ${{ matrix.wsl }}
update: "false"
use-cache: "true"
additional-packages: |
git
${{ matrix.python }}
python3-pip
openssh-client
- name: Get Linux workspace path
shell: pwsh
run: |
# $ws = & wslpath --% -u -a "${{ github.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 "${{ github.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 }})
run: |
${{ matrix.python }} -m pip config set global.break-system-packages true
${{ matrix.python }} -m pip install --upgrade setuptools pypsrp --disable-pip-version-check --retries 10
${{ matrix.python }} -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
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'
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/[email protected]
with:
install: sqlengine
sa-password: L0wlydb4
version: 2022
- name: Retry SQL Server install
id: retry1
if: steps.mssqlsuite.outcome == 'failure'
uses: potatoqualitee/[email protected]
with:
install: sqlengine
sa-password: L0wlydb4
version: 2022
- name: Run integration test
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
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/[email protected]
with:
fail_ci_if_error: false