Skip to content

Commit 2eebcc4

Browse files
committed
ci: enforce zero-warning policy and dynamic test env
1 parent e479ba7 commit 2eebcc4

6 files changed

Lines changed: 98 additions & 16 deletions

File tree

.github/workflows/pull_request.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ jobs:
5050
5151
- name: Run help mode
5252
run: |
53-
sudo perl ./mysqltuner.pl --help
53+
set -o pipefail
54+
sudo perl ./mysqltuner.pl --help 2>&1 | tee output.log
55+
if grep -iE 'use of uninitialized value|warning' output.log; then
56+
echo "Zero-Warning Quality Gate Failed: Warnings detected in test output!"
57+
exit 1
58+
fi
5459
5560
test_with_empty_db:
5661
needs: test_help
@@ -84,4 +89,25 @@ jobs:
8489
8590
# Runs a single command using the runners shell
8691
- name: Run verbose mode
87-
run: sudo perl ./mysqltuner.pl --user=root --pass=root --protocol tcp --verbose
92+
run: |
93+
set -o pipefail
94+
sudo perl ./mysqltuner.pl --user=root --pass=root --protocol tcp --verbose 2>&1 | tee output.log
95+
if grep -iE 'use of uninitialized value|warning' output.log; then
96+
echo "Zero-Warning Quality Gate Failed: Warnings detected in test output!"
97+
exit 1
98+
fi
99+
100+
unit_tests:
101+
runs-on: ubuntu-latest
102+
steps:
103+
- name: Setup MySQL Tuner repository
104+
uses: actions/checkout@v6
105+
106+
- name: Run unit tests
107+
run: |
108+
set -o pipefail
109+
make unit-tests 2>&1 | tee test_output.log
110+
if grep -iE 'use of uninitialized value|warning' test_output.log; then
111+
echo "Zero-Warning Quality Gate Failed: Warnings detected in test output!"
112+
exit 1
113+
fi

Changelog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
2.8.41 2026-04-13
44

5+
- ci: enhance Quality Gate to strictly enforce zero-warning policy on GitHub Actions tests.
6+
- ci: implement dynamic CI test environment detection by wrapping configuration extraction.
57
- fix: Restore compatibility with older Perl versions (by @jasongill).
68
- feat: implement idiomatic Perl Boolean practices across the project (#34).
79
- refactor: update CLI metadata to use `undef` as default for string/path options.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ test: vendor_setup
127127

128128
test-all: vendor_setup
129129
@echo "Running all MySQLTuner Lab Tests..."
130-
bash build/test_envs.sh
130+
bash build/test_envs.sh `perl build/get_supported_envs.pl`
131131

132132
test-container:
133133
@echo "Running MySQLTuner against container: $(CONTAINER)..."

build/get_supported_envs.pl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env perl
2+
use strict;
3+
use warnings;
4+
5+
# Parses mysql_support.md and mariadb_support.md to find "Supported" versions
6+
# and outputs them in the format expected by multi-db-docker-env (e.g. mysql84 mariadb1011)
7+
8+
my @configs;
9+
10+
sub parse_support_file {
11+
my ($file, $prefix) = @_;
12+
return unless -f $file;
13+
14+
open my $fh, '<', $file or die "Cannot open $file: $!\n";
15+
while (my $line = <$fh>) {
16+
# Format: | 8.4 | Supported | 2024-04-30 | 2032-04-30 |
17+
if ($line =~ /\|\s*([\d\.]+)\s*\|\s*Supported\s*\|/) {
18+
my $version = $1;
19+
$version =~ s/\.//g; # Remove dots (e.g. 8.4 -> 84, 10.11 -> 1011)
20+
push @configs, "$prefix$version";
21+
}
22+
}
23+
close $fh;
24+
}
25+
26+
parse_support_file("mysql_support.md", "mysql");
27+
parse_support_file("mariadb_support.md", "mariadb");
28+
29+
# Always append percona80 as a default supported engine
30+
push @configs, "percona80";
31+
32+
print join(" ", @configs) . "\n";

mysqltuner.pl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,6 +2347,8 @@ sub mysql_setup {
23472347
$password = <STDIN>;
23482348
system("stty echo >$devnull 2>&1");
23492349
}
2350+
$password = "" unless defined $password;
2351+
$name = "" unless defined $name;
23502352
chomp($password);
23512353
chomp($name);
23522354
$mysqllogin = "$defaults_options -u $name ";
@@ -3849,7 +3851,7 @@ sub system_recommendations {
38493851
}
38503852
else {
38513853
get_fs_info;
3852-
if ( !is_docker() && $opt{'container'} eq '' ) {
3854+
if ( !is_docker() && ($opt{'container'} // '') eq '' ) {
38533855
subheaderprint "Kernel Information Recommendations";
38543856
get_kernel_info;
38553857
}
@@ -4474,8 +4476,10 @@ sub get_replication_status {
44744476

44754477
$result{'Replication'}{'status'} = \%myrepl;
44764478
my ($io_running) = $myrepl{'Replica_IO_Running'};
4479+
$io_running = '' unless defined $io_running;
44774480
debugprint "IO RUNNING: " . ( $io_running // 'undef' ) . " ";
44784481
my ($sql_running) = $myrepl{'Replica_SQL_Running'};
4482+
$sql_running = '' unless defined $sql_running;
44794483
debugprint "SQL RUNNING: " . ( $sql_running // 'undef' ) . " ";
44804484

44814485
my ($seconds_behind_replica) = $myrepl{'Seconds_Behind_Replica'};
@@ -5004,7 +5008,7 @@ sub check_storage_engines {
50045008
sub dump_into_file {
50055009
my $file = shift;
50065010
my $content = shift;
5007-
if ( -d "$opt{dumpdir}" && $opt{dumpdir} ) {
5011+
if ( defined($opt{dumpdir}) && $opt{dumpdir} ne '' && -d $opt{dumpdir} ) {
50085012
$file = "$opt{dumpdir}/$file";
50095013
open( FILE, ">$file" ) or die "Can't open $file: $!";
50105014
print FILE $content;
@@ -8397,8 +8401,8 @@ sub mysql_80_modeling_checks {
83978401
return unless mysql_version_ge( 8, 0 );
83988402

83998403
my $is_mariadb = (
8400-
( $myvar{'version'} =~ /MariaDB/i )
8401-
or ( $myvar{'version_comment'} =~ /MariaDB/i )
8404+
( defined $myvar{'version'} && $myvar{'version'} =~ /MariaDB/i )
8405+
or ( defined $myvar{'version_comment'} && $myvar{'version_comment'} =~ /MariaDB/i )
84028406
);
84038407
my $header =
84048408
$is_mariadb

tests/removed_innodb_vars.t

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use Data::Dumper;
66

77
# 1. Load MySQLTuner logic
88
require './mysqltuner.pl';
9+
require './tests/MySQLTuner/TestHelper.pm';
910

1011
# Mocking essential globals and subroutines
1112
$main::good = '[OK]';
@@ -20,7 +21,8 @@ our @generalrec;
2021
# Test 1: MariaDB 10.6 with removed vars
2122
subtest 'MariaDB 10.6 Removed Variables' => sub {
2223
@main::generalrec = ();
23-
%main::myvar = (
24+
MySQLTuner::TestHelper::reset_state();
25+
%main::myvar = ( %main::myvar,
2426
version => '10.6.15-MariaDB',
2527
version_numbers => '10.6.15',
2628
version_comment => 'mariadb.org binary distribution',
@@ -36,7 +38,8 @@ subtest 'MariaDB 10.6 Removed Variables' => sub {
3638
# Test 2: MySQL 8.0 with removed vars
3739
subtest 'MySQL 8.0 Removed Variables' => sub {
3840
@main::generalrec = ();
39-
%main::myvar = (
41+
MySQLTuner::TestHelper::reset_state();
42+
%main::myvar = ( %main::myvar,
4043
version => '8.0.35',
4144
version_numbers => '8.0.35',
4245
version_comment => 'MySQL Community Server - GPL',
@@ -52,7 +55,8 @@ subtest 'MySQL 8.0 Removed Variables' => sub {
5255
# Test 3: MySQL 9.0 with removed vars
5356
subtest 'MySQL 9.0 Removed Variables' => sub {
5457
@main::generalrec = ();
55-
%main::myvar = (
58+
MySQLTuner::TestHelper::reset_state();
59+
%main::myvar = ( %main::myvar,
5660
version => '9.0.1',
5761
version_numbers => '9.0.1',
5862
version_comment => 'MySQL Community Server - GPL',
@@ -68,7 +72,8 @@ subtest 'MySQL 9.0 Removed Variables' => sub {
6872
# Test 4: MySQL 5.7 (Legacy) - should NOT warn for these vars
6973
subtest 'MySQL 5.7 Legacy Variables' => sub {
7074
@main::generalrec = ();
71-
%main::myvar = (
75+
MySQLTuner::TestHelper::reset_state();
76+
%main::myvar = ( %main::myvar,
7277
version => '5.7.44',
7378
version_numbers => '5.7.44',
7479
version_comment => 'MySQL Community Server - GPL',
@@ -83,21 +88,28 @@ subtest 'MySQL 5.7 Legacy Variables' => sub {
8388
# Test 5: MariaDB 10.3 (Legacy) - should NOT warn for file_format (removed in 10.6)
8489
subtest 'MariaDB 10.3 Legacy Variables' => sub {
8590
@main::generalrec = ();
86-
%main::myvar = (
91+
MySQLTuner::TestHelper::reset_state();
92+
%main::myvar = ( %main::myvar,
93+
version => '10.3.39-MariaDB',
94+
version_numbers => '10.3.39',
95+
version_comment => 'mariadb.org binary distribution',
96+
innodb_file_format => 'Antelope',
97+
);
98+
%main::real_vars = (
8799
version => '10.3.39-MariaDB',
88100
version_numbers => '10.3.39',
89101
version_comment => 'mariadb.org binary distribution',
90102
innodb_file_format => 'Antelope',
91103
);
92-
%main::real_vars = %main::myvar;
93104
main::check_removed_innodb_variables();
94105
is(scalar @main::generalrec, 0, 'MariaDB 10.3: No warnings for innodb_file_format (not removed yet)');
95106
};
96107

97108
# Test 6: Internally injected variables should NOT trigger warnings (Issue #32)
98109
subtest 'Injected Variables (Issue #32)' => sub {
99110
@main::generalrec = ();
100-
%main::myvar = (
111+
MySQLTuner::TestHelper::reset_state();
112+
%main::myvar = ( %main::myvar,
101113
version => '10.11.3-MariaDB',
102114
version_numbers => '10.11.3',
103115
version_comment => 'mariadb.org binary distribution',
@@ -114,13 +126,19 @@ subtest 'Injected Variables (Issue #32)' => sub {
114126
# Test 7: Variables set to 'OFF' should NOT trigger warnings (Issue #32)
115127
subtest 'Variables set to OFF (Issue #32)' => sub {
116128
@main::generalrec = ();
117-
%main::myvar = (
129+
MySQLTuner::TestHelper::reset_state();
130+
%main::myvar = ( %main::myvar,
131+
version => '10.11.3-MariaDB',
132+
version_numbers => '10.11.3',
133+
version_comment => 'mariadb.org binary distribution',
134+
innodb_prefix_index_cluster_optimization => 'OFF',
135+
);
136+
%main::real_vars = (
118137
version => '10.11.3-MariaDB',
119138
version_numbers => '10.11.3',
120139
version_comment => 'mariadb.org binary distribution',
121140
innodb_prefix_index_cluster_optimization => 'OFF',
122141
);
123-
%main::real_vars = %main::myvar;
124142
main::check_removed_innodb_variables();
125143
is(scalar @main::generalrec, 0, "Variables set to 'OFF' do not trigger false warnings");
126144
};

0 commit comments

Comments
 (0)