From e22e7c6a494de5b35eb59efb2b98bd653d92b449 Mon Sep 17 00:00:00 2001 From: Josh McVey Date: Thu, 30 Jan 2025 15:40:00 -0600 Subject: [PATCH] better cache --- .github/actions/container/ci/action.yaml | 32 ++++++++++++++++-------- ci-docker/Dockerfile | 18 +++---------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/actions/container/ci/action.yaml b/.github/actions/container/ci/action.yaml index eda0d2a43f8..e750e3560bf 100644 --- a/.github/actions/container/ci/action.yaml +++ b/.github/actions/container/ci/action.yaml @@ -25,14 +25,28 @@ runs: driver-opts: network=host - name: Cache Docker Buildx Layers + id: cache uses: actions/cache@v4 with: - path: /tmp/.buildx-cache - key: buildx-${{ inputs.git_ref }} - restore-keys: | - buildx-${{ inputs.git_ref }} - buildx-edge + path: | + node + python + key: cache-${{ inputs.git_ref }} + restore-keys: buildx-edge + - name: inject cache into docker + uses: reproducible-containers/buildkit-cache-dance@v3.1.2 + with: + cache-map: | + { + "node": "/root/.cache/yarn", + "python": "/root/.cache/pip" + } + skip-extraction: ${{ steps.cache.outputs.cache-hit }} + + # Checkout already happened so that we may use this action. + # Make sure we're on the right ref In case it was a tag. + # So that we are using the Dockerfile on that inputs.git_ref - name: 'Fix actions/checkout odd handling of tags' if: startsWith(inputs.git_ref, 'refs/tags') shell: bash @@ -50,10 +64,6 @@ runs: target: ci push: true tags: ghcr.io/opentrons/opentrons-ci:${{ inputs.git_ref }} - cache-from: | - type=local,src=/tmp/.buildx-cache - type=registry,ref=ghcr.io/opentrons/opentrons-ci:cache - cache-to: | - type=local,dest=/tmp/.buildx-cache,mode=max - type=registry,ref=ghcr.io/opentrons/opentrons-ci:cache,mode=max + cache-from: type=gha + cache-to: type=gha,mode=max secrets: GIT_AUTH_TOKEN=${{ inputs.token }} diff --git a/ci-docker/Dockerfile b/ci-docker/Dockerfile index f05d2e47692..3d72bad865c 100644 --- a/ci-docker/Dockerfile +++ b/ci-docker/Dockerfile @@ -115,20 +115,10 @@ ENV GIT_REF=${GIT_REF} WORKDIR /opentrons -# Use a BuildKit cache mount. If `/tmp/git-repo` already exists, fetch & checkout. -RUN --mount=type=cache,id=opentrons-git-cache,target=/tmp/git-repo \ - set -eux; \ - if [ -d /tmp/git-repo/.git ]; then \ - echo "Using cached Opentrons/opentrons repo in /tmp/git-repo"; \ - else \ - git clone https://github.com/Opentrons/opentrons.git /tmp/git-repo; \ - fi && \ - cd /tmp/git-repo; \ - git fetch --all; \ - git fetch --tags --force; \ - git fetch origin "${GIT_REF}"; \ - git checkout "${GIT_REF}"; \ - cp -r /tmp/git-repo/. /opentrons +RUN git clone https://github.com/Opentrons/opentrons.git . \ + && git fetch --tags --force \ + && git fetch origin "${GIT_REF}" \ + && git checkout "${GIT_REF}" RUN --mount=type=cache,target=/root/.cache/yarn \ bash -c "\