@@ -197,72 +197,45 @@ jobs:
197197 sudo apt-get update -qq
198198 sudo apt-get install -y --no-install-recommends mysql-client
199199
200- - name : Cache Docker images (save/load approach)
200+ - name : Set up Docker Buildx
201201 if : contains(matrix.target, 'testversion') || contains(matrix.target, 'testpercona') || contains(matrix.target, 'testmariadb')
202- id : cache-docker-images
203- uses : actions/cache@v4
204- with :
205- path : /tmp/docker-images
206- key : ${{ runner.os }}-docker-${{ matrix.target }}-v1
207- restore-keys : |
208- ${{ runner.os }}-docker-${{ matrix.target }}-
209- ${{ runner.os }}-docker-
202+ uses : docker/setup-buildx-action@v3
210203
211- - name : Load Docker image from cache (if available)
212- if : (contains(matrix.target, 'testversion') || contains(matrix.target, 'testpercona') || contains(matrix.target, 'testmariadb')) && steps.cache-docker-images.outputs.cache-hit == 'true'
213- run : |
214- # Load cached image if available
215- if [[ "${{ matrix.target }}" == testversion5.6 ]] && [ -f /tmp/docker-images/mysql-5.6.tar ]; then
216- docker load -i /tmp/docker-images/mysql-5.6.tar
217- elif [[ "${{ matrix.target }}" == testversion5.7 ]] && [ -f /tmp/docker-images/mysql-5.7.tar ]; then
218- docker load -i /tmp/docker-images/mysql-5.7.tar
219- elif [[ "${{ matrix.target }}" == testversion8.0 ]] && [ -f /tmp/docker-images/mysql-8.0.tar ]; then
220- docker load -i /tmp/docker-images/mysql-8.0.tar
221- elif [[ "${{ matrix.target }}" == testpercona5.7 ]] && [ -f /tmp/docker-images/percona-5.7.tar ]; then
222- docker load -i /tmp/docker-images/percona-5.7.tar
223- elif [[ "${{ matrix.target }}" == testpercona8.0 ]] && [ -f /tmp/docker-images/percona-8.0.tar ]; then
224- docker load -i /tmp/docker-images/percona-8.0.tar
225- elif [[ "${{ matrix.target }}" == testmariadb10.3 ]] && [ -f /tmp/docker-images/mariadb-10.3.tar ]; then
226- docker load -i /tmp/docker-images/mariadb-10.3.tar
227- elif [[ "${{ matrix.target }}" == testmariadb10.8 ]] && [ -f /tmp/docker-images/mariadb-10.8.tar ]; then
228- docker load -i /tmp/docker-images/mariadb-10.8.tar
229- elif [[ "${{ matrix.target }}" == testmariadb10.10 ]] && [ -f /tmp/docker-images/mariadb-10.10.tar ]; then
230- docker load -i /tmp/docker-images/mariadb-10.10.tar
231- fi
232-
233- - name : Pre-pull Docker image for this test
204+ - name : Determine Docker image for this test
234205 if : contains(matrix.target, 'testversion') || contains(matrix.target, 'testpercona') || contains(matrix.target, 'testmariadb')
206+ id : docker-image
235207 run : |
236- # Pre-pull the Docker image needed for this test
237- # If cache hit, docker pull will be fast (only missing layers)
238- # If cache miss, full pull happens and we'll save it for next run
239- mkdir -p /tmp/docker-images
240208 if [[ "${{ matrix.target }}" == testversion5.6 ]]; then
241- docker pull mysql:5.6
242- docker save mysql:5.6 -o /tmp/docker-images/mysql-5.6.tar || true
209+ echo "image=mysql:5.6" >> $GITHUB_OUTPUT
243210 elif [[ "${{ matrix.target }}" == testversion5.7 ]]; then
244- docker pull mysql:5.7
245- docker save mysql:5.7 -o /tmp/docker-images/mysql-5.7.tar || true
211+ echo "image=mysql:5.7" >> $GITHUB_OUTPUT
246212 elif [[ "${{ matrix.target }}" == testversion8.0 ]]; then
247- docker pull mysql:8.0
248- docker save mysql:8.0 -o /tmp/docker-images/mysql-8.0.tar || true
213+ echo "image=mysql:8.0" >> $GITHUB_OUTPUT
249214 elif [[ "${{ matrix.target }}" == testpercona5.7 ]]; then
250- docker pull percona:5.7
251- docker save percona:5.7 -o /tmp/docker-images/percona-5.7.tar || true
215+ echo "image=percona:5.7" >> $GITHUB_OUTPUT
252216 elif [[ "${{ matrix.target }}" == testpercona8.0 ]]; then
253- docker pull percona:8.0
254- docker save percona:8.0 -o /tmp/docker-images/percona-8.0.tar || true
217+ echo "image=percona:8.0" >> $GITHUB_OUTPUT
255218 elif [[ "${{ matrix.target }}" == testmariadb10.3 ]]; then
256- docker pull mariadb:10.3
257- docker save mariadb:10.3 -o /tmp/docker-images/mariadb-10.3.tar || true
219+ echo "image=mariadb:10.3" >> $GITHUB_OUTPUT
258220 elif [[ "${{ matrix.target }}" == testmariadb10.8 ]]; then
259- docker pull mariadb:10.8
260- docker save mariadb:10.8 -o /tmp/docker-images/mariadb-10.8.tar || true
221+ echo "image=mariadb:10.8" >> $GITHUB_OUTPUT
261222 elif [[ "${{ matrix.target }}" == testmariadb10.10 ]]; then
262- docker pull mariadb:10.10
263- docker save mariadb:10.10 -o /tmp/docker-images/mariadb-10.10.tar || true
223+ echo "image=mariadb:10.10" >> $GITHUB_OUTPUT
264224 fi
265225
226+ - name : Pull and cache Docker image using Buildx
227+ if : contains(matrix.target, 'testversion') || contains(matrix.target, 'testpercona') || contains(matrix.target, 'testmariadb')
228+ uses : docker/build-push-action@v5
229+ with :
230+ context : .
231+ file : Dockerfile.mysql
232+ push : false
233+ tags : ${{ steps.docker-image.outputs.image }}
234+ build-args : |
235+ MYSQL_IMAGE=${{ steps.docker-image.outputs.image }}
236+ cache-from : type=gha,scope=${{ steps.docker-image.outputs.image }}
237+ cache-to : type=gha,mode=max,scope=${{ steps.docker-image.outputs.image }}
238+
266239 - name : Extract TiDB version from test target
267240 id : extract-tidb-version
268241 if : contains(matrix.target, 'tidb')
0 commit comments