-
Notifications
You must be signed in to change notification settings - Fork 8
209 lines (190 loc) 路 8.25 KB
/
Copy pathtest-aitools.yml
File metadata and controls
209 lines (190 loc) 路 8.25 KB
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
name: Test AITools
on:
push:
branches:
- '**' # Run on all branches
paths-ignore:
- 'README.md'
- '**/*.png'
- '**/*.jpg'
- '**/*.jpeg'
- '**/*.gif'
- '**/*.svg'
- '**/*.ico'
- '**/*.webp'
jobs:
test:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup PowerShell module cache
id: psmodulecache
uses: potatoqualitee/psmodulecache@v6.2.1
with:
modules-to-cache: PSFramework:1.7.249, Microsoft.PowerShell.ThreadJob:2.2.0, Pester:5.6.1
- name: Cache winget packages (Windows only)
if: runner.os == 'Windows'
uses: actions/cache@v4
with:
path: ~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalCache
key: ${{ runner.os }}-winget-${{ hashFiles('.github/workflows/*.yml') }}
restore-keys: |
${{ runner.os }}-winget-
- name: Setup PowerShell
shell: pwsh
run: |
Write-Host "PowerShell version: $($PSVersionTable.PSVersion)"
Write-Host "OS: $($PSVersionTable.OS)"
Write-Host "Platform: $($PSVersionTable.Platform)"
- name: Setup Node.js (required for ClaudeCode on Linux/macOS)
if: runner.os != 'Windows'
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Check if Install-AITool.ps1 changed
id: check_install_tool
shell: pwsh
run: |
# Get files changed in the current commit
$changed = git diff-tree --no-commit-id --name-only -r HEAD | Select-String -Pattern "Install-AITool.ps1"
if ($changed) {
echo "install_tool_changed=true" >> $env:GITHUB_OUTPUT
Write-Host "Install-AITool.ps1 has changed - will test Aider installation on Windows"
} else {
echo "install_tool_changed=false" >> $env:GITHUB_OUTPUT
Write-Host "Install-AITool.ps1 unchanged - will skip Aider on Windows"
}
- name: Install AI tools (skip Aider and Gemini on Windows for speed)
shell: pwsh
continue-on-error: true
run: |
Import-Module ./aitools.psd1 -Force
if ($IsWindows -or $env:OS -match 'Windows') {
Write-Host "Installing AI tools on Windows (skipping Aider and Gemini due to long install times)..."
$tools = @('ClaudeCode', 'Codex', 'GitHubCopilot')
foreach ($tool in $tools) {
Write-Host "Installing $tool..."
Install-AITool -Name $tool -SkipInitialization -Verbose
}
} else {
Write-Host "Installing all AI tools..."
Install-AITool -Name All -SkipInitialization -Verbose
}
- name: Install Aider and Gemini on Windows (only when Install-AITool.ps1 changes)
if: runner.os == 'Windows' && steps.check_install_tool.outputs.install_tool_changed == 'true'
shell: pwsh
continue-on-error: true
run: |
Import-Module ./aitools.psd1 -Force
Write-Host "Install-AITool.ps1 changed - testing Aider and Gemini installation..."
Install-AITool -Name Aider -SkipInitialization -Verbose
Install-AITool -Name Gemini -SkipInitialization -Verbose
- name: Verify at least ClaudeCode is installed
shell: pwsh
run: |
Import-Module ./aitools.psd1 -Force
$claude = Get-Command claude -ErrorAction SilentlyContinue
if (-not $claude) {
Write-Host "ClaudeCode not found, installing individually..."
Install-AITool -Name ClaudeCode -SkipInitialization -Verbose
# Refresh path after installation for current session
if ($IsWindows -or $env:OS -match 'Windows') {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
} else {
# On Unix, npm global installs go to different locations
$npmBin = npm config get prefix 2>$null
if ($npmBin) {
$env:PATH = "$npmBin/bin:$env:PATH"
}
}
# Persist PATH to subsequent steps using GitHub Actions environment file
# This is necessary because each step starts a new shell session
if ($IsWindows -or $env:OS -match 'Windows') {
$newPath = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
"PATH=$newPath" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
Write-Host "Updated GITHUB_PATH for subsequent steps"
} else {
$npmBin = npm config get prefix 2>$null
if ($npmBin) {
"$npmBin/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
Write-Host "Added npm bin to GITHUB_PATH: $npmBin/bin"
}
}
# Check again after path refresh
$claude = Get-Command claude -ErrorAction SilentlyContinue
if (-not $claude) {
Write-Warning "ClaudeCode still not found after installation. Checking npm global path..."
npm list -g --depth=0
}
} else {
Write-Host "ClaudeCode is installed"
& claude --version
}
- name: Set ClaudeCode as default
shell: pwsh
run: |
Import-Module ./aitools.psd1 -Force
# Verify claude is available before setting as default (to avoid Read-Host prompt)
$claude = Get-Command claude -ErrorAction SilentlyContinue
if ($claude) {
Write-Host "Setting ClaudeCode as default tool..."
Set-AIToolDefault -Tool ClaudeCode
} else {
Write-Error "ClaudeCode is not installed, cannot set as default"
exit 1
}
- name: Setup Claude OAuth Token
shell: pwsh
env:
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
run: |
Write-Host "Setting up CLAUDE_CODE_OAUTH_TOKEN environment variable..."
if ([string]::IsNullOrEmpty($env:CLAUDE_CODE_OAUTH_TOKEN)) {
Write-Warning "CLAUDE_CODE_OAUTH_TOKEN is not set in secrets"
exit 1
}
Write-Host "CLAUDE_CODE_OAUTH_TOKEN is configured (length: $($env:CLAUDE_CODE_OAUTH_TOKEN.Length))"
- name: Test Invoke-AITool quick chat
shell: pwsh
env:
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
run: |
Import-Module ./aitools.psd1 -Force
Write-Host "Testing Invoke-AITool with quick chat..."
$result = Invoke-AITool -Prompt "Hello" -Tool ClaudeCode
Write-Host "Chat result:"
$result | Format-List
- name: Clone dbatools repo at specific commit
shell: pwsh
run: |
Write-Host "Cloning dbatools repository at commit ed7f53d81f28cea1e4b691f2d92b8b6042802d12..."
git clone --depth 1 --single-branch --branch master https://github.com/dataplat/dbatools.git
cd dbatools
git fetch --depth 50 origin ed7f53d81f28cea1e4b691f2d92b8b6042802d12
git checkout ed7f53d81f28cea1e4b691f2d92b8b6042802d12
- name: Run Pester integration tests
shell: pwsh
env:
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
run: |
Import-Module ./aitools.psd1 -Force
Write-Host "Installing Pester..."
Install-Module -Name Pester -Force -SkipPublisherCheck -MinimumVersion 5.0.0
Write-Host "Running Pester tests..."
$config = New-PesterConfiguration
$config.Run.Path = "Tests/aitools.Tests.ps1"
$config.Output.Verbosity = "Detailed"
$config.Run.Exit = $true
Invoke-Pester -Configuration $config
- name: Show git diff
shell: pwsh
run: |
Write-Host "Showing git diff of changes..."
Push-Location dbatools
git diff --color=always tests/Invoke-DbaDbShrink.Tests.ps1
Pop-Location