Commit 5944dbed authored by Harrison Saturley-Hall's avatar Harrison Saturley-Hall Committed by GitHub
Browse files

ci: remove caching of docker layers on PR builds (#61)

parent 678cffb4
...@@ -48,33 +48,22 @@ jobs: ...@@ -48,33 +48,22 @@ jobs:
registry: ghcr.io registry: ghcr.io
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Set IMAGE_TAG based on Event
id: set_image_tag
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "IMAGE_TAG=ghcr.io/${{ github.repository }}:pr_${{ github.event.pull_request.number }}_${{ matrix.framework }}" >> $GITHUB_ENV
fi
- name: Decide on cache - name: Decide on cache
id: which_cache id: which_caches
env:
CACHE_LOCATION: ghcr.io/${{ github.repository }}:latest-${{ matrix.framework }}
run: | run: |
set +e set +e
if [ "${{ github.event_name }}" == "pull_request" ]; then if [ "${{ github.event_name }}" == "pull_request" ]; then
docker manifest inspect ${{ env.IMAGE_TAG }}
if [ $? -eq 0 ]; then echo "Not pushing to container image cache"
echo "USING ${{ env.IMAGE_TAG }}" echo "cache_to_location=" >> $GITHUB_OUTPUT
echo "CACHE_LOCATION=${{ env.IMAGE_TAG }}" >> $GITHUB_ENV else
fi echo "Pushing ${{ env.IMAGE_TAG }} to container image cache"
echo "cache_to_location=--cache-to \"type=registry,ref=${{ env.IMAGE_TAG }},image-manifest=true,mode=max\"" >> $GITHUB_OUTPUT
fi fi
echo "cache_from_location=${{ env.CACHE_LOCATION }}" >> $GITHUB_OUTPUT echo "cache_from_location=--cache-from \"type=registry,ref=${{ env.IMAGE_TAG }}\"" >> $GITHUB_OUTPUT
echo "cache_to_location=${{ env.IMAGE_TAG }}" >> $GITHUB_OUTPUT
- name: Build image - name: Build image
env:
CACHE_FROM: "type=registry,ref=${{ steps.which_cache.outputs.cache_from_location }}"
CACHE_TO: "type=registry,ref=${{ steps.which_cache.outputs.cache_to_location }},image-manifest=true,mode=max"
run: | run: |
./container/build.sh --tag ${{ env.IMAGE_TAG }} --framework ${{ matrix.framework }} --cache-from "${{ env.CACHE_FROM }}" --cache-to "${{ env.CACHE_TO }}" ./container/build.sh --tag ${{ env.IMAGE_TAG }} --framework ${{ matrix.framework }} ${{ steps.which_caches.outputs.cache_from_location }} ${{ steps.which_caches.outputs.cache_to_location }}
- name: Run pytest - name: Run pytest
env: env:
PYTEST_MARKS: "pre_merge or mypy" PYTEST_MARKS: "pre_merge or mypy"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment