Skip to content

Commit 603992f

Browse files
committed
win changes gha
1 parent 3110393 commit 603992f

File tree

1 file changed

+152
-142
lines changed

1 file changed

+152
-142
lines changed

.github/workflows/test-scripts.yml

Lines changed: 152 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -171,148 +171,158 @@ jobs:
171171
retention-days: 30
172172
if-no-files-found: ignore
173173

174-
# test-windows:
175-
# name: Test win/run.ps1 on Windows
176-
# runs-on: windows-latest
177-
# timeout-minutes: 15
178-
# environment: BrowserStack
179-
# steps:
180-
# - name: Checkout code
181-
# uses: actions/checkout@v4
182-
# - name: Set up Python 3.12
183-
# uses: actions/setup-python@v5
184-
# with:
185-
# python-version: '3.12'
186-
# - name: Check PowerShell version
187-
# run: |
188-
# $PSVersionTable.PSVersion
189-
# Write-Host "✅ PowerShell version check complete"
190-
#
191-
# - name: Validate PowerShell script syntax
192-
# run: |
193-
# Write-Host "Validating win/run.ps1 syntax..."
194-
# $ScriptPath = "win/run.ps1"
195-
# $null = [System.Management.Automation.PSParser]::Tokenize((Get-Content $ScriptPath), [ref]$null)
196-
# Write-Host "✅ win/run.ps1 syntax is valid"
197-
#
198-
# - name: Validate supporting PowerShell scripts syntax
199-
# run: |
200-
# Write-Host "Validating supporting PowerShell scripts..."
201-
# $Scripts = @("win/proxy-check.ps1")
202-
# foreach ($Script in $Scripts) {
203-
# $null = [System.Management.Automation.PSParser]::Tokenize((Get-Content $Script), [ref]$null)
204-
# Write-Host "✅ $Script syntax is valid"
205-
# }
206-
#
207-
# - name: Run PSScriptAnalyzer
208-
# run: |
209-
# Write-Host "Installing PSScriptAnalyzer..."
210-
# Install-Module -Name PSScriptAnalyzer -Force -SkipPublisherCheck -ErrorAction SilentlyContinue
211-
# Write-Host "Running PSScriptAnalyzer..."
212-
# Invoke-ScriptAnalyzer -Path "win/run.ps1" -Recurse -ReportSummary || $true
213-
# Write-Host "✅ PSScriptAnalyzer analysis complete"
214-
#
215-
# - name: Check script file encoding
216-
# run: |
217-
# Write-Host "Checking PowerShell script encoding..."
218-
# $ScriptPath = "win/run.ps1"
219-
# $Encoding = (Get-Item $ScriptPath).EncodingInfo
220-
# Write-Host "File encoding: $Encoding"
221-
# Write-Host "✅ Encoding check complete"
222-
#
223-
# - name: Verify required dependencies
224-
# run: |
225-
# Write-Host "Checking required dependencies..."
226-
# if (Get-Command curl.exe -ErrorAction SilentlyContinue) { Write-Host "✅ curl found" }
227-
# if (Get-Command git.exe -ErrorAction SilentlyContinue) { Write-Host "✅ git found" }
228-
# Write-Host "✅ PowerShell dependencies verified"
229-
#
230-
# - name: Integration Test - Silent Mode Execution
231-
# if: success()
232-
# env:
233-
# BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
234-
# BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
235-
# TURL: https://bstackdemo.com
236-
# run: |
237-
# Write-Host "Running integration tests in silent mode..."
238-
#
239-
# # Set default values if secrets are not provided
240-
# $BrowserStackUsername = if ($env:BROWSERSTACK_USERNAME) { $env:BROWSERSTACK_USERNAME } else { "test_user" }
241-
# $BrowserStackAccessKey = if ($env:BROWSERSTACK_ACCESS_KEY) { $env:BROWSERSTACK_ACCESS_KEY } else { "test_key" }
242-
# $TestUrl = $env:TURL
243-
#
244-
# # Export environment variables
245-
# $env:BROWSERSTACK_USERNAME = $BrowserStackUsername
246-
# $env:BROWSERSTACK_ACCESS_KEY = $BrowserStackAccessKey
247-
# $env:TURL = $TestUrl
248-
#
249-
# # Test configurations
250-
# $testConfigs = @(
251-
# @("web", "java"),
252-
# @("app", "java"),
253-
# @("web", "python"),
254-
# @("app", "python"),
255-
# @("web", "nodejs"),
256-
# @("app", "nodejs")
257-
# )
258-
#
259-
# foreach ($config in $testConfigs) {
260-
# $testType = $config[0]
261-
# $techStack = $config[1]
262-
#
263-
# Write-Host "================================"
264-
# Write-Host "Testing: .\win\run.ps1 --silent $testType $techStack"
265-
# Write-Host "================================"
266-
#
267-
# # Create log file path
268-
# $logPath = "C:\Temp\run_test_${testType}_${techStack}.log"
269-
# New-Item -ItemType Directory -Path "C:\Temp" -Force -ErrorAction SilentlyContinue | Out-Null
270-
#
271-
# # Run with timeout (using job for timeout capability)
272-
# $job = Start-Job -ScriptBlock {
273-
# param($path, $testType, $techStack, $logPath)
274-
# & $path --silent $testType $techStack 2>&1 | Tee-Object -FilePath $logPath -Append
275-
# } -ArgumentList ".\win\run.ps1", $testType, $techStack, $logPath
276-
#
277-
# # Wait for job with 600 second timeout
278-
# $timeout = New-TimeSpan -Seconds 600
279-
# $completed = Wait-Job -Job $job -Timeout 600
280-
#
281-
# if ($completed) {
282-
# $result = Receive-Job -Job $job
283-
# if ($job.State -eq "Completed") {
284-
# Write-Host "✅ .\win\run.ps1 --silent $testType $techStack completed successfully"
285-
# } else {
286-
# Write-Host "⚠️ .\win\run.ps1 --silent $testType $techStack exited with state: $($job.State)"
287-
# if (Test-Path $logPath) {
288-
# Write-Host "Log output (last 20 lines):"
289-
# Get-Content -Path $logPath -Tail 20
290-
# }
291-
# }
292-
# } else {
293-
# Write-Host "⚠️ .\win\run.ps1 --silent $testType $techStack timed out after 600 seconds"
294-
# Stop-Job -Job $job
295-
# if (Test-Path $logPath) {
296-
# Write-Host "Log output (last 20 lines):"
297-
# Get-Content -Path $logPath -Tail 20
298-
# }
299-
# }
300-
#
301-
# Remove-Job -Job $job -Force
302-
# }
303-
#
304-
# Write-Host "✅ All integration tests completed"
305-
#
306-
# - name: Upload BrowserStack Logs as Artifacts
307-
# if: always()
308-
# uses: actions/upload-artifact@v4
309-
# with:
310-
# name: browserstack-logs-windows
311-
# path: |
312-
# C:\Users\runneradmin\.browserstack\NOW\logs\
313-
# C:\Temp\run_test_*.log
314-
# retention-days: 30
315-
# if-no-files-found: ignore
174+
test-windows:
175+
name: Test win/run.ps1 on Windows
176+
runs-on: windows-latest
177+
timeout-minutes: 15
178+
environment: BrowserStack
179+
steps:
180+
- name: Checkout code
181+
uses: actions/checkout@v4
182+
- name: Set up Python 3.12
183+
uses: actions/setup-python@v5
184+
with:
185+
python-version: '3.12'
186+
- name: Check PowerShell version
187+
run: |
188+
$PSVersionTable.PSVersion
189+
Write-Host "✅ PowerShell version check complete"
190+
191+
- name: Validate PowerShell script syntax
192+
run: |
193+
Write-Host "Validating win/run.ps1 syntax..."
194+
$ScriptPath = "win/run.ps1"
195+
$null = [System.Management.Automation.PSParser]::Tokenize((Get-Content $ScriptPath), [ref]$null)
196+
Write-Host "✅ win/run.ps1 syntax is valid"
197+
198+
- name: Validate supporting PowerShell scripts syntax
199+
run: |
200+
Write-Host "Validating supporting PowerShell scripts..."
201+
$Scripts = @("win/proxy-check.ps1")
202+
foreach ($Script in $Scripts) {
203+
$null = [System.Management.Automation.PSParser]::Tokenize((Get-Content $Script), [ref]$null)
204+
Write-Host "✅ $Script syntax is valid"
205+
}
206+
207+
- name: Run PSScriptAnalyzer
208+
run: |
209+
Write-Host "Installing PSScriptAnalyzer..."
210+
Install-Module -Name PSScriptAnalyzer -Force -SkipPublisherCheck -ErrorAction SilentlyContinue
211+
Write-Host "Running PSScriptAnalyzer..."
212+
Invoke-ScriptAnalyzer -Path "win/run.ps1" -Recurse -ReportSummary || $true
213+
Write-Host "✅ PSScriptAnalyzer analysis complete"
214+
215+
- name: Check script file encoding
216+
run: |
217+
Write-Host "Checking PowerShell script encoding..."
218+
$ScriptPath = "win/run.ps1"
219+
$Encoding = (Get-Item $ScriptPath).EncodingInfo
220+
Write-Host "File encoding: $Encoding"
221+
Write-Host "✅ Encoding check complete"
222+
223+
- name: Verify required dependencies
224+
run: |
225+
Write-Host "Checking required dependencies..."
226+
if (Get-Command curl.exe -ErrorAction SilentlyContinue) { Write-Host "✅ curl found" }
227+
if (Get-Command git.exe -ErrorAction SilentlyContinue) { Write-Host "✅ git found" }
228+
Write-Host "✅ PowerShell dependencies verified"
229+
230+
- name: Integration Test - Silent Mode Execution
231+
if: success()
232+
env:
233+
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
234+
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
235+
TURL: https://bstackdemo.com
236+
run: |
237+
Write-Host "Running integration tests in silent mode..."
238+
239+
# Set default values if secrets are not provided
240+
$BrowserStackUsername = if ($env:BROWSERSTACK_USERNAME) { $env:BROWSERSTACK_USERNAME } else { "test_user" }
241+
$BrowserStackAccessKey = if ($env:BROWSERSTACK_ACCESS_KEY) { $env:BROWSERSTACK_ACCESS_KEY } else { "test_key" }
242+
$TestUrl = $env:TURL
243+
244+
# Export environment variables
245+
$env:BROWSERSTACK_USERNAME = $BrowserStackUsername
246+
$env:BROWSERSTACK_ACCESS_KEY = $BrowserStackAccessKey
247+
$env:TURL = $TestUrl
248+
249+
# Test configurations
250+
$testConfigs = @(
251+
@("web", "java"),
252+
@("app", "java"),
253+
@("web", "python"),
254+
@("app", "python"),
255+
@("web", "nodejs"),
256+
@("app", "nodejs")
257+
)
258+
259+
foreach ($config in $testConfigs) {
260+
$testType = $config[0]
261+
$techStack = $config[1]
262+
263+
Write-Host "================================"
264+
Write-Host "Testing: .\win\run.ps1 --silent $testType $techStack"
265+
Write-Host "================================"
266+
267+
# Create log file path
268+
$logPath = "C:\Temp\run_test_${testType}_${techStack}.log"
269+
New-Item -ItemType Directory -Path "C:\Temp" -Force -ErrorAction SilentlyContinue | Out-Null
270+
271+
# Run with timeout (using job for timeout capability)
272+
$job = Start-Job -ScriptBlock {
273+
param($path, $testType, $techStack, $logPath)
274+
& $path --silent $testType $techStack 2>&1 | Tee-Object -FilePath $logPath -Append
275+
} -ArgumentList ".\win\run.ps1", $testType, $techStack, $logPath
276+
277+
# Wait for job with 600 second timeout
278+
$timeout = New-TimeSpan -Seconds 600
279+
$completed = Wait-Job -Job $job -Timeout 600
280+
281+
if ($completed) {
282+
$result = Receive-Job -Job $job
283+
if ($job.State -eq "Completed") {
284+
Write-Host "✅ .\win\run.ps1 --silent $testType $techStack completed successfully"
285+
} else {
286+
Write-Host "⚠️ .\win\run.ps1 --silent $testType $techStack exited with state: $($job.State)"
287+
if (Test-Path $logPath) {
288+
Write-Host "Log output (last 20 lines):"
289+
Get-Content -Path $logPath -Tail 20
290+
}
291+
}
292+
} else {
293+
Write-Host "⚠️ .\win\run.ps1 --silent $testType $techStack timed out after 600 seconds"
294+
Stop-Job -Job $job
295+
if (Test-Path $logPath) {
296+
Write-Host "Log output (last 20 lines):"
297+
Get-Content -Path $logPath -Tail 20
298+
}
299+
}
300+
301+
Remove-Job -Job $job -Force
302+
}
303+
304+
Write-Host "✅ All integration tests completed"
305+
306+
- name: Sync BrowserStack logs to workspace
307+
if: always()
308+
run: |
309+
mkdir -p ${{ github.workspace }}/bs-logs
310+
if [ -d ~/.browserstack/NOW/logs ]; then
311+
cp -R ~/.browserstack/NOW/logs/* ${{ github.workspace }}/bs-logs/ || true
312+
else
313+
echo "No logs found in ~/.browserstack/NOW/logs"
314+
fi
315+
316+
- name: Upload BrowserStack Logs as Artifacts
317+
if: always()
318+
uses: actions/upload-artifact@v4
319+
with:
320+
name: browserstack-logs-windows
321+
path: |
322+
C:\Users\runneradmin\.browserstack\NOW\logs\
323+
C:\Temp\run_test_*.log
324+
retention-days: 30
325+
if-no-files-found: ignore
316326

317327
test-linux:
318328
name: Test mac/run.sh on Linux

0 commit comments

Comments
 (0)