From 2568bc0d99134b47f461edb2cbc93da24bd1cc29 Mon Sep 17 00:00:00 2001 From: Tom Clesius <48072820+tclesius@users.noreply.github.com> Date: Tue, 29 Jul 2025 18:04:56 +0200 Subject: [PATCH] ci: add caching for apt packages (#11162) * add caching for apt packages * remove 'inputs' from apt cache key, use outputs instead of env * remove unnecessary mkdir for partial --------- Co-authored-by: George Hotz <72895+geohot@users.noreply.github.com> --- .github/actions/setup-tinygrad/action.yml | 43 +++++++++++++++++------ 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/.github/actions/setup-tinygrad/action.yml b/.github/actions/setup-tinygrad/action.yml index aaa82a980d..e6e95248ef 100644 --- a/.github/actions/setup-tinygrad/action.yml +++ b/.github/actions/setup-tinygrad/action.yml @@ -112,7 +112,16 @@ runs: fi # ******************* apt ******************* + - name: Setup apt + if: runner.os == 'Linux' && (inputs.opencl == 'true' || inputs.amd == 'true' || inputs.cuda == 'true' || inputs.webgpu == 'true' || inputs.llvm == 'true') + shell: bash + run: | + sudo chown -R $USER:$USER /var/cache/apt/archives + echo 'Acquire::GzipIndexes "true";' | sudo tee /etc/apt/apt.conf.d/gzip + echo 'Acquire::http::Pipeline-Depth "5";' | sudo tee -a /etc/apt/apt.conf.d/99parallel + echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' | sudo tee -a /etc/apt/apt.conf.d/99keep-debs + - name: Add OpenCL Repo if: inputs.opencl == 'true' && runner.os == 'Linux' shell: bash @@ -135,14 +144,11 @@ runs: wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-20 main" | sudo tee /etc/apt/sources.list.d/llvm.list - - name: apt-get update + install + - name: Compute Package List + Hash if: runner.os == 'Linux' && (inputs.opencl == 'true' || inputs.amd == 'true' || inputs.cuda == 'true' || inputs.webgpu == 'true' || inputs.llvm == 'true') + id: apt-pkgs shell: bash run: | - echo 'Acquire::GzipIndexes "true";' | sudo tee /etc/apt/apt.conf.d/gzip - echo 'Acquire::http::Pipeline-Depth "5";' | sudo tee -a /etc/apt/apt.conf.d/99parallel - sudo apt -qq update || true - pkgs="" # **** OpenCL **** if [[ "${{ inputs.opencl }}" == "true" ]]; then @@ -168,14 +174,31 @@ runs: if [[ "${{ inputs.llvm }}" == "true" ]]; then pkgs+=" libllvm20 clang-20 lld-20" fi + + echo "pkgs=$pkgs" >> "$GITHUB_OUTPUT" + echo "hash=$(echo -n "$pkgs" | sha256sum | cut -d' ' -f1)" >> "$GITHUB_OUTPUT" + - 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 + with: + path: /var/cache/apt/archives/ + key: ${{ runner.os }}-apt-${{ steps.apt-pkgs.outputs.hash }} + + - name: Run apt Update + Install + if: runner.os == 'Linux' && (inputs.opencl == 'true' || inputs.amd == 'true' || inputs.cuda == 'true' || inputs.webgpu == 'true' || inputs.llvm == 'true') + shell: bash + run: | + sudo apt -qq update || true + # ******** do install ******** - if [[ -n "$pkgs" ]]; then - sudo apt-get -y --allow-unauthenticated --no-install-recommends install $pkgs + if [[ -n "${{ steps.apt-pkgs.outputs.pkgs }}" ]]; then + sudo apt-get -y --allow-unauthenticated --no-install-recommends install ${{ steps.apt-pkgs.outputs.pkgs }} fi - + + sudo chown -R $USER:$USER /var/cache/apt/archives/ + # **** AMD **** - - name: Setup AMD (Linux) if: inputs.amd == 'true' && runner.os == 'Linux' shell: bash @@ -228,7 +251,7 @@ runs: shell: bash run: | cd ${{ github.workspace }}/gpuocelot/ocelot/build - sudo cp libgpuocelot.${{ runner.os == 'macOS' && 'dylib' || 'so' }} /usr/${{ runner.os == 'macOS' && 'local/' || ''}}lib/ + sudo cp libgpuocelot.${{ runner.os == 'macOS' && 'dylib' || 'so' }} /usr/${{ runner.os == 'macOS' && 'local/' || '' }}lib/ # **** WebGPU ****