Skip to content

Commit 3098034

Browse files
committed
add cache to CI
1 parent 38a49ea commit 3098034

1 file changed

Lines changed: 40 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,24 @@ jobs:
3232
steps:
3333
- uses: actions/checkout@v4
3434

35+
# Pinned SDKs are immutable, so a version-keyed cache never goes stale.
36+
# Restoring the extracted tree skips the 100-150MB download + tar.bz2
37+
# decompress on every run.
38+
- name: Cache Ren'Py SDK
39+
uses: actions/cache@v4
40+
id: cache-sdk
41+
with:
42+
path: renpy-${{ matrix.renpy }}-sdk
43+
key: renpy-sdk-${{ matrix.renpy }}-${{ runner.os }}
44+
3545
- name: Download Ren'Py SDK
46+
if: steps.cache-sdk.outputs.cache-hit != 'true'
3647
run: |
3748
curl -fL "https://www.renpy.org/dl/${{ matrix.renpy }}/renpy-${{ matrix.renpy }}-sdk.tar.bz2" -o sdk.tar.bz2
3849
tar xjf sdk.tar.bz2
39-
echo "SDK_DIR=$PWD/renpy-${{ matrix.renpy }}-sdk" >> "$GITHUB_ENV"
50+
51+
- name: Set SDK_DIR
52+
run: echo "SDK_DIR=$PWD/renpy-${{ matrix.renpy }}-sdk" >> "$GITHUB_ENV"
4053

4154
# The `test` command is uses_display=True and the 7.x leg forces
4255
# SDL_VIDEODRIVER=x11 -- both need a real X server. xvfb provides it.
@@ -55,12 +68,25 @@ jobs:
5568
- uses: actions/checkout@v4
5669

5770
- uses: actions/setup-python@v5
71+
id: python
5872
with:
5973
python-version: "3.12"
6074

75+
# Cache the poetry venv in-project. The key includes the exact resolved
76+
# Python patch because a venv's interpreter symlink is tied to that
77+
# path -- when the hosted image bumps the patch the key changes and the
78+
# venv is rebuilt, instead of restoring a dead one.
79+
- name: Cache poetry venv
80+
uses: actions/cache@v4
81+
id: cache-venv
82+
with:
83+
path: .venv
84+
key: poetry-venv-${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
85+
6186
- name: Install poetry + deps
6287
run: |
6388
python -m pip install --upgrade pip "poetry==2.4.1"
89+
poetry config virtualenvs.in-project true
6490
poetry install
6591
6692
# bin/lint.sh calls bare `pyright` (not `poetry run pyright`), so the
@@ -69,12 +95,23 @@ jobs:
6995
# pyrightconfig.json's extraPaths point at the SDK (relative ./sdk plus
7096
# machine-local absolute paths that don't exist here). Download the SDK
7197
# and symlink it into ./sdk so pyright can resolve renpy.* on this
72-
# clean runner.
98+
# clean runner. The 8.5.3 testcases leg seeds the same version-keyed
99+
# cache, so whichever job starts first saves it and the other reads it.
100+
- name: Cache Ren'Py SDK for pyright
101+
uses: actions/cache@v4
102+
id: cache-sdk
103+
with:
104+
path: renpy-8.5.3-sdk
105+
key: renpy-sdk-8.5.3-${{ runner.os }}
106+
73107
- name: Download Ren'Py SDK for pyright
108+
if: steps.cache-sdk.outputs.cache-hit != 'true'
74109
run: |
75110
curl -fL "https://www.renpy.org/dl/8.5.3/renpy-8.5.3-sdk.tar.bz2" -o sdk.tar.bz2
76111
tar xjf sdk.tar.bz2
77-
ln -s "$PWD/renpy-8.5.3-sdk" sdk
112+
113+
- name: Symlink SDK
114+
run: ln -s "$PWD/renpy-8.5.3-sdk" sdk
78115

79116
- name: Lint
80117
run: |

0 commit comments

Comments
 (0)