66 tags : ["*"]
77 pull_request :
88 branches : [ "*" ]
9+
10+ # TiDB versions used in tests - single source of truth
11+ # Latest version of each minor series: 6.1.x, 6.5.x, 7.1.x, 7.5.x, 8.1.x, 8.5.x
12+ env :
13+ TIDB_VERSIONS : " 6.1.7 6.5.12 7.1.6 7.5.7 8.1.2 8.5.3"
14+
915jobs :
1016 lint :
1117 runs-on : ubuntu-22.04
2127 - name : Running ${{ matrix.command }}
2228 run : ${{ matrix.command }}
2329
30+ prepare-dependencies :
31+ name : Prepare Dependencies
32+ runs-on : ubuntu-22.04
33+ steps :
34+ - name : Checkout Git repo
35+ uses : actions/checkout@v4
36+ with :
37+ fetch-depth : 1
38+
39+ - name : Validate TiDB versions sync
40+ run : |
41+ # Extract TiDB versions from test matrix and compare with env.TIDB_VERSIONS
42+ 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)
44+
45+ echo "Expected versions (from env): $EXPECTED_VERSIONS"
46+ echo "Matrix versions (from test targets): $MATRIX_VERSIONS"
47+
48+ # Check if versions match (simple check - both should contain same versions)
49+ MISSING=""
50+ for version in $EXPECTED_VERSIONS; do
51+ if ! echo "$MATRIX_VERSIONS" | grep -q "$version"; then
52+ MISSING="$MISSING $version"
53+ fi
54+ done
55+
56+ if [ -n "$MISSING" ]; then
57+ 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"
59+ exit 1
60+ fi
61+
62+ echo "✓ TiDB versions are in sync"
63+
64+ - name : Set up Go
65+ uses : actions/setup-go@v4
66+ with :
67+ go-version-file : go.mod
68+
69+ - name : Download Terraform
70+ run : |
71+ mkdir -p bin
72+ curl -sfL https://releases.hashicorp.com/terraform/1.5.6/terraform_1.5.6_linux_amd64.zip > bin/terraform.zip
73+ cd bin && unzip terraform.zip && rm terraform.zip && chmod +x terraform
74+
75+ - name : Vendor Go dependencies
76+ run : go mod vendor
77+
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
94+
95+ - name : Upload Terraform binary
96+ uses : actions/upload-artifact@v4
97+ with :
98+ name : terraform-binary
99+ path : bin/terraform
100+ retention-days : 1
101+
102+ - name : Upload vendor directory
103+ uses : actions/upload-artifact@v4
104+ with :
105+ name : vendor-dir
106+ path : vendor/
107+ retention-days : 1
108+ compression-level : 6
109+
24110 tests :
25111 runs-on : ubuntu-22.04
112+ needs : [prepare-dependencies]
26113 strategy :
27114 fail-fast : false
28115 matrix :
@@ -36,20 +123,169 @@ jobs:
36123 - testmariadb10.8
37124 - testmariadb10.10
38125 # Track https://github.com/pingcap/tidb/tags
39- - testtidb6.1.0
40- - testtidb6.5.3
41- # - testtidb6.5.10
42- - testtidb7.1.5
43- - testtidb7.5.2
44- - testtidb8.1.0
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
45134 steps :
46135 - name : Checkout Git repo
47136 uses : actions/checkout@v4
137+ with :
138+ fetch-depth : 1
139+
140+ - name : Set up Go
141+ uses : actions/setup-go@v4
142+ with :
143+ go-version-file : go.mod
144+
145+ - name : Download Terraform binary
146+ uses : actions/download-artifact@v4
147+ with :
148+ name : terraform-binary
149+ path : bin/
150+
151+ - name : Download vendor directory
152+ uses : actions/download-artifact@v4
153+ with :
154+ name : vendor-dir
155+ path : vendor/
156+
157+ - name : Make Terraform executable
158+ run : chmod +x bin/terraform
159+
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+
48168 - name : Install mysql client
49169 run : |
50- sudo apt-get update
51- sudo apt-get -f -y install mysql-client
170+ sudo apt-get update -qq
171+ sudo apt-get install -y --no-install-recommends mysql-client
172+
173+ - name : Set up Docker Buildx
174+ if : contains(matrix.target, 'testversion') || contains(matrix.target, 'testpercona') || contains(matrix.target, 'testmariadb')
175+ uses : docker/setup-buildx-action@v3
176+
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')
215+ 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}"
220+
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')
227+ 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 }}
255+
256+ - name : 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 : 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+
52286 - name : Run tests {{ matrix.target }}
287+ env :
288+ GOFLAGS : -mod=vendor
53289 run : make ${{ matrix.target }}
54290 # DISABLED to figure out GPG signing issue on Github Actions
55291 # possibly due to lack of TTY inside docker?
0 commit comments