Skip to content

Commit

Permalink
better cache
Browse files Browse the repository at this point in the history
  • Loading branch information
y3rsh committed Jan 30, 2025
1 parent 0a24c27 commit e22e7c6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
32 changes: 21 additions & 11 deletions .github/actions/container/ci/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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
Expand All @@ -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 }}
18 changes: 4 additions & 14 deletions ci-docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 "\
Expand Down

0 comments on commit e22e7c6

Please sign in to comment.