From 4ab228b498f1e430e484c3079cefde508596bfe3 Mon Sep 17 00:00:00 2001 From: Christopher Milan Date: Tue, 27 Jan 2026 20:21:31 -0800 Subject: [PATCH] don't save caches for PRs (#14389) --- .github/actions/cache/action.yml | 30 +++++++++++++++++++++++ .github/actions/setup-tinygrad/action.yml | 20 ++++++--------- 2 files changed, 37 insertions(+), 13 deletions(-) create mode 100644 .github/actions/cache/action.yml diff --git a/.github/actions/cache/action.yml b/.github/actions/cache/action.yml new file mode 100644 index 0000000000..f3bd57ab13 --- /dev/null +++ b/.github/actions/cache/action.yml @@ -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 }} diff --git a/.github/actions/setup-tinygrad/action.yml b/.github/actions/setup-tinygrad/action.yml index fb9493862d..3112430a27 100644 --- a/.github/actions/setup-tinygrad/action.yml +++ b/.github/actions/setup-tinygrad/action.yml @@ -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: