Skip to content

containers, build-lectures: git refuses the work tree in container jobs, so every page silently loses its "Last changed" header #164

Closed

Description

@mmcky

Every lecture page built inside the quantecon-build (or quantecon) container loses its "Last changed" header and changelog, and nothing in the build log says so. This is already visible on a production site: none of lecture-dp's 52 live pages carries the header.

The same lecture, built two ways

test-actions-lecture-intro is the canary for the container build, and a copy of lecture-python-intro, which still builds on the runner. Same theme, same template:

Lecture Built on the runner (intro.quantecon.org) Built in the container (test-actions-lecture-intro)
intro Last changed: Dec 21, 2023 no header
linear_equations Last changed: May 24, 2026 no header

Checked by fetching each page and matching the theme's button.qe-page__header-changed, which is server-rendered, so a static fetch sees it. The same check on other sites:

Site Build Header
python.quantecon.org/linear_algebra runner (setup-miniconda) Last changed: Sep 12, 2026
quantecon.github.io/lecture-dp, 52 pages container, quantecon-build:latest none
test-lecture-theme-sphinx, all 14 pages container none

lecture-dp already checks out with fetch-depth: 0, which isolates the cause to the one below.

Why

  • The runner creates the workspace on the host as its own user (uid 1001) and bind-mounts it into the container. The images declare no USER, so container steps run as root.
  • git 2.43.0 exempts root from its ownership check only for root-owned paths. So every git command in the work tree exits 128 with detected dubious ownership, and stdout is empty.
  • actions/checkout does add a safe.directory entry, but into a temporary HOME that it deletes when its own step ends; its log says Temporarily overriding HOME='/__w/_temp/<uuid>'. Later steps never see the entry. Upstream this is /github/home/.gitconfig does not exist for container runs actions/checkout#1169, open since February 2023.
  • quantecon-book-theme shows the header only when get_git_last_modified() returns a date and the changelog is non-empty. Both run git and return None / [] on any failure. So the header disappears without a warning.

Reproducible locally with git's own hook for this code path, GIT_TEST_ASSUME_DIFFERENT_OWNER=1: the theme's helpers return nothing, and with the tree trusted they return a date and entries.

Two details that decide where the fix can go

  • The trusted path must be the work-tree root. An entry for a subdirectory such as lectures/ still fails, and so do /* and a trailing slash — all reproduced on git 2.43.0 built from source.
  • $GITHUB_WORKSPACE is not always that root. test-containers-lectures.yml checks the lecture repo out into $GITHUB_WORKSPACE/lecture-repo, where an entry for $GITHUB_WORKSPACE still fails. Separately, inside a container job the ${{ github.workspace }} expression is the host path; the shell's $GITHUB_WORKSPACE is the container path.

A second silent casualty

scripts/detect-changed-lectures.sh, used by preview-netlify and preview-cloudflare, runs git with its errors hidden (2>/dev/null || true). In a container job it therefore fails the same way and reports no changed lectures. On the canary, QuantEcon/test-actions-lecture-intro#58 changed lectures/french_rev.md, and the preview run's detection printed no changed lecture. The script hides stderr, so the log cannot prove that was the cause, but the mechanism above produces exactly that result.

And the shallow half

With git working, a depth-1 checkout still dates every page to the head commit, because git log --follow -- <file> sees only one commit. templates/publish.yml and templates/cache.yml use actions/checkout@v4 at its default depth of 1. Open issues #147, #148 and #149 plan fetch-depth: 1 for PR previews to save time, and that trade-off is fine as long as it is visible. So the fix should warn about a shallow clone, not force a full one.

Nothing would have caught this

No test in this repository checks that the header renders. test-actions.yml has no container job. The smoke tests use sphinx_book_theme. test-containers-lectures.yml builds real quantecon-book-theme lectures in both images but inspects nothing in the output.

The fix

In the linked PR:

  • Both images set git config --system --add safe.directory '*'. That covers every step of every job, whatever HOME a step sets, including callers that don't use build-lectures. The ownership check guards shared multi-user machines against a repository planted by another user; these images are single-tenant and hold only the job's own checkout, so there is nothing to guard.
  • build-lectures gains a step before HTML builds. It finds the work-tree root from source-dir, trusts that root only if git currently refuses it, and emits a ::warning:: when git is missing, the source isn't in a work tree, git still can't read it, or the clone is shallow. It never fails a build. It is also a fallback for callers on other images or pinned digests.
  • Two regression checks. test-container.yml asserts git can read the checkout, which fails in about a second on the exact condition. test-containers-lectures.yml asserts built pages carry the header. Both run after an image build on main, against the freshly built image.
  • Templates check out with fetch-depth: 0.

Merging rebuilds :latest, and every consumer picks it up, lecture-dp included, since callers pin :latest. That is the point, but worth knowing before merging.

Found while verifying the theme-parity test corpora; the evidence and the parity-side fix are on QuantEcon/project-theme-parity#25.

Activity

  1. added
    bug
    infrastructure
    on Sep 18, 2026
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

    buginfrastructure

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions