@@ -25,13 +25,40 @@ jobs:
2525 python -m pip install -v ".[dev]"
2626 mypy neat_ml
2727 ruff check neat_ml
28- - name : install fonts
28+ - name : cache fonts
29+ id : cache-fonts
2930 if : runner.os == 'Linux'
31+ uses : actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
32+ with :
33+ path : ~/.cache/msttcorefonts/
34+ key : ${{ runner.os }}-msttcorefonts-v1
35+ - name : install fonts
36+ if : runner.os == 'Linux' && steps.cache-fonts.outputs.cache-hit != 'true'
3037 run : |
3138 echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections
3239 sudo apt-get update
3340 sudo apt-get install -y ttf-mscorefonts-installer || true
34- sudo fc-cache -f -v
41+ # before making the user storage directory, check if the font(s) we need
42+ # (i.e. `Arial.ttf` and `Arial_Bold.ttf`) exist/were successfully downloaded
43+ # to the root directory to avoid loading an empty directory on a successful
44+ # ``cache-hit``
45+ if [[ ! -f "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf" || \
46+ ! -f "/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf" ]]; then
47+ echo "Fonts not downloaded successfully."
48+ exit 1
49+ else
50+ echo "Fonts downloaded successfully. Caching fonts..."
51+ mkdir -p ~/.cache/msttcorefonts/
52+ cp /usr/share/fonts/truetype/msttcorefonts/*.ttf ~/.cache/msttcorefonts/
53+ fi
54+ - name : install fonts from cache
55+ if : runner.os == 'Linux' && steps.cache-fonts.outputs.cache-hit == 'true'
56+ run : |
57+ sudo mkdir -p /usr/share/fonts/truetype/msttcorefonts/
58+ sudo cp ~/.cache/msttcorefonts/*.ttf /usr/share/fonts/truetype/msttcorefonts/
59+ - name : refresh font cache
60+ if : runner.os == 'Linux'
61+ run : sudo fc-cache -f -v
3562 - name : test
3663 run : |
3764 cd /tmp && python -m pytest --pyargs neat_ml --cov=neat_ml --cov-report=term-missing
0 commit comments