Skip to content

feat(setup-environment): install-latex installs from the LaTeX package cache, as setup-latex does (#224) - #284

Merged
mmcky merged 13 commits into
mainfrom
feat/224-install-latex-cache
Nov 9, 2026
Merged

mmcky merged 13 commits into
mainfrom
feat/224-install-latex-cache

Conversation

@mmcky

@mmcky mmcky commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Important

This waits for Monday. It changes setup-environment/, which the scheduled lecture-matrix run of 2026-11-09 02:00 UTC uses from main, and which must still be v0.16.0's when that run lets v0 move. Merge it only after that run passes.

setup-environment's install-latex downloads TeX Live from the runner's Ubuntu mirror on every run, with a plain sudo apt-get update and sudo apt-get install. A slow mirror stalls that for hours without failing (the check on #224 has the numbers). #283, merged as d89b021, added setup-latex, which installs from a cache of the downloaded archives. This PR is the second of the two the maintainer chose on #224. It moves install-latex onto the same script, scripts/latex-packages.sh, and the same cache.

setup-environment cannot call setup-latex itself: uses: quantecon/actions/setup-latex@v0 would run the released copy, never this PR's, and ./setup-latex resolves against the caller's workspace. So it runs the script's three steps and the two actions/cache steps directly, as setup-latex does.

With install-latex: 'true', standard mode Before After
Exact cache hit apt-get update, then every package downloaded from the mirror The cached archives installed with no apt-get update and no download. latex-cache-hit: 'true'
Fallback restore (a new runner image, or a changed list) The same apt-get update, then only what the restored archives lack downloaded. latex-cache-hit: 'false'
Miss The same The same, then the archives saved straight after the install, except from a tag ref
A download, with apt-get update, that takes over 30 minutes Finishes slowly, after hours if need be Fails, with an annotation that says the mirror was slow. Fixed at 30 minutes, with no input, as the maintainer decided. setup-latex's download-timeout-minutes sets another limit
An entry in the list that is not an apt package name, such as --no-install-recommends Passed to apt, which reads it as an option Fails the job, before anything is installed
cache-version bumped A fresh Conda environment A fresh Conda environment, and the LaTeX packages downloaded afresh
Container mode Ignored Ignored

Who this reaches. No QuantEcon repository passes install-latex (code search, 2026-11-07). build-jupyter-cache passes it for a pdflatex build in standard mode, through setup-environment@v0, so it reaches that path only when v0 moves. Its three QuantEcon callers all run in a container: lecture-dp, test-lecture-theme-sphinx and the canary. So the entry is Changed, without the ⚠️ marker, as the maintainer decided. It says plainly that a download past 30 minutes now fails where it used to finish slowly.

Changes

File Change
setup-environment/action.yml The LaTeX step becomes five, all if: container-mode == 'false' && install-latex == 'true': read the list (latex-packages.sh list, with no packages input), prepare, actions/cache/restore@v6, install (with TIMEOUT_MINUTES: '30' and no input named), and actions/cache/save@v6. A new output, latex-cache-hit. The cache-version, install-latex and latex-requirements-file descriptions say what they now do. The summary's LaTeX line says whether the packages came from an exact cache match, an earlier cache, or no cache.
scripts/latex-packages.sh list takes PACKAGES_INPUT='' for an action with only a file input, so its messages never name a packages input. The header names both callers.
docs/user/actions/setup-environment.md The generated tables. Standard mode's step 6: the cache, the 30-minute limit, the save. "When to use it" points at setup-latex. "What fails the job" and Troubleshooting gain the bad-entry and timeout messages, and the missing and empty list messages as they now read. "The restored environment is broken" covers the LaTeX cache too.
docs/user/actions/setup-latex.md "With setup-environment" says install-latex now installs the same way.
.github/workflows/test-actions.yml env-latex-seed: a salted cache-version, so both caches miss: latex-cache-hit empty, and pdflatex works. env-latex-hit: on the seed's image, behind the refusing stand-in, latex-cache-hit == 'true', no request through apt, and pdflatex works; on another image, the fallback install instead, with a notice. Both are in harness-summary's needs:. latex-hit's stand-in setup moves into a script both jobs use. latex-timeout's stand-in now has to be listening before the job goes on.
.github/fixtures/setup-latex/refuse-mirrors.sh (new) Compares the runner image with the seed's. On the same image it starts apt-proxy.py in refuse mode, and fails, with the stand-in's output, if it is not listening after 10 s. Then it points apt's http and https proxy at it, shows that apt-get update's requests reach it, and clears its log.
docs/dev/TESTING.md setup-environment's row covers the two new jobs.
docs/dev/PLAN.md #224 leaves the "Environment and reproducibility" row.
CHANGELOG.md One entry under [Unreleased], ### Changed, after #270's.

Also fixed: a gap in #283's harness

Copilot found that the stand-in's readiness loop could fall through without the proxy ever listening, after which a hit job would blame the mirrors rather than the stand-in. #283 has the same loop inline, in latex-hit and latex-timeout. This PR closes the gap in both, as agreed with the organiser: latex-hit now uses refuse-mirrors.sh, which checks, and latex-timeout checks too. Both changes are to the harness only (8701883).

What I checked, and how

The new hit test fails on today's code. A throwaway branch from main ran env-latex-hit's shape: main's setup-environment with install-latex: 'true', behind the refusing stand-in (run 42349915064). apt-get update went through the stand-in, and the install failed with exit 100 on "Failed to fetch". The assertion failed: "the install made 160 requests through apt (above): it ran apt-get update or downloaded". The branch is deleted.

The script itself is #283's, where latex-seed, latex-hit, latex-fallback and latex-timeout pass on real runners: an exact hit with no request through the stand-in, a fallback that downloaded 121 kB, and the limit stopping a trickling mirror at 60 s. This PR's own run shows the same through setup-environment.

Callers. Code search of the org for install-latex finds only this repository's files, and for quantecon/actions/build-jupyter-cache finds three workflows, each with a container: image.

The local checks, with actionlint 1.7.12 and shellcheck 0.11.0. These are clean: python3 scripts/generate-docs.py --check --check-examples --actionlint …, actionlint, python3 scripts/lint-shell.py, and shellcheck on the fixture scripts. Against main, CHANGELOG.md gains two entries and loses no line, and everything from ## [0.16.0] down is unchanged.

What to watch after merge

Nothing at merge. No QuantEcon workflow uses setup-environment in standard mode with install-latex.

At the staged release of v0.17.0, the canary should exercise this path. Add it to #283's throwaway workflow: two standard-runner jobs, a miss and then a hit, each running [email protected] with install-latex: 'true' and the canary's latex-requirements.txt and environment.yml, then a build-lectures pdflatex build. In the second job's log, the summary should say "LaTeX: Installed from an exact cache match". The LaTeX steps should show no apt-get update group and no Get: line.

When v0 moves to v0.17.0, build-jupyter-cache's standard-mode pdflatex path gets the cache too.

Not in this PR

  • A timeout input on setup-environment: the maintainer chose a fixed 30 minutes. setup-latex has the input.
  • Moving any lecture repository onto either action: the maintainer's rollout, after v0.17.0.

Closes #224.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WT8bMXtFLfZrVgBA6ycXev

mmcky and others added 9 commits November 7, 2026 17:25
…ckages (#224)

A new action, setup-latex, installs the apt packages it is given and keeps
their downloaded .deb archives in the repository's Actions cache. The key
hashes the installed package set, so an exact hit installs the archives as
local files with no apt-get update and no download; a fallback restore or a
miss downloads only what the cache lacks, prunes, and saves. A
download-timeout-minutes limit (default 30) stops a mirror that trickles.

The work is in scripts/latex-packages.sh, which setup-environment's
install-latex will share.

Part of #224.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMXtFLfZrVgBA6ycXev
…s and the example list's header (#224)

ARCHITECTURE.md's parts table counts nine actions, and its shared scripts
row names the cached LaTeX install. security.md lists packages among the
inputs that may span lines. The example latex-requirements.txt names
setup-latex, and its format note now matches the parser: '#' starts a
comment anywhere on a line.

Part of #224.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMXtFLfZrVgBA6ycXev
Brings in #280. The CHANGELOG's [Unreleased] keeps both entries, setup-latex's
### Added above #280's ### Changed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMXtFLfZrVgBA6ycXev
apt fails at once a response whose length it knows to be wrong: a 1 GB
InRelease is past its 10 MB limit, and a .deb's must match the index. With
no length, apt reads until the connection closes, which the stand-in never
does, so only download-timeout-minutes stops it.

Part of #224.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMXtFLfZrVgBA6ycXev
…from a mirror (#224)

Two things a runner showed. apt refuses even local .deb files under
--no-download, so the completeness check always failed and every hit went
online. And given a local file whose version the image's lists also carry,
apt downloads that version from a mirror rather than read the file. With the
cache as apt's Dir::Cache::archives, it finds each archive there and fetches
nothing; a version only the file carries is read in place. The check is now
apt's --print-uris, which lists what it would fetch and reads no mirror.

Part of #224.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMXtFLfZrVgBA6ycXev
apt failed at once both a 1 GB length, past its 10 MB InRelease limit, and
a response with no length, so apt-get update never hung.

Part of #224.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMXtFLfZrVgBA6ycXev
Brings in #281. No conflict: the CHANGELOG's [Unreleased] keeps setup-latex's
### Added first, then #280's ### Changed and #281's ### Fixed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMXtFLfZrVgBA6ycXev
…e cache, as setup-latex does (#224)

install-latex now runs scripts/latex-packages.sh, as setup-latex does: an
exact hit installs the cached archives with no apt-get update and no
download; a fallback restore or a miss downloads what the cache lacks,
within a fixed 30 minutes, and saves straight after the install. A new
output, latex-cache-hit, says which. cache-version keys the LaTeX cache
too. The list's entries must be apt package names.

The harness gains env-latex-seed and env-latex-hit, the hit behind the
refusing stand-in. The stand-in's setup moves into refuse-mirrors.sh,
which latex-hit now uses too. PLAN.md drops #224.

Part of #224.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMXtFLfZrVgBA6ycXev
Copilot AI balanced review requested due to automatic review settings November 7, 2026 07:18
mmcky and others added 2 commits November 7, 2026 18:21
#224)

From Copilot's review of #283. On a self-hosted runner whose user cannot
sudo without a password, prepare now fails before it makes anything, with
an ::error:: that says apt needs root and how to give it, instead of sudo's
own message. latex-inputs runs prepare with a sudo stub that asks for a
password, and checks the message.

Part of #224.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMXtFLfZrVgBA6ycXev
Brings in #283's sudo check (e4bb43a). TESTING.md keeps this branch's
setup-environment row and #283's setup-latex row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMXtFLfZrVgBA6ycXev

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

🟡 Changes recommended

A moderate active issue remains in .github/fixtures/setup-latex/refuse-mirrors.sh where the proxy readiness loop may exit without verifying apt-proxy is actually listening, leading to misleading mirror-related failures and flakier, harder-to-debug CI unless an explicit post-loop check is added.

1 open issue
What changed in this PR

This pull request updates setup-environment’s optional install-latex path to use the same cached-archive installation flow introduced for setup-latex, reducing repeated TeX Live downloads from Ubuntu mirrors and adding harness coverage for cache-hit behavior (including a fixed 30‑minute download/update timeout).

Changes:

  • Refactors LaTeX installation in setup-environment into list/prepare/cache-restore/install/cache-save steps driven by scripts/latex-packages.sh.
  • Adds a latex-cache-hit output and updates action summaries/docs to reflect cache-hit vs fallback vs miss behavior.
  • Extends CI harness to seed and verify exact cache hits (including “no apt mirror requests”) and adds a shared “refuse mirrors” fixture.
File Summary
setup-environment/​action.yml Switches install-latex to the shared cached-install flow, adds latex-cache-hit, and updates summary/docs text (note: current latex-cache-hit/summary semantics can be misleading when an exact cache-key restore still falls back to downloading).
scripts/​latex-packages.sh Adjusts list-mode behavior/messages to support callers that only provide a requirements file (no inline packages input).
docs/​user/​actions/​setup-latex.md Documents that setup-environment now installs LaTeX via the same script+cache approach.
docs/​user/​actions/​setup-environment.md Regenerates/updates docs describing cached LaTeX install behavior, the fixed timeout, new output, and updated failure/troubleshooting guidance.
docs/​dev/​TESTING.md Updates the testing matrix to include the new LaTeX cache harness coverage for setup-environment.
docs/​dev/​PLAN.md Updates the plan/status tracking to reflect completion of the related work item.
CHANGELOG.md Adds an Unreleased entry describing the changed LaTeX install behavior and the new output.
.github/​workflows/​test-actions.yml Adds env-latex-seed/env-latex-hit harness jobs to validate miss→hit behavior and “no mirror contact” assertions.
.github/​fixtures/​setup-latex/​refuse-mirrors.sh New harness helper to stand up a refusing apt proxy; needs an explicit post-loop failure if the proxy never becomes ready to avoid flakiness/misattributed failures.

Review effort: Balanced

Comment on lines +24 to +29
log="$RUNNER_TEMP/apt-proxy.log"
python3 "$(dirname "${BASH_SOURCE[0]}")/apt-proxy.py" refuse 3128 "$log" > "$RUNNER_TEMP/apt-proxy.out" 2>&1 &
for _ in $(seq 50); do
curl -s -o /dev/null http://127.0.0.1:3128/ && break
sleep 0.2
done

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, and fixed in 8701883. If apt-proxy.py is not listening after the 10 s loop, refuse-mirrors.sh now prints the stand-in's own output and fails with an ::error:: saying it was not listening, before it touches apt's configuration. latex-timeout's loop had the same gap, and got the same check.

On the review summary's other note, that latex-cache-hit and the summary can mislead when an exact match still downloads: the output keeps conda-cache-hit's meaning, the key match, as the maintainer decided. But the summary line no longer claims "no download", and now says "Installed from an exact cache match". The rare exact match that falls short is reported by the install step's warning, and the key should rule it out.

Claude Code (on behalf of mmcky)

…mary claims no download it cannot know (#224)

From Copilot's review of #284. refuse-mirrors.sh and latex-timeout now
fail, with the stand-in's output, when it is not listening after 10 s,
instead of blaming the mirrors later. setup-environment's summary says an
exact cache match, not 'no download', since the rare exact match that falls
short downloads, with a warning in the install step.

Part of #224.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMXtFLfZrVgBA6ycXev
Base automatically changed from feat/224-setup-latex to main November 7, 2026 07:26
Brings in #283's squash, d89b021, whose tree is that of e4bb43a, which this
branch already holds. Where the two touch the same lines, this branch's
version, which builds on e4bb43a, is kept: the tree is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMXtFLfZrVgBA6ycXev
@mmcky
mmcky merged commit 5a80d5c into main Nov 9, 2026
66 checks passed
@mmcky
mmcky deleted the feat/224-install-latex-cache branch November 9, 2026 23:17
mmcky added a commit that referenced this pull request Nov 9, 2026
Brings in #280, #281, #283 and #284. CHANGELOG keeps main's [Unreleased]
entries and puts #142's in Changed; PLAN keeps main's rows and drops #142
from the Container validation row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMZzgrBo6FK6GsstoUY
mmcky added a commit that referenced this pull request Nov 10, 2026
* release: v0.17.0

Cut [0.17.0] - 2026-11-10 under an empty [Unreleased]: setup-latex
(#283), setup-environment's install-latex on the LaTeX cache (#284),
the execution cache keyed on the environment and the templates
restoring it (#280), preview-cloudflare's deploy-url (#281), and
:latest promoted only after the smoke test (#274).

PLAN's release line: 9 actions with setup-latex, v0.17.0 the latest
release, @v0 on v0.16.0 until this release's canary and the lecture
matrix have passed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMbZoC2dpGt3sPyBjyd

* docs(plan): format the release line's v0.17.0 as code, as its other versions are

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMbZoC2dpGt3sPyBjyd

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cache the TeX Live apt install: a slow Ubuntu mirror stalls PDF builds for hours

2 participants