diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fc34a4c..94ddd4d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,15 +13,42 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Download Tectonic - run: - wget "https://github.com/tectonic-typesetting/tectonic/releases/download/tectonic%400.15.0/tectonic-0.15.0-x86_64-unknown-linux-musl.tar.gz" && - tar -xf "tectonic-0.15.0-x86_64-unknown-linux-musl.tar.gz" + # Could instead install `texlive-full`, but that takes ~20 minutes. + # We'll specify the packages we need manually. + - name: "Install TeXLive" + run: | + sudo apt update + DEBIAN_FRONTEND=noninteractive \ + sudo apt install --yes \ + texlive texlive-xetex \ + texlive-games texlive-fonts-extra texlive-latex-extra \ + texlive-pictures texlive-pstricks - - name: Build LaTeX handouts - run: bash build.sh + - name: "Download Typst" + run: | + wget -q "https://github.com/typst/typst/releases/download/v0.12.0/typst-x86_64-unknown-linux-musl.tar.xz" + tar -xf "typst-x86_64-unknown-linux-musl.tar.xz" + mv "typst-x86_64-unknown-linux-musl/typst" . + rm "typst-x86_64-unknown-linux-musl.tar.xz" + rm -dr "typst-x86_64-unknown-linux-musl" - - uses: actions/upload-artifact@v3 + # Builds all handouts, LaTeX and Typst + - name: "Build handouts" + run: TYPST_PATH="$(pwd)/typst" python tools/build/main.py + + # Upload logs, even if build fails. + # LaTeX stdout/stderr isn't always helpful. + - name: "Upload LaTeX logs" + uses: actions/upload-artifact@v3 + if: always() + with: + name: "LaTeX logs" + path: "**/*.log" + retention-days: 1 + + # Upload build output + - name: "Upload output" + uses: actions/upload-artifact@v3 with: name: output path: "output/*" diff --git a/tools/build/main.py b/tools/build/main.py index 2bd7257..a19e6ad 100644 --- a/tools/build/main.py +++ b/tools/build/main.py @@ -16,10 +16,15 @@ ROOT: Path = Path(os.getcwd()) ### CONFIGURATION OUT_DIR: Path = ROOT / "output" -TYPST_PATH = "typst" -XETEX_PATH = "xelatex" +TYPST_PATH: str = "typst" +XETEX_PATH: str = "xelatex" ### END CONFIGURATION +# Allow path override +_env = os.environ.get("TYPST_PATH") +if isinstance(_env, str): + TYPST_PATH = _env + def log(msg): print(f"[BUILD.PY] {msg}") @@ -208,7 +213,11 @@ def build_xetex(source_dir: Path, out_subdir: Path) -> IndexEntry | None: stderr=subprocess.PIPE, ) - shutil.copy(source_dir / "main.pdf", f"{out}/{meta['title']}.pdf") + try: + shutil.copy(source_dir / "main.pdf", f"{out}/{meta['title']}.pdf") + except Exception as e: + log(f"Error: {e}") + log_error(res) if res.returncode != 0: log_error(res) @@ -227,7 +236,11 @@ def build_xetex(source_dir: Path, out_subdir: Path) -> IndexEntry | None: stderr=subprocess.PIPE, ) - shutil.copy(source_dir / "main.pdf", f"{out}/{meta['title']}.sols.pdf") + try: + shutil.copy(source_dir / "main.pdf", f"{out}/{meta['title']}.sols.pdf") + except Exception as e: + log(f"Error: {e}") + log_error(res) if res.returncode != 0: log_error(res) @@ -278,6 +291,7 @@ def build_dir(base: str, out_sub: str, index: list[IndexEntry]): index: list[IndexEntry] = [] +index.extend(build_dir("Warm-Ups", "Warm-Ups", index)) index.extend(build_dir("Advanced", "Advanced", index)) index.extend(build_dir("Intermediate", "Intermediate", index))