add cache to CI #26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| jobs: | |
| # Run the Ren'Py testcases harness against pinned SDKs -- the code path | |
| # pytest cannot cover (real .rpy screens + the 7.x/Py2 runtime). The SDK | |
| # launcher (renpy.sh at the SDK root) is passed straight to | |
| # bin/test_harness.sh, which sniffs the bundled major version from | |
| # renpy/__init__.py and runs the matching DSL template. | |
| testcases: | |
| name: testcases (Ren'Py ${{ matrix.renpy }}) | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - renpy: "7.4.10" | |
| os: ubuntu-22.04 | |
| - renpy: "8.5.3" | |
| os: ubuntu-latest | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| # Explicit fixture root (empty is fine -- CueDatabase.open() creates all | |
| # subdirs at init). Never let the run inherit a machine-local pointer | |
| # file, which would override the env var. | |
| RENPY_CUE_DIR: ${{ github.workspace }}/tests/fixtures/data | |
| # Headless runner: no audio device. The testcases play no audio. | |
| SDL_AUDIODRIVER: dummy | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # Pinned SDKs are immutable, so a version-keyed cache never goes stale. | |
| # Restoring the extracted tree skips the 100-150MB download + tar.bz2 | |
| # decompress on every run. | |
| - name: Cache Ren'Py SDK | |
| uses: actions/cache@v4 | |
| id: cache-sdk | |
| with: | |
| path: renpy-${{ matrix.renpy }}-sdk | |
| key: renpy-sdk-${{ matrix.renpy }}-${{ runner.os }} | |
| - name: Download Ren'Py SDK | |
| if: steps.cache-sdk.outputs.cache-hit != 'true' | |
| run: | | |
| curl -fL "https://www.renpy.org/dl/${{ matrix.renpy }}/renpy-${{ matrix.renpy }}-sdk.tar.bz2" -o sdk.tar.bz2 | |
| tar xjf sdk.tar.bz2 | |
| - name: Set SDK_DIR | |
| run: echo "SDK_DIR=$PWD/renpy-${{ matrix.renpy }}-sdk" >> "$GITHUB_ENV" | |
| # The `test` command is uses_display=True and the 7.x leg forces | |
| # SDL_VIDEODRIVER=x11 -- both need a real X server. xvfb provides it. | |
| - name: Run testcases | |
| # Explicit `bash` invocation: the repo lives on a filesystem that | |
| # doesn't persist the exec bit (core.fileMode=false), so the scripts | |
| # aren't executable in the working tree. | |
| run: xvfb-run -a bash bin/test_harness.sh "$SDK_DIR/renpy.sh" | |
| # Fast gate: pyright + 120-char lint, then the pytest suite, under the | |
| # modern toolchain. Mirrors the /lint and /test skills via bin/*.sh. | |
| check: | |
| name: lint + test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| id: python | |
| with: | |
| python-version: "3.12" | |
| # Cache the poetry venv in-project. The key includes the exact resolved | |
| # Python patch because a venv's interpreter symlink is tied to that | |
| # path -- when the hosted image bumps the patch the key changes and the | |
| # venv is rebuilt, instead of restoring a dead one. | |
| - name: Cache poetry venv | |
| uses: actions/cache@v4 | |
| id: cache-venv | |
| with: | |
| path: .venv | |
| key: poetry-venv-${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('poetry.lock') }} | |
| - name: Install poetry + deps | |
| run: | | |
| python -m pip install --upgrade pip "poetry==2.4.1" | |
| poetry config virtualenvs.in-project true | |
| poetry install | |
| # bin/lint.sh calls bare `pyright` (not `poetry run pyright`), so the | |
| # project venv's bin/ must be on PATH. | |
| # | |
| # pyrightconfig.json's extraPaths point at the SDK (relative ./sdk plus | |
| # machine-local absolute paths that don't exist here). Download the SDK | |
| # and symlink it into ./sdk so pyright can resolve renpy.* on this | |
| # clean runner. The 8.5.3 testcases leg seeds the same version-keyed | |
| # cache, so whichever job starts first saves it and the other reads it. | |
| - name: Cache Ren'Py SDK for pyright | |
| uses: actions/cache@v4 | |
| id: cache-sdk | |
| with: | |
| path: renpy-8.5.3-sdk | |
| key: renpy-sdk-8.5.3-${{ runner.os }} | |
| - name: Download Ren'Py SDK for pyright | |
| if: steps.cache-sdk.outputs.cache-hit != 'true' | |
| run: | | |
| curl -fL "https://www.renpy.org/dl/8.5.3/renpy-8.5.3-sdk.tar.bz2" -o sdk.tar.bz2 | |
| tar xjf sdk.tar.bz2 | |
| - name: Symlink SDK | |
| run: ln -s "$PWD/renpy-8.5.3-sdk" sdk | |
| - name: Lint | |
| run: | | |
| export PATH="$(poetry env info -p)/bin:$PATH" | |
| bash bin/lint.sh | |
| - name: Test | |
| run: bash bin/test.sh |