Skip to content

Commit f90519d

Browse files
committed
ci: cache docker layers and avoid re-downloading them for each job
Sometimes the CI fails because Docker doesn't respond. It could be because we download many docker images in every job and we have 58 jobs now. With this commit, the image layers will be downloaded during nightly builds and cached. Signed-off-by: Salvatore Mesoraca <[email protected]>
1 parent cd24489 commit f90519d

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.github/workflows/integration.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,29 @@ jobs:
5050
pip install -r dev_requirements.txt
5151
invoke linters
5252
53+
populate-cache:
54+
runs-on: ubuntu-latest
55+
timeout-minutes: 60
56+
name: Update docker cache
57+
steps:
58+
- uses: actions/checkout@v4
59+
- name: Cache docker images
60+
id: custom-cache
61+
uses: actions/cache@v3
62+
with:
63+
path: ./custom-cache/
64+
key: custom-cache
65+
- if: ${{ steps.custom-cache.outputs.cache-hit != 'true' || github.event_name == 'schedule' }}
66+
name: Update Cache
67+
run: |
68+
mkdir -p ./custom-cache/
69+
docker compose --profile all build
70+
docker pull valkey/valkey:latest
71+
docker save valkey-py-stunnel:latest valkey-py-cluster:latest valkey/valkey:latest -o ./custom-cache/all.tar
72+
5373
run-tests:
5474
runs-on: ubuntu-latest
75+
needs: [populate-cache]
5576
timeout-minutes: 60
5677
strategy:
5778
max-parallel: 15
@@ -70,6 +91,17 @@ jobs:
7091
with:
7192
python-version: ${{ matrix.python-version }}
7293
cache: 'pip'
94+
95+
- name: Cache docker images
96+
id: custom-cache
97+
uses: actions/cache@v3
98+
with:
99+
path: ./custom-cache/
100+
fail-on-cache-miss: true
101+
key: custom-cache
102+
- name: Use Cache
103+
run: docker image load -i ./custom-cache/all.tar
104+
73105
- name: run tests
74106
run: |
75107
pip install -U setuptools wheel
@@ -115,6 +147,17 @@ jobs:
115147
- uses: actions/setup-python@v5
116148
with:
117149
python-version: 3.9
150+
151+
- name: Cache docker images
152+
id: custom-cache
153+
uses: actions/cache@v3
154+
with:
155+
path: ./custom-cache/
156+
fail-on-cache-miss: true
157+
key: custom-cache
158+
- name: Use Cache
159+
run: docker image load -i ./custom-cache/all.tar
160+
118161
- name: Run installed unit tests
119162
run: |
120163
bash .github/workflows/install_and_test.sh ${{ matrix.extension }}

0 commit comments

Comments
 (0)