Skip to content

Commit

Permalink
github: fix caching the docker images
Browse files Browse the repository at this point in the history
This commit updates the way docker cache is created by including the
current date into the cache key. Now when "save-always" option in
actions/cache is deprecated [1] this seems to be the conventional
way [2] to create the cache.

[1] actions/cache#1452
[2] https://github.com/actions/cache?tab=readme-ov-file#creating-a-cache-key

Signed-off-by: Mikhail Koviazin <[email protected]>
  • Loading branch information
mkmkme committed Mar 7, 2025
1 parent fd0e9b7 commit 144c5a2
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,18 @@ jobs:
pip install -r dev_requirements.txt
invoke linters
get-date:
outputs:
current_date: ${{ steps.date.outputs.current_date }}
runs-on: ubuntu-latest
steps:
- name: Set current date
id: date
run: echo "current_date=$(date -u +'%Y%m%d')" >> $GITHUB_OUTPUT

populate-cache:
runs-on: ubuntu-latest
needs: [get-date, dependency-audit, lint]
timeout-minutes: 60
name: Update docker cache
steps:
Expand All @@ -61,8 +71,8 @@ jobs:
uses: actions/cache@v4
with:
path: ./custom-cache/
key: custom-cache
- if: ${{ steps.custom-cache.outputs.cache-hit != 'true' || github.event_name == 'schedule' }}
key: custom-cache-${{ needs.get-date.outputs.current_date }}
- if: ${{ steps.custom-cache.outputs.cache-hit != 'true' }}
name: Update Cache
run: |
mkdir -p ./custom-cache/
Expand All @@ -72,7 +82,7 @@ jobs:
run-tests:
runs-on: ubuntu-latest
needs: [populate-cache]
needs: [populate-cache, get-date]
timeout-minutes: 60
strategy:
max-parallel: 15
Expand All @@ -98,7 +108,7 @@ jobs:
with:
path: ./custom-cache/
fail-on-cache-miss: true
key: custom-cache
key: custom-cache-${{ needs.get-date.outputs.current_date }}
- name: Use Cache
run: docker image load -i ./custom-cache/all.tar

Expand Down Expand Up @@ -137,7 +147,7 @@ jobs:
build_and_test_package:
name: Validate building and installing the package
runs-on: ubuntu-latest
needs: [run-tests]
needs: [run-tests, get-date, populate-cache]
strategy:
fail-fast: false
matrix:
Expand All @@ -154,7 +164,7 @@ jobs:
with:
path: ./custom-cache/
fail-on-cache-miss: true
key: custom-cache
key: custom-cache-${{ needs.get-date.outputs.current_date }}
- name: Use Cache
run: docker image load -i ./custom-cache/all.tar

Expand Down

0 comments on commit 144c5a2

Please sign in to comment.