Skip to content

Commit f8a0df9

Browse files
committed
Enforce DOCKER_IMAGE is set - fail early if missing
- Add validation in workflow to check DOCKER_IMAGE is set before running tests - Update TestMain to fail immediately if DOCKER_IMAGE is empty instead of defaulting to mysql:8.0 - Add validation for TIDB_VERSION as well - This prevents silent failures and ensures correct Docker images are used
1 parent 5653951 commit f8a0df9

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

.github/workflows/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,18 @@ jobs:
190190
export PATH="${{ github.workspace }}/bin:$PATH"
191191
if [ "${{ matrix.db_type }}" == "tidb" ]; then
192192
export TIDB_VERSION=${{ matrix.db_version }}
193+
if [ -z "$TIDB_VERSION" ]; then
194+
echo "ERROR: TIDB_VERSION is not set for TiDB test"
195+
exit 1
196+
fi
193197
go test -tags=testcontainers -v ./mysql/... -run WithTestcontainers -timeout=30m
194198
else
195199
export DOCKER_IMAGE=${{ matrix.docker_image }}
200+
if [ -z "$DOCKER_IMAGE" ]; then
201+
echo "ERROR: DOCKER_IMAGE is not set for ${{ matrix.db_type }} test"
202+
exit 1
203+
fi
204+
echo "Using Docker image: $DOCKER_IMAGE"
196205
go test -tags=testcontainers -v ./mysql/... -run WithTestcontainers -timeout=30m
197206
fi
198207
release:

mysql/testcontainers_testmain.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ func TestMain(m *testing.M) {
4242
os.Exit(code)
4343
}
4444

45-
// Default to MySQL 8.0, but allow override via DOCKER_IMAGE env var
45+
// Require DOCKER_IMAGE to be set - fail early if missing
4646
mysqlImage := os.Getenv("DOCKER_IMAGE")
4747
if mysqlImage == "" {
48-
mysqlImage = "mysql:8.0"
48+
os.Stderr.WriteString("ERROR: DOCKER_IMAGE environment variable is not set. This is required for MySQL/Percona/MariaDB tests.\n")
49+
os.Stderr.WriteString("Please set DOCKER_IMAGE to the appropriate Docker image (e.g., mysql:5.6, percona:8.0, mariadb:10.10)\n")
50+
os.Exit(1)
4951
}
5052

5153
// Start shared container before running tests

0 commit comments

Comments
 (0)