Skip to content

Commit 63a1e50

Browse files
Copilotskjnldsv
authored andcommitted
fix(ci): cache texlive-fonts-extra differently
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent 9982658 commit 63a1e50

1 file changed

Lines changed: 58 additions & 6 deletions

File tree

.github/workflows/sphinxbuild.yml

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ concurrency:
1717
jobs:
1818
setup-latex-cache:
1919
name: Cache LaTeX packages
20-
runs-on: ubuntu-latest
20+
# Force running on GitHub-hosted runners
21+
runs-on: ubuntu-24.04
2122

2223
steps:
2324
- name: Configure apt cache
@@ -33,7 +34,7 @@ jobs:
3334
path: |
3435
${{ runner.temp }}/.cache/archives
3536
${{ runner.temp }}/.cache/lists
36-
key: latex-apt-${{ runner.os }}-${{ runner.arch }}-ubuntu-24.04-texlive-2023-v2
37+
key: latex-apt-${{ runner.os }}-${{ runner.arch }}-ubuntu-24.04-texlive-2023-v3
3738
restore-keys: |
3839
latex-apt-${{ runner.os }}-${{ runner.arch }}-ubuntu-24.04-
3940
latex-apt-${{ runner.os }}-${{ runner.arch }}-
@@ -54,7 +55,7 @@ jobs:
5455
-o Dir::State::lists="${{ runner.temp }}/.cache/lists" \
5556
python3-pil python3-pip texlive-fonts-recommended latexmk \
5657
texlive-latex-extra texlive-latex-recommended texlive-xetex \
57-
texlive-fonts-extra-links texlive-fonts-extra xindy tex-gyre
58+
texlive-fonts-extra-links xindy tex-gyre
5859
# Ensure downloaded packages are owned by the current user so they can be cached
5960
sudo chown -R $(id -u):$(id -g) ${{ runner.temp }}/.cache/
6061
@@ -65,7 +66,42 @@ jobs:
6566
path: |
6667
${{ runner.temp }}/.cache/archives
6768
${{ runner.temp }}/.cache/lists
68-
key: latex-apt-${{ runner.os }}-${{ runner.arch }}-ubuntu-24.04-texlive-2023-v2
69+
key: latex-apt-${{ runner.os }}-${{ runner.arch }}-ubuntu-24.04-texlive-2023-v3
70+
71+
- name: Check texlive-fonts-extra installed files cache
72+
id: cache-fonts-extra
73+
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
74+
with:
75+
path: ~/.cache/texlive-fonts-extra
76+
key: latex-fonts-extra-${{ runner.os }}-${{ runner.arch }}-ubuntu-24.04-texlive-2023-v1
77+
lookup-only: true
78+
79+
- name: Install texlive-fonts-extra and cache installed files (cache miss only)
80+
if: steps.cache-fonts-extra.outputs.cache-hit != 'true'
81+
run: |
82+
for i in 1 2 3; do
83+
sudo DEBIAN_FRONTEND=noninteractive apt-get update \
84+
-o Acquire::Retries=3 && break
85+
echo "apt-get update failed (attempt $i), retrying in 15s..."
86+
sleep 15
87+
done
88+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends texlive-fonts-extra
89+
mkdir -p ~/.cache/texlive-fonts-extra
90+
while IFS= read -r f; do
91+
[ -f "$f" ] || [ -L "$f" ] || continue
92+
rel="${f#/}"
93+
dir="$HOME/.cache/texlive-fonts-extra/$(dirname "$rel")"
94+
mkdir -p "$dir"
95+
sudo cp -P "$f" "$dir/"
96+
done < <(dpkg -L texlive-fonts-extra)
97+
sudo chown -R $(id -u):$(id -g) ~/.cache/texlive-fonts-extra
98+
99+
- name: Save texlive-fonts-extra installed files cache (cache miss only)
100+
if: steps.cache-fonts-extra.outputs.cache-hit != 'true'
101+
uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
102+
with:
103+
path: ~/.cache/texlive-fonts-extra
104+
key: latex-fonts-extra-${{ runner.os }}-${{ runner.arch }}-ubuntu-24.04-texlive-2023-v1
69105

70106
build:
71107
name: Build ${{ matrix.manual.name }}
@@ -138,14 +174,30 @@ jobs:
138174
path: |
139175
${{ runner.temp }}/.cache/archives
140176
${{ runner.temp }}/.cache/lists
141-
key: latex-apt-${{ runner.os }}-${{ runner.arch }}-ubuntu-24.04-texlive-2023-v2
177+
key: latex-apt-${{ runner.os }}-${{ runner.arch }}-ubuntu-24.04-texlive-2023-v3
142178
restore-keys: |
143179
latex-apt-${{ runner.os }}-${{ runner.arch }}-ubuntu-24.04-
144180
latex-apt-${{ runner.os }}-${{ runner.arch }}-
145181
182+
- name: Restore texlive-fonts-extra installed files
183+
if: ${{ matrix.manual.build_pdf_path }}
184+
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
185+
with:
186+
path: ~/.cache/texlive-fonts-extra
187+
key: latex-fonts-extra-${{ runner.os }}-${{ runner.arch }}-ubuntu-24.04-texlive-2023-v1
188+
189+
- name: Install texlive-fonts-extra from cache
190+
if: ${{ matrix.manual.build_pdf_path }}
191+
run: |
192+
if [ -d ~/.cache/texlive-fonts-extra ]; then
193+
sudo cp -r ~/.cache/texlive-fonts-extra/. /
194+
else
195+
echo "texlive-fonts-extra cache not found, installing from apt..." >&2
196+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends texlive-fonts-extra
197+
fi
198+
146199
- name: Install LaTeX from cache
147200
if: ${{ matrix.manual.build_pdf_path }}
148-
timeout-minutes: 5
149201
run: |
150202
debs=(${{ runner.temp }}/.cache/archives/*.deb)
151203
if [ ! -e "${debs[0]}" ]; then

0 commit comments

Comments
 (0)