@@ -75,22 +75,17 @@ jobs:
7575 - name : Vendor Go dependencies
7676 run : go mod vendor
7777
78- - name : Generate TiDB versions hash
79- id : tidb-versions-hash
80- run : |
81- echo "hash=$(echo '${{ env.TIDB_VERSIONS }}' | sha256sum | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
82-
83- - name : Cache TiUP components
84- id : cache-tiup
78+ - name : Cache TiUP binary
79+ id : cache-tiup-binary
8580 uses : actions/cache@v4
8681 with :
8782 path : |
88- ~/.tiup
89- # Include workflow hash and TiDB versions hash in cache key so cache updates when versions change
90- key : ${{ runner.os }}-tiup-${{ hashFiles('.github/workflows/main.yml') }}-${{ hashFiles('**/go.mod') }}-${{ steps.tidb-versions-hash.outputs.hash }}
83+ ~/.tiup/bin
84+ ~/.tiup/manifests
85+ # Cache TiUP binary separately (small, ~20MB)
86+ key : ${{ runner.os }}-tiup-binary-${{ hashFiles('.github/workflows/main.yml') }}
9187 restore-keys : |
92- ${{ runner.os }}-tiup-${{ hashFiles('.github/workflows/main.yml') }}-${{ hashFiles('**/go.mod') }}-
93- ${{ runner.os }}-tiup-
88+ ${{ runner.os }}-tiup-binary-
9489
9590 - name : Install TiUP
9691 run : |
@@ -105,18 +100,8 @@ jobs:
105100 tiup update --self || true
106101 tiup update playground || true
107102
108- - name : Pre-download TiDB versions
109- run : |
110- export PATH=$HOME/.tiup/bin:$PATH
111- # Pre-download all TiDB versions from env.TIDB_VERSIONS (single source of truth)
112- echo "Pre-downloading TiDB versions: ${{ env.TIDB_VERSIONS }}"
113- for version in ${{ env.TIDB_VERSIONS }}; do
114- echo "Pre-downloading TiDB components for v${version}..."
115- tiup install tidb:v${version} || true
116- tiup install pd:v${version} || true
117- tiup install tikv:v${version} || true
118- done
119- echo "TiDB version pre-download complete"
103+ # Note: TiDB components are NOT pre-downloaded here to avoid huge cache timeout
104+ # Each test job will download and cache only the version it needs (~700-800MB per version)
120105
121106 - name : Upload Terraform binary
122107 uses : actions/upload-artifact@v4
@@ -196,24 +181,40 @@ jobs:
196181 sudo apt-get update -qq
197182 sudo apt-get install -y --no-install-recommends mysql-client
198183
199- - name : Generate TiDB versions hash
200- id : tidb-versions-hash-test
184+ - name : Extract TiDB version from test target
185+ id : extract- tidb-version
201186 if : contains(matrix.target, 'tidb')
202187 run : |
203- echo "hash=$(echo '${{ env.TIDB_VERSIONS }}' | sha256sum | cut -d' ' -f1 | cut -c1-8)" >> $GITHUB_OUTPUT
188+ # Extract version from testtidb6.1.7 -> 6.1.7
189+ VERSION=$(echo "${{ matrix.target }}" | sed 's/testtidb//')
190+ echo "version=${VERSION}" >> $GITHUB_OUTPUT
191+ echo "TiDB version for this test: ${VERSION}"
192+
193+ - name : Cache TiUP binary (shared across all TiDB tests)
194+ id : cache-tiup-binary-test
195+ if : contains(matrix.target, 'tidb')
196+ uses : actions/cache@v4
197+ with :
198+ path : |
199+ ~/.tiup/bin
200+ ~/.tiup/manifests
201+ # Cache TiUP binary separately (small, ~20MB) - shared by all TiDB tests
202+ key : ${{ runner.os }}-tiup-binary-${{ hashFiles('.github/workflows/main.yml') }}
203+ restore-keys : |
204+ ${{ runner.os }}-tiup-binary-
204205
205- - name : Cache TiUP components
206- id : cache-tiup-test
206+ - name : Cache TiDB components for this specific version
207+ id : cache-tidb-version
207208 if : contains(matrix.target, 'tidb')
208209 uses : actions/cache@v4
209210 with :
210211 path : |
211- ~/.tiup
212- # Use same cache key as prepare-dependencies job to share cache
213- key : ${{ runner.os }}-tiup-${{ hashFiles('.github/workflows/main.yml') }}-${{ hashFiles('**/go.mod') }}-${{ steps.tidb-versions-hash-test.outputs.hash }}
212+ ~/.tiup/components
213+ # Cache components directory per version (~700-800MB per version instead of 4.5GB total)
214+ # Each test job caches only the version it needs
215+ key : ${{ runner.os }}-tidb-${{ steps.extract-tidb-version.outputs.version }}-${{ hashFiles('.github/workflows/main.yml') }}
214216 restore-keys : |
215- ${{ runner.os }}-tiup-${{ hashFiles('.github/workflows/main.yml') }}-${{ hashFiles('**/go.mod') }}-
216- ${{ runner.os }}-tiup-
217+ ${{ runner.os }}-tidb-${{ steps.extract-tidb-version.outputs.version }}-
217218
218219 - name : Install TiUP (if not cached)
219220 if : contains(matrix.target, 'tidb')
@@ -232,6 +233,17 @@ jobs:
232233 tiup update --self || true
233234 tiup update playground || true
234235
236+ - name : Install TiDB components for this version (if not cached)
237+ if : contains(matrix.target, 'tidb') && steps.cache-tidb-version.outputs.cache-hit != 'true'
238+ run : |
239+ export PATH=$HOME/.tiup/bin:$PATH
240+ VERSION="${{ steps.extract-tidb-version.outputs.version }}"
241+ echo "Installing TiDB components for v${VERSION} (cache miss)..."
242+ tiup install tidb:v${VERSION} || true
243+ tiup install pd:v${VERSION} || true
244+ tiup install tikv:v${VERSION} || true
245+ echo "TiDB v${VERSION} components installed and will be cached for next run"
246+
235247 - name : Run tests {{ matrix.target }}
236248 env :
237249 GOFLAGS : -mod=vendor
0 commit comments