1+ # cd to the directory of this script
2+ $scriptPath = Split-Path - Parent $MyInvocation.MyCommand.Definition
3+ $rootPath = Split-Path - Parent $scriptPath
4+ $outputFolder = " $rootPath /output"
5+ if (Test-Path $outputFolder ) {
6+ Remove-Item $outputFolder - Recurse - Force
7+ }
8+ New-Item - ItemType Directory - Path $outputFolder
9+
10+ Set-Location $rootPath
11+
12+ # list all newly added notebooks by comparing with the main branch
13+ # $mainBranch = "main"
14+ # $notebooks = git diff --name-only $mainBranch | Where-Object { $_ -like "*.ipynb" }
15+ $notebooks = Get-ChildItem - Path $rootPath - Recurse - Include * .ipynb | Where-Object { $_.FullName -notlike " *output*" }
16+
17+ # skip notebooks that are known to fail
18+ $notebooks_to_skip = @ (
19+ " 14-Methods and Members.ipynb" ,
20+ " 02-Code Cells.ipynb"
21+ )
22+
23+ $notebooks = $notebooks | Where-Object { $notebooks_to_skip -notcontains $_.Name }
24+ # list all notebooks and print out
25+ foreach ($notebook in $notebooks ) {
26+ Write-Host $notebook
27+ }
28+
29+ # for each notebook, run it using dotnet perl. Check the exit code and print out the result
30+ # if the exit code is not 0, exit the script with exit code 1
31+ $failNotebooks = @ ()
32+ $exitCode = 0
33+ foreach ($notebook in $notebooks ) {
34+ Write-Host " Running $notebook "
35+ # get notebook name with extension
36+ $name = Split-Path - Leaf $notebook
37+ Write-Host " Name: $name "
38+ $notebookFolder = Split-Path - Parent $notebook
39+ $outputPath = " $outputFolder \$notebookFolder "
40+ Set-Location $notebookFolder
41+ $result = dotnet repl -- run $name -- exit-after - run
42+ Write-Host $result
43+ if ($LASTEXITCODE -ne 0 ) {
44+ Write-Host " Failed to run $notebook "
45+ $failNotebooks += $notebook
46+ $exitCode = 1
47+ }
48+ else {
49+ Write-Host " Successfully ran $notebook "
50+ }
51+ Set-Location $rootPath
52+ }
53+
54+ Write-Host " Failed notebooks:"
55+ foreach ($notebook in $failNotebooks ) {
56+ Write-Host $notebook
57+ }
58+
59+ exit $exitCode
0 commit comments