@@ -40,10 +40,10 @@ jobs:
4040 run : |
4141 # Extract TiDB versions from test matrix and compare with env.TIDB_VERSIONS
4242 EXPECTED_VERSIONS="${{ env.TIDB_VERSIONS }}"
43- MATRIX_VERSIONS=$(grep -E "testtidb[0-9] " .github/workflows/main.yml | sed 's/.*testtidb \([0-9.]*\).*/\1/' | tr '\n' ' ' | xargs)
43+ MATRIX_VERSIONS=$(grep -A 20 "db_type: tidb " .github/workflows/main.yml | grep "db_version:" | sed 's/.*db_version: " \([0-9.]*\)" .*/\1/' | tr '\n' ' ' | xargs)
4444
4545 echo "Expected versions (from env): $EXPECTED_VERSIONS"
46- echo "Matrix versions (from test targets ): $MATRIX_VERSIONS"
46+ echo "Matrix versions (from workflow ): $MATRIX_VERSIONS"
4747
4848 # Check if versions match (simple check - both should contain same versions)
4949 MISSING=""
5555
5656 if [ -n "$MISSING" ]; then
5757 echo "ERROR: TiDB versions in env.TIDB_VERSIONS not found in test matrix: $MISSING"
58- echo "Please ensure test matrix includes testtidb* entries for all versions in env.TIDB_VERSIONS"
58+ echo "Please ensure test matrix includes tidb entries for all versions in env.TIDB_VERSIONS"
5959 exit 1
6060 fi
6161
7575 - name : Vendor Go dependencies
7676 run : go mod vendor
7777
78- # Note: TiDB tests now use Docker images with Buildx caching instead of TiUP
79- # Docker images are cached per version in individual test jobs using Buildx with GHA cache backend
80- # Each test job pulls and caches its own images - no pre-pull needed since Docker layer cache is ephemeral per job
81-
82- - name : Cache apt packages
83- uses : actions/cache@v4
84- with :
85- path : /var/cache/apt/archives
86- key : ${{ runner.os }}-apt-${{ hashFiles('**/.github/workflows/main.yml') }}
87- restore-keys : |
88- ${{ runner.os }}-apt-
89-
90- - name : Install mysql client (populates cache for test jobs)
91- run : |
92- sudo apt-get update -qq
93- sudo apt-get install -y --no-install-recommends mysql-client
78+ # Note: Tests now use testcontainers - no mysql-client or Docker Buildx caching needed
79+ # Testcontainers handles container lifecycle and image pulling automatically
9480
9581 - name : Upload Terraform binary
9682 uses : actions/upload-artifact@v4
@@ -113,24 +99,47 @@ jobs:
11399 strategy :
114100 fail-fast : false
115101 matrix :
116- target :
117- - testversion5.6
118- - testversion5.7
119- - testversion8.0
120- - testpercona5.7
121- - testpercona8.0
122- - testmariadb10.3
123- - testmariadb10.8
124- - testmariadb10.10
125- # Track https://github.com/pingcap/tidb/tags
126- # TiDB versions must match env.TIDB_VERSIONS: 6.1.7 6.5.12 7.1.6 7.5.7 8.1.2 8.5.3
127- # Latest version of each minor series
128- - testtidb6.1.7
129- - testtidb6.5.12
130- - testtidb7.1.6
131- - testtidb7.5.7
132- - testtidb8.1.2
133- - testtidb8.5.3
102+ include :
103+ # MySQL versions
104+ - db_type : mysql
105+ db_version : " 5.6"
106+ docker_image : " mysql:5.6"
107+ - db_type : mysql
108+ db_version : " 5.7"
109+ docker_image : " mysql:5.7"
110+ - db_type : mysql
111+ db_version : " 8.0"
112+ docker_image : " mysql:8.0"
113+ # Percona versions
114+ - db_type : percona
115+ db_version : " 5.7"
116+ docker_image : " percona:5.7"
117+ - db_type : percona
118+ db_version : " 8.0"
119+ docker_image : " percona:8.0"
120+ # MariaDB versions
121+ - db_type : mariadb
122+ db_version : " 10.3"
123+ docker_image : " mariadb:10.3"
124+ - db_type : mariadb
125+ db_version : " 10.8"
126+ docker_image : " mariadb:10.8"
127+ - db_type : mariadb
128+ db_version : " 10.10"
129+ docker_image : " mariadb:10.10"
130+ # TiDB versions - must match env.TIDB_VERSIONS: 6.1.7 6.5.12 7.1.6 7.5.7 8.1.2 8.5.3
131+ - db_type : tidb
132+ db_version : " 6.1.7"
133+ - db_type : tidb
134+ db_version : " 6.5.12"
135+ - db_type : tidb
136+ db_version : " 7.1.6"
137+ - db_type : tidb
138+ db_version : " 7.5.7"
139+ - db_type : tidb
140+ db_version : " 8.1.2"
141+ - db_type : tidb
142+ db_version : " 8.5.3"
134143 steps :
135144 - name : Checkout Git repo
136145 uses : actions/checkout@v4
@@ -157,136 +166,33 @@ jobs:
157166 - name : Make Terraform executable
158167 run : chmod +x bin/terraform
159168
160- - name : Cache apt packages
161- uses : actions/cache@v4
162- with :
163- path : /var/cache/apt/archives
164- key : ${{ runner.os }}-apt-${{ hashFiles('**/.github/workflows/main.yml') }}
165- restore-keys : |
166- ${{ runner.os }}-apt-
167-
168- - name : Install mysql client
169- run : |
170- sudo apt-get update -qq
171- sudo apt-get install -y --no-install-recommends mysql-client
172-
173169 - name : Set up Docker Buildx
174- if : contains(matrix.target, 'testversion') || contains(matrix.target, 'testpercona') || contains(matrix.target, 'testmariadb')
175170 uses : docker/setup-buildx-action@v3
176171
177- - name : Determine Docker image for this test
178- if : contains(matrix.target, 'testversion') || contains(matrix.target, 'testpercona') || contains(matrix.target, 'testmariadb')
179- id : docker-image
180- run : |
181- if [[ "${{ matrix.target }}" == testversion5.6 ]]; then
182- echo "image=mysql:5.6" >> $GITHUB_OUTPUT
183- elif [[ "${{ matrix.target }}" == testversion5.7 ]]; then
184- echo "image=mysql:5.7" >> $GITHUB_OUTPUT
185- elif [[ "${{ matrix.target }}" == testversion8.0 ]]; then
186- echo "image=mysql:8.0" >> $GITHUB_OUTPUT
187- elif [[ "${{ matrix.target }}" == testpercona5.7 ]]; then
188- echo "image=percona:5.7" >> $GITHUB_OUTPUT
189- elif [[ "${{ matrix.target }}" == testpercona8.0 ]]; then
190- echo "image=percona:8.0" >> $GITHUB_OUTPUT
191- elif [[ "${{ matrix.target }}" == testmariadb10.3 ]]; then
192- echo "image=mariadb:10.3" >> $GITHUB_OUTPUT
193- elif [[ "${{ matrix.target }}" == testmariadb10.8 ]]; then
194- echo "image=mariadb:10.8" >> $GITHUB_OUTPUT
195- elif [[ "${{ matrix.target }}" == testmariadb10.10 ]]; then
196- echo "image=mariadb:10.10" >> $GITHUB_OUTPUT
197- fi
198-
199- - name : Pull and cache Docker image using Buildx
200- if : contains(matrix.target, 'testversion') || contains(matrix.target, 'testpercona') || contains(matrix.target, 'testmariadb')
201- uses : docker/build-push-action@v5
202- with :
203- context : .
204- file : Dockerfile.mysql
205- push : false
206- tags : ${{ steps.docker-image.outputs.image }}
207- build-args : |
208- MYSQL_IMAGE=${{ steps.docker-image.outputs.image }}
209- cache-from : type=gha,scope=${{ steps.docker-image.outputs.image }}
210- cache-to : type=gha,mode=max,scope=${{ steps.docker-image.outputs.image }}
211-
212- - name : Extract TiDB version from test target
213- id : extract-tidb-version
214- if : contains(matrix.target, 'tidb')
172+ - name : Pre-pull Docker images for caching
173+ if : matrix.db_type != 'tidb'
215174 run : |
216- # Extract version from testtidb6.1.7 -> 6.1.7
217- VERSION=$(echo "${{ matrix.target }}" | sed 's/testtidb//')
218- echo "version=${VERSION}" >> $GITHUB_OUTPUT
219- echo "TiDB version for this test: ${VERSION}"
175+ docker pull ${{ matrix.docker_image }} || true
220176
221- - name : Set up Docker Buildx for TiDB
222- if : contains(matrix.target, 'tidb')
223- uses : docker/setup-buildx-action@v3
224-
225- - name : Pull TiDB Docker images in parallel
226- if : contains(matrix.target, 'tidb')
177+ - name : Pre-pull TiDB images for caching
178+ if : matrix.db_type == 'tidb'
227179 run : |
228- VERSION="${{ steps.extract-tidb-version.outputs.version }}"
229- echo "Pulling TiDB component images for v${VERSION} in parallel..."
230-
231- # Pull all three images in parallel
232- docker pull pingcap/tidb:v${VERSION} &
233- docker pull pingcap/pd:v${VERSION} &
234- docker pull pingcap/tikv:v${VERSION} &
235-
236- # Wait for all pulls to complete
237- wait
238-
239- echo "All TiDB component images pulled successfully"
240-
241- - name : Cache TiDB Docker images using Buildx
242- if : contains(matrix.target, 'tidb')
243- uses : docker/build-push-action@v5
244- continue-on-error : false
245- with :
246- context : .
247- file : Dockerfile.tidb
248- push : false
249- tags : pingcap/tidb:v${{ steps.extract-tidb-version.outputs.version }}
250- build-args : |
251- TIDB_COMPONENT=pingcap/tidb
252- TIDB_VERSION=v${{ steps.extract-tidb-version.outputs.version }}
253- cache-from : type=gha,scope=tidb-v${{ steps.extract-tidb-version.outputs.version }}
254- cache-to : type=gha,mode=max,scope=tidb-v${{ steps.extract-tidb-version.outputs.version }}
180+ docker pull pingcap/tidb:v${{ matrix.db_version }} || true
181+ docker pull pingcap/pd:v${{ matrix.db_version }} || true
182+ docker pull pingcap/tikv:v${{ matrix.db_version }} || true
255183
256- - name : Pull and cache PD Docker image using Buildx
257- if : contains(matrix.target, 'tidb')
258- uses : docker/build-push-action@v5
259- continue-on-error : false
260- with :
261- context : .
262- file : Dockerfile.tidb
263- push : false
264- tags : pingcap/pd:v${{ steps.extract-tidb-version.outputs.version }}
265- build-args : |
266- TIDB_COMPONENT=pingcap/pd
267- TIDB_VERSION=v${{ steps.extract-tidb-version.outputs.version }}
268- cache-from : type=gha,scope=pd-v${{ steps.extract-tidb-version.outputs.version }}
269- cache-to : type=gha,mode=max,scope=pd-v${{ steps.extract-tidb-version.outputs.version }}
270-
271- - name : Pull and cache TiKV Docker image using Buildx
272- if : contains(matrix.target, 'tidb')
273- uses : docker/build-push-action@v5
274- continue-on-error : false
275- with :
276- context : .
277- file : Dockerfile.tidb
278- push : false
279- tags : pingcap/tikv:v${{ steps.extract-tidb-version.outputs.version }}
280- build-args : |
281- TIDB_COMPONENT=pingcap/tikv
282- TIDB_VERSION=v${{ steps.extract-tidb-version.outputs.version }}
283- cache-from : type=gha,scope=tikv-v${{ steps.extract-tidb-version.outputs.version }}
284- cache-to : type=gha,mode=max,scope=tikv-v${{ steps.extract-tidb-version.outputs.version }}
285-
286- - name : Run tests {{ matrix.target }}
184+ - name : Run testcontainers tests
287185 env :
288186 GOFLAGS : -mod=vendor
289- run : make ${{ matrix.target }}
187+ TF_ACC : 1
188+ GOTOOLCHAIN : auto
189+ run : |
190+ export PATH="${{ github.workspace }}/bin:$PATH"
191+ if [ "${{ matrix.db_type }}" == "tidb" ]; then
192+ TIDB_VERSION=${{ matrix.db_version }} go test -tags=testcontainers -v ./mysql/... -run WithTestcontainers -timeout=30m
193+ else
194+ DOCKER_IMAGE=${{ matrix.docker_image }} go test -tags=testcontainers -v ./mysql/... -run WithTestcontainers -timeout=30m
195+ fi
290196 # DISABLED to figure out GPG signing issue on Github Actions
291197 # possibly due to lack of TTY inside docker?
292198 # release:
0 commit comments