Skip to content

PR previews show main's cached pages instead of the pull request's changes #307

Open

Description

@mmcky

What happens

A pull request's Netlify preview does not show the pull request's changes to an existing lecture. The Build HTML step in ci.yml writes a page only when that lecture has no page in the downloaded build cache, so every other page in the preview is the cached copy built from main.

Evidence from #304, which changed var_dmd.md and measurement_models.md:

  • Its CI run (Actions run 39720429073) wrote six pages: gallant_tauchen, intro, lq_mean_field_games, lucas_prescott_investment, optimal_growth_uncertainty and social_security_depletion. Neither changed lecture was among them.
  • On the preview it deployed, var_dmd.html contains 113 of the 114 phrases the PR removed and 6 of the 154 it added. The page shows the old translation.

#305's preview of sir_model looked right only by coincidence. Its run did not rewrite that page either, but the cache predated #302, so it already held the wording #305 restored.

Cause

The Clear stale Sphinx environment step removes _build/.doctrees but leaves the cached _build/html. The notebook build then reads every source and saves the shared Sphinx environment, so the HTML build reads nothing (updating environment: 0 added, 0 changed, 0 removed) and writes a page only if its source file is newer than the cached HTML file. The cache is unpacked after checkout, so the cached HTML always looks newer.

publish.yml does not have this problem. Its clear step removes both directories, and the publish-2026oct22 run wrote all 150 pages.

What to change

  1. In ci.yml, make the clear step remove _build/html as well, matching publish.yml:
      - name: Clear stale Sphinx environment
        shell: bash -l {0}
        run: rm -rf _build/.doctrees _build/html

The execution cache (_build/.jupyter_cache) is kept, so no notebook re-executes. The HTML step then writes all 150 pages.

  1. Remove the second, broken preview link. Netlify's own app also comments on each PR ("Deploy Preview for astonishing-narwhal-a8fc64 ready!"), and its deploy-preview-N link returns 404 (checked 2026-10-23 on 🌐 [translation-sync] [var_dmd, svd_intro, measurement_models] Correct math, add exercises #304 and sir_model: restore the 2025 reviewers' wording lost in #302 #305). The working preview is the later github-actions comment ("🚀 Deployed on …"). Turn off deploy previews for this site in Netlify's settings, so the CI deploy is the only one.

  2. Optional: replace nwtgck/actions-netlify with quantecon/actions/preview-netlify@v0.12.0, as QuantEcon/lecture-python-programming.fr does. It posts a stable pr-N URL and a link to each lecture the PR changes, which is the page a reviewer opens. It needs pull-requests: write on the job and a Node setup step, as in the fr ci.yml. On Update need_for_speed.md lecture-python-programming.fr#94 its preview shows the PR's text.

Done when

  • A PR that edits an existing lecture shows the edited text in its preview, checked on one PR.
  • Each PR carries one preview link, and it works.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions