Skip to content

Commit

Permalink
Modify error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederisk committed Nov 17, 2022
1 parent 6f2a1af commit 9a5ba04
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"callsh",
"chdir",
"cpuset",
"endgroup",
"kaggle",
"lvyufeng",
"namiyousef",
Expand Down
51 changes: 27 additions & 24 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,34 +104,37 @@ runs:
[String]$kernelName = '${{ inputs.title }}';
# check status
while ($true) {
[String]$status = (kaggle kernels status $kernelName 2>&1) -join [Environment]::NewLine;
# error
if ($status -like '*error*') {
kaggle kernels output $kernelName -p $kernelName;
[String]$fullMessage = (Get-Content -Path ([System.IO.Path]::Combine($kernelName, $kernelName + '.log')) -Raw | ConvertFrom-Json -AsHashtable | ForEach-Object -Process { $_['data'] }) -join '';
Write-Host -Object @"
FAIL: Test(s) failed. Full logs below:
try {
while ($true) {
[String]$status = (kaggle kernels status $kernelName 2>&1) -join ' ';
# error
if ($status -like '*error*') {
throw [Exception]::new('FAIL: Test(s) failed.');
}
# cancel
elseif ($status -like '*cancel*') {
throw [OperationCanceledException]::new('FAIL: Test(s) failed. The kaggle kernel has been canceled.');
}
#complete
elseif ($status -like '*complete*') {
Write-Host -Object 'SUCCESS: Kaggle Integration Tests!' -ForegroundColor Green | Out-Null;
break;
}
# running
else {
Start-Sleep -Seconds 3 | Out-Null;
}
}
}
catch {
kaggle kernels output $kernelName;
[String]$fullMessage = (Get-Content -Path ($kernelName + '.log') -Raw | ConvertFrom-Json -AsHashtable | ForEach-Object -Process { $_['data'] }) -join '';
Write-Host -Object @"
::group::Full log
$fullMessage
::endgroup::
"@ | Out-Null;
break;
}
# cancel
elseif ($status -like '*cancel*') {
Write-Host -Object '::error::FAIL: Test(s) failed. The kaggle kernel has been canceled.' | Out-Null;
break;
}
#complete
elseif ($status -like '*complete*') {
Write-Host -Object 'SUCCESS: Kaggle Integration Tests!' | Out-Null;
break;
}
# running
else {
Start-Sleep -Seconds 3 | Out-Null;
}
throw;
}
branding:
Expand Down

0 comments on commit 9a5ba04

Please sign in to comment.