Skip to content

Commit 8cc5847

Browse files
committed
fixup! fix(ci): latex caching improvements
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent f5dd2ab commit 8cc5847

File tree

1 file changed

+36
-17
lines changed

1 file changed

+36
-17
lines changed

.github/workflows/sphinxbuild.yml

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,43 @@ permissions:
1111
contents: read
1212

1313
jobs:
14+
setup-latex-cache:
15+
name: Cache LaTeX packages
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Configure apt cache
20+
run: |
21+
mkdir -p /tmp/apt/cache/archives
22+
echo 'Dir::Cache::archives "/tmp/apt/cache/archives";' | sudo tee /etc/apt/apt.conf.d/apt-cache-tmp
23+
24+
- name: Cache LaTeX apt packages
25+
id: cache-latex-apt
26+
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
27+
with:
28+
path: /tmp/apt/cache/archives
29+
key: latex-apt-${{ runner.os }}-${{ runner.arch }}-ubuntu-24.04-texlive-2023
30+
restore-keys: |
31+
latex-apt-${{ runner.os }}-${{ runner.arch }}-ubuntu-24.04-
32+
latex-apt-${{ runner.os }}-${{ runner.arch }}-
33+
34+
- name: Download LaTeX packages (cache miss only)
35+
if: steps.cache-latex-apt.outputs.cache-hit != 'true'
36+
run: |
37+
sudo DEBIAN_FRONTEND=noninteractive apt-get update
38+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
39+
--download-only \
40+
python3-pil python3-pip texlive-fonts-recommended latexmk \
41+
texlive-latex-extra texlive-latex-recommended texlive-xetex \
42+
texlive-fonts-extra-links texlive-fonts-extra xindy
43+
# Ensure downloaded packages are owned by the current user so they can be cached
44+
sudo chown -R $(id -u):$(id -g) /tmp/apt/cache/archives
45+
1446
build:
1547

1648
name: Build ${{ matrix.manual.name }}
1749
runs-on: ubuntu-latest
50+
needs: setup-latex-cache
1851

1952
strategy:
2053
matrix:
@@ -72,28 +105,18 @@ jobs:
72105
mkdir -p /tmp/apt/cache/archives
73106
echo 'Dir::Cache::archives "/tmp/apt/cache/archives";' | sudo tee /etc/apt/apt.conf.d/apt-cache-tmp
74107
75-
- name: Cache LaTeX apt packages
108+
- name: Restore LaTeX apt cache
76109
if: ${{ matrix.manual.build_pdf_path }}
77-
id: cache-latex-apt
78-
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
110+
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
79111
with:
80112
path: /tmp/apt/cache/archives
81113
key: latex-apt-${{ runner.os }}-${{ runner.arch }}-ubuntu-24.04-texlive-2023
82114
restore-keys: |
83115
latex-apt-${{ runner.os }}-${{ runner.arch }}-ubuntu-24.04-
84116
latex-apt-${{ runner.os }}-${{ runner.arch }}-
85117
86-
- name: Install LaTeX dependencies
87-
if: ${{ matrix.manual.build_pdf_path && steps.cache-latex-apt.outputs.cache-hit != 'true' }}
88-
run: |
89-
sudo DEBIAN_FRONTEND=noninteractive apt-get update
90-
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
91-
python3-pil python3-pip texlive-fonts-recommended latexmk \
92-
texlive-latex-extra texlive-latex-recommended texlive-xetex \
93-
texlive-fonts-extra-links texlive-fonts-extra xindy
94-
95118
- name: Install LaTeX from cache
96-
if: ${{ matrix.manual.build_pdf_path && steps.cache-latex-apt.outputs.cache-hit == 'true' }}
119+
if: ${{ matrix.manual.build_pdf_path }}
97120
run: |
98121
sudo DEBIAN_FRONTEND=noninteractive apt-get update
99122
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
@@ -102,10 +125,6 @@ jobs:
102125
texlive-latex-extra texlive-latex-recommended texlive-xetex \
103126
texlive-fonts-extra-links texlive-fonts-extra xindy
104127
105-
- name: Fix apt cache ownership
106-
if: ${{ matrix.manual.build_pdf_path && steps.cache-latex-apt.outputs.cache-hit != 'true' }}
107-
run: sudo chown -R $(id -u):$(id -g) /tmp/apt/cache/archives
108-
109128
- name: Build html documentation
110129
run: cd ${{ matrix.manual.directory }} && make ${{ matrix.manual.make_target }}
111130

0 commit comments

Comments
 (0)