Skip to content

Commit 61a3b39

Browse files
committed
CI: run timeout inside sudo, per apt command, so the kill reaches apt-get
Addresses Copilot review on QuantEcon/lecture-intro.zh-cn#301: with timeout wrapping sudo, a timed-out attempt terminated sudo and the bash -c shell but could orphan apt-get holding the dpkg lock, making the retry block instead of retry. timeout is now the direct parent of each apt-get (inside sudo, -k 30s escalation): update 1m/2m, install 3m/12m for graphviz/texlive. Step budgets unchanged.
1 parent 798d625 commit 61a3b39

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ jobs:
2828
- name: Install latex dependencies
2929
timeout-minutes: 30
3030
run: |
31-
# Retried with a per-attempt timeout: a stalled Ubuntu mirror otherwise
31+
# Retried with per-command timeouts (timeout inside sudo, so the kill reaches
32+
# apt-get and the dpkg lock is released): a stalled Ubuntu mirror otherwise
3233
# hangs this step for hours (two 358-minute hangs on 2026-08-18).
3334
pkgs="texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended texlive-fonts-extra texlive-xetex latexmk xindy dvipng cm-super"
3435
for attempt in 1 2; do
35-
timeout 14m sudo bash -c "apt-get -qq update && apt-get install -y $pkgs" && break
36+
sudo timeout -k 30s 2m apt-get -qq update && sudo timeout -k 30s 12m apt-get install -y $pkgs && break
3637
if [ "$attempt" = 2 ]; then echo "apt-get failed after 2 attempts"; exit 1; fi
3738
echo "apt-get attempt $attempt failed; retrying in 30s"; sleep 30
3839
done

.github/workflows/publish.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ jobs:
3333
- name: Install latex dependencies
3434
timeout-minutes: 30
3535
run: |
36-
# Retried with a per-attempt timeout: a stalled Ubuntu mirror otherwise
36+
# Retried with per-command timeouts (timeout inside sudo, so the kill reaches
37+
# apt-get and the dpkg lock is released): a stalled Ubuntu mirror otherwise
3738
# hangs this step for hours (two 358-minute hangs on 2026-08-18).
3839
pkgs="texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended texlive-fonts-extra texlive-xetex latexmk xindy dvipng cm-super"
3940
for attempt in 1 2; do
40-
timeout 14m sudo bash -c "apt-get -qq update && apt-get install -y $pkgs" && break
41+
sudo timeout -k 30s 2m apt-get -qq update && sudo timeout -k 30s 12m apt-get install -y $pkgs && break
4142
if [ "$attempt" = 2 ]; then echo "apt-get failed after 2 attempts"; exit 1; fi
4243
echo "apt-get attempt $attempt failed; retrying in 30s"; sleep 30
4344
done

0 commit comments

Comments
 (0)