mirror of
https://github.com/ntdevlabs/tiny11builder.git
synced 2025-12-19 09:54:15 +00:00
Fix workflow logic errors and improve error handling
- Fix path resolution using GITHUB_WORKSPACE instead of calculated paths - Improve error handling with proper exit code checking - Add BUILD_SUCCESS flag to track script completion - Increase wait time for ISO file to 20 minutes - Improve ISO search logic to check multiple locations - Add better logging and error messages - Fix ErrorActionPreference to Continue for better error recovery - Add conditional check for ISO_PATH before upload
This commit is contained in:
parent
b8bb028236
commit
74b3931a1d
3 changed files with 142 additions and 47 deletions
29
.github/scripts/run-coremaker-automated.ps1
vendored
29
.github/scripts/run-coremaker-automated.ps1
vendored
|
|
@ -12,12 +12,22 @@ param(
|
||||||
[bool]$EnableDotNet35 = $false
|
[bool]$EnableDotNet35 = $false
|
||||||
)
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Continue' # Change to Continue to allow script to continue on errors
|
||||||
$scriptRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
|
||||||
|
# Use GITHUB_WORKSPACE if available, otherwise calculate from PSScriptRoot
|
||||||
|
if ($env:GITHUB_WORKSPACE) {
|
||||||
|
$scriptRoot = $env:GITHUB_WORKSPACE
|
||||||
|
} else {
|
||||||
|
$scriptRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||||
|
}
|
||||||
|
|
||||||
$scriptPath = Join-Path $scriptRoot "tiny11Coremaker.ps1"
|
$scriptPath = Join-Path $scriptRoot "tiny11Coremaker.ps1"
|
||||||
|
|
||||||
if (-not (Test-Path $scriptPath)) {
|
if (-not (Test-Path $scriptPath)) {
|
||||||
Write-Error "Script not found: $scriptPath"
|
Write-Error "Script not found: $scriptPath"
|
||||||
|
Write-Host "PSScriptRoot: $PSScriptRoot"
|
||||||
|
Write-Host "scriptRoot: $scriptRoot"
|
||||||
|
Write-Host "Current location: $(Get-Location)"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,11 +106,22 @@ $scriptContent | Out-File -FilePath $tempScriptPath -Append -Encoding UTF8
|
||||||
try {
|
try {
|
||||||
# Change to script directory
|
# Change to script directory
|
||||||
Push-Location $scriptRoot
|
Push-Location $scriptRoot
|
||||||
# Run the modified script
|
Write-Host "Changed to directory: $(Get-Location)"
|
||||||
|
Write-Host "Running script: $tempScriptPath"
|
||||||
|
|
||||||
|
# Run the modified script and capture exit code
|
||||||
& $tempScriptPath
|
& $tempScriptPath
|
||||||
|
$scriptExitCode = $LASTEXITCODE
|
||||||
|
|
||||||
|
if ($scriptExitCode -ne 0 -and $scriptExitCode -ne $null) {
|
||||||
|
Write-Error "Script exited with code: $scriptExitCode"
|
||||||
|
exit $scriptExitCode
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
Write-Error "Error running script: $_"
|
Write-Error "Error running script: $_"
|
||||||
throw
|
Write-Error "Exception: $($_.Exception.Message)"
|
||||||
|
Write-Error "Line: $($_.InvocationInfo.ScriptLineNumber)"
|
||||||
|
exit 1
|
||||||
} finally {
|
} finally {
|
||||||
Pop-Location
|
Pop-Location
|
||||||
# Cleanup temp script
|
# Cleanup temp script
|
||||||
|
|
|
||||||
28
.github/scripts/run-maker-automated.ps1
vendored
28
.github/scripts/run-maker-automated.ps1
vendored
|
|
@ -12,12 +12,22 @@ param(
|
||||||
[string]$ScratchDrive = ""
|
[string]$ScratchDrive = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Continue' # Change to Continue to allow script to continue on errors
|
||||||
$scriptRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
|
||||||
|
# Use GITHUB_WORKSPACE if available, otherwise calculate from PSScriptRoot
|
||||||
|
if ($env:GITHUB_WORKSPACE) {
|
||||||
|
$scriptRoot = $env:GITHUB_WORKSPACE
|
||||||
|
} else {
|
||||||
|
$scriptRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||||
|
}
|
||||||
|
|
||||||
$scriptPath = Join-Path $scriptRoot "tiny11maker.ps1"
|
$scriptPath = Join-Path $scriptRoot "tiny11maker.ps1"
|
||||||
|
|
||||||
if (-not (Test-Path $scriptPath)) {
|
if (-not (Test-Path $scriptPath)) {
|
||||||
Write-Error "Script not found: $scriptPath"
|
Write-Error "Script not found: $scriptPath"
|
||||||
|
Write-Host "PSScriptRoot: $PSScriptRoot"
|
||||||
|
Write-Host "scriptRoot: $scriptRoot"
|
||||||
|
Write-Host "Current location: $(Get-Location)"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,17 +103,23 @@ $scriptContent | Out-File -FilePath $tempScriptPath -Append -Encoding UTF8
|
||||||
try {
|
try {
|
||||||
# Change to script directory
|
# Change to script directory
|
||||||
Push-Location $scriptRoot
|
Push-Location $scriptRoot
|
||||||
|
Write-Host "Changed to directory: $(Get-Location)"
|
||||||
# Use wrapper approach to ensure all prompts are handled
|
|
||||||
# Even though tiny11maker supports ISO parameter, it still prompts for image index
|
|
||||||
Write-Host "Using wrapper approach to handle all prompts automatically"
|
Write-Host "Using wrapper approach to handle all prompts automatically"
|
||||||
|
Write-Host "Running script: $tempScriptPath"
|
||||||
|
|
||||||
# Run the wrapper script which has Read-Host override
|
# Run the wrapper script which has Read-Host override
|
||||||
& $tempScriptPath
|
& $tempScriptPath
|
||||||
|
$scriptExitCode = $LASTEXITCODE
|
||||||
|
|
||||||
|
if ($scriptExitCode -ne 0 -and $scriptExitCode -ne $null) {
|
||||||
|
Write-Error "Script exited with code: $scriptExitCode"
|
||||||
|
exit $scriptExitCode
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
Write-Error "Error running script: $_"
|
Write-Error "Error running script: $_"
|
||||||
throw
|
Write-Error "Exception: $($_.Exception.Message)"
|
||||||
|
Write-Error "Line: $($_.InvocationInfo.ScriptLineNumber)"
|
||||||
|
exit 1
|
||||||
} finally {
|
} finally {
|
||||||
Pop-Location
|
Pop-Location
|
||||||
# Cleanup temp script
|
# Cleanup temp script
|
||||||
|
|
|
||||||
132
.github/workflows/build-tiny11.yml
vendored
132
.github/workflows/build-tiny11.yml
vendored
|
|
@ -182,48 +182,83 @@ jobs:
|
||||||
Write-Host "Running script: $scriptType.ps1"
|
Write-Host "Running script: $scriptType.ps1"
|
||||||
Write-Host "ISO Drive: $isoDrive"
|
Write-Host "ISO Drive: $isoDrive"
|
||||||
Write-Host "Scratch Drive: $scratchDrive"
|
Write-Host "Scratch Drive: $scratchDrive"
|
||||||
|
Write-Host "Working Directory: $PWD"
|
||||||
|
Write-Host "GITHUB_WORKSPACE: $env:GITHUB_WORKSPACE"
|
||||||
|
|
||||||
|
# Use GITHUB_WORKSPACE as script root (repo root)
|
||||||
|
$scriptRoot = $env:GITHUB_WORKSPACE
|
||||||
|
if (-not $scriptRoot) {
|
||||||
|
$scriptRoot = $PSScriptRoot
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Script Root: $scriptRoot"
|
||||||
|
|
||||||
# Set execution policy
|
# Set execution policy
|
||||||
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force
|
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force
|
||||||
|
|
||||||
# Run the appropriate script
|
# Verify wrapper scripts exist
|
||||||
|
$makerWrapper = Join-Path $scriptRoot ".github\scripts\run-maker-automated.ps1"
|
||||||
|
$coreWrapper = Join-Path $scriptRoot ".github\scripts\run-coremaker-automated.ps1"
|
||||||
|
|
||||||
if ("$scriptType" -eq "tiny11maker") {
|
if ("$scriptType" -eq "tiny11maker") {
|
||||||
# tiny11maker supports parameters but still has image index prompt
|
if (-not (Test-Path $makerWrapper)) {
|
||||||
Write-Host "Using tiny11maker with parameters and automation"
|
Write-Error "Wrapper script not found: $makerWrapper"
|
||||||
|
|
||||||
# Create wrapper to handle image index selection
|
|
||||||
$wrapperPath = Join-Path $PSScriptRoot ".github\scripts\run-maker-automated.ps1"
|
|
||||||
if (-not (Test-Path $wrapperPath)) {
|
|
||||||
Write-Error "Wrapper script not found: $wrapperPath"
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
$wrapperParams = @{
|
|
||||||
ISODrive = "$isoDrive`:"
|
|
||||||
}
|
|
||||||
if ("$scratchDrive" -ne "") {
|
|
||||||
$wrapperParams.ScratchDrive = "$scratchDrive"
|
|
||||||
}
|
|
||||||
|
|
||||||
& $wrapperPath @wrapperParams
|
|
||||||
} else {
|
} else {
|
||||||
# For tiny11Coremaker, use the wrapper script
|
if (-not (Test-Path $coreWrapper)) {
|
||||||
Write-Host "Using tiny11Coremaker with automation wrapper"
|
Write-Error "Wrapper script not found: $coreWrapper"
|
||||||
$wrapperPath = Join-Path $PSScriptRoot ".github\scripts\run-coremaker-automated.ps1"
|
|
||||||
if (-not (Test-Path $wrapperPath)) {
|
|
||||||
Write-Error "Wrapper script not found: $wrapperPath"
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
& $wrapperPath -ISODrive "$isoDrive`:" -EnableDotNet35 ${{ inputs.enable_dotnet35 }}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Run the appropriate script with proper error handling
|
||||||
|
$exitCode = 0
|
||||||
|
try {
|
||||||
|
if ("$scriptType" -eq "tiny11maker") {
|
||||||
|
Write-Host "Using tiny11maker with parameters and automation"
|
||||||
|
$wrapperParams = @{
|
||||||
|
ISODrive = "$isoDrive`:"
|
||||||
|
}
|
||||||
|
if ("$scratchDrive" -ne "") {
|
||||||
|
$wrapperParams.ScratchDrive = "$scratchDrive"
|
||||||
|
}
|
||||||
|
& $makerWrapper @wrapperParams
|
||||||
|
$exitCode = $LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
Write-Host "Using tiny11Coremaker with automation wrapper"
|
||||||
|
& $coreWrapper -ISODrive "$isoDrive`:" -EnableDotNet35 ${{ inputs.enable_dotnet35 }}
|
||||||
|
$exitCode = $LASTEXITCODE
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($exitCode -ne 0) {
|
||||||
|
Write-Error "Script failed with exit code: $exitCode"
|
||||||
|
exit $exitCode
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
Write-Error "Error running script: $_"
|
||||||
|
Write-Error "Exception: $($_.Exception.Message)"
|
||||||
|
Write-Error "StackTrace: $($_.ScriptStackTrace)"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Script completed successfully"
|
||||||
|
Write-Host "BUILD_SUCCESS=true" >> $env:GITHUB_ENV
|
||||||
|
|
||||||
- name: Wait for script completion and find ISO
|
- name: Wait for script completion and find ISO
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
Write-Host "Waiting for script to complete..."
|
Write-Host "Checking script completion status..."
|
||||||
|
|
||||||
# Wait for script to finish (check every 30 seconds, max 10 minutes)
|
# Check if script was marked as successful
|
||||||
$maxWaitTime = 600 # 10 minutes
|
if ($env:BUILD_SUCCESS -ne "true") {
|
||||||
|
Write-Warning "Script may not have completed successfully"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Waiting for ISO file..."
|
||||||
|
|
||||||
|
# Wait for script to finish (check every 30 seconds, max 20 minutes)
|
||||||
|
$maxWaitTime = 1200 # 20 minutes
|
||||||
$checkInterval = 30 # 30 seconds
|
$checkInterval = 30 # 30 seconds
|
||||||
$elapsed = 0
|
$elapsed = 0
|
||||||
$isoFound = $false
|
$isoFound = $false
|
||||||
|
|
@ -232,10 +267,14 @@ jobs:
|
||||||
Start-Sleep -Seconds $checkInterval
|
Start-Sleep -Seconds $checkInterval
|
||||||
$elapsed += $checkInterval
|
$elapsed += $checkInterval
|
||||||
|
|
||||||
# Check for ISO file in script root
|
# Check for ISO file in script root (repo root)
|
||||||
$isoFiles = Get-ChildItem -Path $PSScriptRoot -Filter "tiny11.iso" -ErrorAction SilentlyContinue
|
$scriptRoot = $env:GITHUB_WORKSPACE
|
||||||
|
Write-Host "Checking for ISO in: $scriptRoot ($elapsed seconds elapsed)"
|
||||||
|
|
||||||
|
$isoFiles = Get-ChildItem -Path $scriptRoot -Filter "tiny11.iso" -ErrorAction SilentlyContinue
|
||||||
if ($isoFiles) {
|
if ($isoFiles) {
|
||||||
Write-Host "Found ISO file: $($isoFiles.FullName)"
|
Write-Host "Found ISO file: $($isoFiles.FullName)"
|
||||||
|
Write-Host "ISO size: $([math]::Round($isoFiles.Length / 1GB, 2)) GB"
|
||||||
Write-Host "ISO_PATH=$($isoFiles.FullName)" >> $env:GITHUB_ENV
|
Write-Host "ISO_PATH=$($isoFiles.FullName)" >> $env:GITHUB_ENV
|
||||||
$isoFound = $true
|
$isoFound = $true
|
||||||
break
|
break
|
||||||
|
|
@ -246,32 +285,51 @@ jobs:
|
||||||
|
|
||||||
if (-not $isoFound) {
|
if (-not $isoFound) {
|
||||||
Write-Host "ISO file not found after waiting. Checking all locations..."
|
Write-Host "ISO file not found after waiting. Checking all locations..."
|
||||||
# Also check in scratch drive if specified
|
|
||||||
|
# Check repo root
|
||||||
|
$scriptRoot = $env:GITHUB_WORKSPACE
|
||||||
|
Write-Host "Checking repo root: $scriptRoot"
|
||||||
|
Get-ChildItem -Path $scriptRoot -Filter "*.iso" -ErrorAction SilentlyContinue | ForEach-Object {
|
||||||
|
Write-Host "Found ISO: $($_.FullName)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check scratch drive if specified
|
||||||
$scratchDrive = "${{ inputs.scratch_drive }}"
|
$scratchDrive = "${{ inputs.scratch_drive }}"
|
||||||
if ($scratchDrive -ne "") {
|
if ($scratchDrive -ne "") {
|
||||||
$scratchPath = "$scratchDrive`:\tiny11\sources"
|
$scratchPath = "$scratchDrive`:\tiny11"
|
||||||
|
Write-Host "Checking scratch path: $scratchPath"
|
||||||
if (Test-Path $scratchPath) {
|
if (Test-Path $scratchPath) {
|
||||||
Write-Host "Checking scratch path: $scratchPath"
|
Get-ChildItem -Path $scratchPath -Filter "*.iso" -Recurse -ErrorAction SilentlyContinue | ForEach-Object {
|
||||||
|
Write-Host "Found ISO in scratch: $($_.FullName)"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Final check
|
# Check system drive
|
||||||
$isoFiles = Get-ChildItem -Path $PSScriptRoot -Filter "tiny11.iso" -ErrorAction SilentlyContinue
|
$systemDrive = $env:SystemDrive
|
||||||
|
$systemTiny11Path = "$systemDrive\tiny11"
|
||||||
|
if (Test-Path $systemTiny11Path) {
|
||||||
|
Write-Host "Checking system drive: $systemTiny11Path"
|
||||||
|
Get-ChildItem -Path $systemTiny11Path -Filter "*.iso" -Recurse -ErrorAction SilentlyContinue | ForEach-Object {
|
||||||
|
Write-Host "Found ISO in system drive: $($_.FullName)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Final check in repo root
|
||||||
|
$isoFiles = Get-ChildItem -Path $scriptRoot -Filter "tiny11.iso" -ErrorAction SilentlyContinue
|
||||||
if ($isoFiles) {
|
if ($isoFiles) {
|
||||||
Write-Host "Found ISO file: $($isoFiles.FullName)"
|
Write-Host "Found ISO file: $($isoFiles.FullName)"
|
||||||
Write-Host "ISO_PATH=$($isoFiles.FullName)" >> $env:GITHUB_ENV
|
Write-Host "ISO_PATH=$($isoFiles.FullName)" >> $env:GITHUB_ENV
|
||||||
} else {
|
} else {
|
||||||
Write-Error "Failed to find tiny11.iso file after waiting $elapsed seconds"
|
Write-Error "Failed to find tiny11.iso file after waiting $elapsed seconds"
|
||||||
Write-Host "Checking for any ISO files in script root..."
|
Write-Host "Please check the build logs above for script execution errors"
|
||||||
Get-ChildItem -Path $PSScriptRoot -Filter "*.iso" | ForEach-Object {
|
|
||||||
Write-Host "Found ISO: $($_.FullName)"
|
|
||||||
}
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- name: Upload Tiny11 ISO Artifact
|
- name: Upload Tiny11 ISO Artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
if: env.ISO_PATH != ''
|
||||||
with:
|
with:
|
||||||
name: tiny11-iso
|
name: tiny11-iso
|
||||||
path: ${{ env.ISO_PATH }}
|
path: ${{ env.ISO_PATH }}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue