@@ -15,10 +15,43 @@ concurrency:
1515 cancel-in-progress : true
1616
1717jobs :
18+ setup-latex-cache :
19+ name : Cache LaTeX packages
20+ runs-on : ubuntu-latest
21+
22+ steps :
23+ - name : Configure apt cache
24+ run : |
25+ mkdir -p ${{ runner.temp }}/.cache/archives
26+ echo 'Dir::Cache::archives "${{ runner.temp }}/.cache/archives";' | sudo tee /etc/apt/apt.conf.d/apt-cache-tmp
27+
28+ - name : Cache LaTeX apt packages
29+ id : cache-latex-apt
30+ uses : actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
31+ with :
32+ path : ${{ runner.temp }}/.cache/archives
33+ key : latex-apt-${{ runner.os }}-${{ runner.arch }}-ubuntu-24.04-texlive-2023
34+ restore-keys : |
35+ latex-apt-${{ runner.os }}-${{ runner.arch }}-ubuntu-24.04-
36+ latex-apt-${{ runner.os }}-${{ runner.arch }}-
37+
38+ - name : Download LaTeX packages (cache miss only)
39+ if : steps.cache-latex-apt.outputs.cache-hit != 'true'
40+ run : |
41+ sudo DEBIAN_FRONTEND=noninteractive apt-get update
42+ sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
43+ --download-only \
44+ python3-pil python3-pip texlive-fonts-recommended latexmk \
45+ texlive-latex-extra texlive-latex-recommended texlive-xetex \
46+ texlive-fonts-extra-links texlive-fonts-extra xindy
47+ # Ensure downloaded packages are owned by the current user so they can be cached
48+ sudo chown -R $(id -u):$(id -g) ${{ runner.temp }}/.cache/archives
49+
1850 build :
1951
2052 name : Build ${{ matrix.manual.name }}
2153 runs-on : ubuntu-latest
54+ needs : setup-latex-cache
2255
2356 strategy :
2457 matrix :
@@ -62,49 +95,40 @@ jobs:
6295 - name : Checkout repository
6396 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6497
65- - name : Configure apt cache to use /dev/shm
98+ - uses : actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
99+ with :
100+ python-version : ' 3.12'
101+ cache : ' pip'
102+
103+ - name : Install pip dependencies
104+ run : pip install -r requirements.txt
105+
106+ - name : Configure apt cache
66107 if : ${{ matrix.manual.build_pdf_path }}
67108 run : |
68- mkdir -p /dev/shm/apt/ cache/archives
69- echo 'Dir::Cache::archives "/dev/shm/apt/ cache/archives";' | sudo tee /etc/apt/apt.conf.d/apt-cache-shm
109+ mkdir -p ${{ runner.temp }}/. cache/archives
110+ echo 'Dir::Cache::archives "${{ runner.temp }}/. cache/archives";' | sudo tee /etc/apt/apt.conf.d/apt-cache-tmp
70111
71- - name : Cache LaTeX apt packages
112+ - name : Restore LaTeX apt cache
72113 if : ${{ matrix.manual.build_pdf_path }}
73- uses : actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
114+ uses : actions/cache/restore @668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
74115 with :
75- path : /dev/shm/apt/cache/archives
76- key : latex-apt-${{ runner.os }}-${{ hashFiles('.github/workflows/sphinxbuild.yml') }}
116+ # Use relative path https://github.com/actions/cache/issues/1127
117+ path : ${{ runner.temp }}/.cache/archives
118+ key : latex-apt-${{ runner.os }}-${{ runner.arch }}-ubuntu-24.04-texlive-2023
77119 restore-keys : |
78- latex-apt-${{ runner.os }}-
120+ latex-apt-${{ runner.os }}-${{ runner.arch }}-ubuntu-24.04-
121+ latex-apt-${{ runner.os }}-${{ runner.arch }}-
79122
80- - name : Install LaTeX dependencies
123+ - name : Install LaTeX from cache
81124 if : ${{ matrix.manual.build_pdf_path }}
82125 run : |
83126 sudo DEBIAN_FRONTEND=noninteractive apt-get update
84- sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \
85- --no-install-recommends \
86- python3-pil \
87- python3-pip \
88- texlive-fonts-recommended \
89- latexmk \
90- texlive-latex-extra \
91- texlive-latex-recommended \
92- texlive-xetex \
93- texlive-fonts-extra-links \
94- texlive-fonts-extra \
95- xindy
96-
97- - name : Fix apt cache ownership for caching
98- if : ${{ matrix.manual.build_pdf_path }}
99- run : sudo chown -R $(id -u):$(id -g) /dev/shm/apt/cache/archives
100-
101- - uses : actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
102- with :
103- python-version : ' 3.12'
104- cache : ' pip'
105-
106- - name : Install pip dependencies
107- run : pip install -r requirements.txt
127+ sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
128+ --no-download \
129+ python3-pil python3-pip texlive-fonts-recommended latexmk \
130+ texlive-latex-extra texlive-latex-recommended texlive-xetex \
131+ texlive-fonts-extra-links texlive-fonts-extra xindy
108132
109133 - name : Build html documentation
110134 run : cd ${{ matrix.manual.directory }} && make ${{ matrix.manual.make_target }}
0 commit comments