don't save caches for PRs (#14389)

This commit is contained in:
Christopher Milan
2026-01-27 20:21:31 -08:00
committed by GitHub
parent 5e36482314
commit 4ab228b498
2 changed files with 37 additions and 13 deletions

30
.github/actions/cache/action.yml vendored Normal file
View File

@@ -0,0 +1,30 @@
name: Cache
description: Wraps actions/cache to disable save for PRs
inputs:
path:
description: 'A list of files, directories, and wildcard patterns to cache and restore'
required: true
key:
description: 'An explicit key for restoring and saving the cache'
required: true
outputs:
cache-hit:
description: 'A boolean value to indicate an exact match was found for the primary key'
value: ${{ steps.restore-only.outputs.cache-hit || steps.restore-save.outputs.cache-hit }}
runs:
using: "composite"
steps:
- name: Restore Cache (PR)
if: github.event_name == 'pull_request'
id: restore-only
uses: actions/cache/restore@v4
with:
path: ${{ inputs.path }}
key: ${{ inputs.key }}
- name: Restore and Save Cache
if: github.event_name != 'pull_request'
id: restore-save
uses: actions/cache@v4
with:
path: ${{ input.path }}
key: ${{ input.key }}

View File

@@ -58,24 +58,18 @@ runs:
- name: Cache Python packages
id: restore-venv
uses: actions/cache@v4
uses: ./.github/actions/cache
with:
path: ${{ github.workspace }}/.venv
key: venv-${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-${{ inputs.deps }}-${{ inputs.pydeps }}-${{ env.CACHE_VERSION }}
# **** Caching downloads ****
- name: Cache downloads (Linux)
if: inputs.key != '' && runner.os == 'Linux'
uses: actions/cache@v4
- name: Cache downloads
if: inputs.key != ''
uses: ./.github/actions/cache
with:
path: ~/.cache/tinygrad/downloads/
key: downloads-${{ github.job }}-${{ inputs.key }}-${{ env.CACHE_VERSION }}
- name: Cache downloads (macOS)
if: inputs.key != '' && runner.os == 'macOS'
uses: actions/cache@v4
with:
path: ~/Library/Caches/tinygrad/downloads/
path: ${{ runner.os == 'Linux' && '~/.cache/tinygrad/downloads/' || '~/Library/Caches/tinygrad/downloads/' }}
key: downloads-${{ github.job }}-${{ inputs.key }}-${{ env.CACHE_VERSION }}
# **** Python deps ****
@@ -184,7 +178,7 @@ runs:
- name: Cache apt
if: runner.os == 'Linux' && (inputs.opencl == 'true' || inputs.amd == 'true' || inputs.cuda == 'true' || inputs.webgpu == 'true' || inputs.llvm == 'true')
uses: actions/cache@v4
uses: ./.github/actions/cache
with:
path: /var/cache/apt/archives/
key: ${{ runner.os }}-apt-${{ steps.apt-pkgs.outputs.hash }}-${{ env.CACHE_VERSION }}
@@ -242,7 +236,7 @@ runs:
- name: Cache gpuocelot
if: inputs.ocelot == 'true'
id: cache-build
uses: actions/cache@v4
uses: ./.github/actions/cache
env:
cache-name: cache-gpuocelot-build-1
with: