Skip to content

Commit 6dc152e

Browse files
committed
Fix silent slide-build failures in CI
build.ps1 ran every pandoc compile in a Start-Job but never inspected the job results, so failed compilations were swallowed and a partial build.zip was shipped. On CI the unbounded parallel lualatex/beamer compiles exhausted runner memory and were killed, dropping all slide PDFs while the workflow stayed green. - Throttle parallelism (ForEach-Object -Parallel -ThrottleLimit 2) so heavy beamer compiles no longer OOM the runner. - Check each pandoc exit code / output file and fail the build on any error, including the combined script.pdf step. - Pre-create output directories in the main thread to avoid worker races. Also temporarily add this branch to the workflow push trigger to validate the build; create_release stays guarded by refs/heads/2026 so no release is made.
1 parent b385495 commit 6dc152e

2 files changed

Lines changed: 50 additions & 18 deletions

File tree

.github/workflows/create-release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
push:
55
branches:
66
- "2026"
7+
# Temporary: validate the build on this CI fix branch (no release is created
8+
# because the create_release job is guarded by refs/heads/2026). Remove on merge.
9+
- "ci/fix-slide-build"
710
workflow_dispatch:
811

912
jobs:

build.ps1

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,56 @@ else {
1010
$zip = 1
1111
}
1212

13-
$jobs = @()
14-
1513
Write-Host "Building PDFs for the following files:"
1614
foreach ($arg in $files) {
1715
Write-Host "- $arg"
1816
}
1917

2018

21-
foreach ($arg in $files) {
22-
$pdfName = "build/" + ((Get-Item $arg).Directory.Basename) + "/" + ((Get-Item $arg).Basename) + ".pdf"
19+
# Pre-compute targets and create output directories in the main thread to avoid
20+
# races between parallel workers creating the same directory.
21+
$targets = foreach ($arg in $files) {
22+
$item = Get-Item $arg
23+
$pdfName = "build/" + $item.Directory.BaseName + "/" + $item.BaseName + ".pdf"
2324
New-Item -ItemType Directory -Path (Split-Path $pdfName) -Force > $null
25+
[PSCustomObject]@{
26+
Source = $item.FullName
27+
Pdf = $pdfName
28+
Type = $item.Directory.Name
29+
}
30+
}
31+
32+
# Build PDFs in parallel, but throttle concurrency: unbounded parallel lualatex
33+
# (especially the heavy beamer slide decks) exhausts memory on CI runners and the
34+
# processes get killed, silently producing no output.
35+
$results = $targets | ForEach-Object -ThrottleLimit 2 -Parallel {
36+
# Parallel runspaces do not reliably inherit the caller's location.
37+
Set-Location $using:currentDir
38+
$t = $_
2439

25-
$jobs += Start-Job -ScriptBlock {
26-
param($arg, $pdfName)
27-
$pdfType = (Get-ChildItem $arg).Directory.Name
28-
if ($pdfType -eq "Slides") {
29-
Write-Host "Building slides for $arg"
30-
pandoc -f markdown+smart+yaml_metadata_block+rebase_relative_paths --toc --slide-level 2 --number-section --pdf-engine lualatex -t beamer -H preamble.tex -F pandoc-plantuml -o $pdfName $arg
31-
}
32-
else {
33-
pandoc -f markdown+smart+yaml_metadata_block+rebase_relative_paths --toc --toc-depth 1 --number-section --pdf-engine lualatex -F pandoc-plantuml -o $pdfName $arg
34-
}
35-
} -ArgumentList $arg, $pdfName
40+
if ($t.Type -eq "Slides") {
41+
Write-Host "Building slides for $($t.Source)"
42+
pandoc -f markdown+smart+yaml_metadata_block+rebase_relative_paths --toc --slide-level 2 --number-section --pdf-engine lualatex -t beamer -H preamble.tex -F pandoc-plantuml -o $t.Pdf $t.Source
43+
}
44+
else {
45+
Write-Host "Building document for $($t.Source)"
46+
pandoc -f markdown+smart+yaml_metadata_block+rebase_relative_paths --toc --toc-depth 1 --number-section --pdf-engine lualatex -F pandoc-plantuml -o $t.Pdf $t.Source
47+
}
48+
49+
[PSCustomObject]@{
50+
Pdf = $t.Pdf
51+
ExitCode = $LASTEXITCODE
52+
}
3653
}
3754

38-
Wait-Job $jobs
55+
# Fail the build if any PDF did not compile, instead of silently shipping a
56+
# partial result.
57+
$failed = $results | Where-Object { $_.ExitCode -ne 0 -or -not (Test-Path $_.Pdf) }
58+
if ($failed) {
59+
Write-Host "##[error]The following PDF builds failed:"
60+
$failed | ForEach-Object { Write-Host " - $($_.Pdf) (exit code $($_.ExitCode))" }
61+
exit 1
62+
}
3963

4064

4165

@@ -52,11 +76,16 @@ header-includes: |
5276
\fancyfoot[R]{Licensed under CC-BY-SA-4.0}
5377
..."
5478
pandoc -f markdown+smart+yaml_metadata_block+rebase_relative_paths --toc --toc-depth 1 --pdf-engine lualatex -F pandoc-plantuml --title="Vorlesung Webengineering" -o "build/script.pdf" $(Get-ChildItem -Recurse -Path Material/Slides -Filter *.md)
79+
$scriptExit = $LASTEXITCODE
5580
Remove-Item -Path "Material/Slides/99_Script.md" -Force
56-
81+
if ($scriptExit -ne 0 -or -not (Test-Path "build/script.pdf")) {
82+
Write-Host "##[error]Building build/script.pdf failed (exit code $scriptExit)"
83+
exit 1
84+
}
85+
5786
Set-Location .\build
5887
Compress-Archive -Force -Path .\* -DestinationPath ..\build.zip
5988
Set-Location $currentDir
6089
}
6190

62-
Remove-Item -Path "tex2pdf.-*" -Force -Recurse
91+
Remove-Item -Path "tex2pdf.-*" -Force -Recurse

0 commit comments

Comments
 (0)