Skip to content

Commit 99729c5

Browse files
allow only linux, perldoc 80 chars and send_result activate
1 parent 55b6539 commit 99729c5

1 file changed

Lines changed: 67 additions & 40 deletions

File tree

PGBuild/Modules/ABICompCheck.pm

Lines changed: 67 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ See accompanying License file for license details
99
1010
=head1 PGBuild::Modules::ABICompCheck
1111
12-
This module is used for ABI compliance checking of PostgreSQL builds
13-
by comparing the latest commit on a stable branch with the most recent
14-
tag on that branch. This helps detect unintended changes that could
15-
break compatibility for extensions or client applications.
12+
This module is used for ABI compliance checking of PostgreSQL builds by
13+
comparing the latest commit on a stable branch with the most recent tag on that
14+
branch. This helps detect unintended changes that could break compatibility for
15+
extensions or client applications.
1616
1717
=head2 EXECUTION FLOW
1818
@@ -22,58 +22,75 @@ The module follows these steps to perform an ABI comparison:
2222
2323
=item 1.
2424
25-
The build farm completes its standard build and installation of PostgreSQL for the latest commit on a given stable branch.
25+
The build farm completes its standard build and installation of PostgreSQL for
26+
the latest commit on a given stable branch.
2627
2728
=item 2.
2829
2930
The C<install> hook of the ABICompCheck module is triggered.
3031
3132
=item 3.
3233
33-
The module identifies the most recent tag for a particular branch (e.g., REL_16_1) to use as a baseline for comparison against the most recent commit of the branch.
34+
The module identifies the most recent tag for a particular branch (e.g.,
35+
REL_16_1) to use as a baseline for comparison against the most recent commit of
36+
the branch.
3437
3538
=item 4.
3639
37-
It checks if a pre-existing, complete build and ABI dump for this baseline tag exists in its working directory (C<buildroot/abicheck.$animal_name>).
40+
It checks if a pre-existing, complete build and ABI dump for this baseline tag
41+
exists in its working directory (C<buildroot/abicheck.$animal_name>).
3842
3943
=item 5.
4044
41-
If the baseline tag's build is missing or incomplete, the module performs a fresh build of that tag:
45+
If the baseline tag's build is missing or incomplete, the module performs a
46+
fresh build of that tag:
4247
- It checks out the source code for the tag.
43-
- It runs C<configure>, C<make>, and C<make install> for the tag in an isolated directory.
44-
- It uses C<abidw> to generate XML representations of the ABI for key binaries (like C<postgres>, C<libpq.so>, C<ecpg> - These are the default binaries and can be customised by animal owners) from this tag build. These are stored for future runs.
48+
- It runs C<configure>, C<make>, and C<make install> for the tag in an
49+
isolated directory.
50+
- It uses C<abidw> to generate XML representations of the ABI for key
51+
binaries (like C<postgres>, C<libpq.so>, C<ecpg> - These are the
52+
default binaries and can be customised by animal owners) from this tag
53+
build. These are stored for future runs.
4554
4655
=item 6.
4756
48-
The module then generates ABI XML files for the same set of key binaries from the main build (the latest commit).
57+
The module then generates ABI XML files for the same set of key binaries from
58+
the main build (the latest commit).
4959
5060
=item 7.
5161
52-
Using C<abidiff>, it compares the ABI XML file of each binary from the latest commit against the corresponding file from the baseline tag.
62+
Using C<abidiff>, it compares the ABI XML file of each binary from the latest
63+
commit against the corresponding file from the baseline tag.
5364
5465
=item 8.
5566
56-
Any differences detected by C<abidiff> are collected into a log report. If no differences are found, a success message is logged.
67+
Any differences detected by C<abidiff> are collected into a log report. If no
68+
differences are found, a success message is logged.
5769
5870
=item 9.
5971
60-
The final report, containing either the ABI differences or "no abi diffs found in this run", is sent to the build farm server as part of the overall build status.
72+
The final report, containing either the ABI differences or "no abi diffs found
73+
in this run", is sent to the build farm server as part of the overall build
74+
status.
6175
6276
=back
6377
6478
=head2 CONFIGURATION OPTIONS
6579
66-
The module supports the following configuration options under `abi_comp_check` key in build-farm.conf:
80+
The module supports the following configuration options under `abi_comp_check`
81+
key in build-farm.conf:
6782
6883
=over 4
6984
7085
=item B<abi_compare_root>
7186
72-
Specifies the root directory for ABI comparison data. If not set, defaults to C<buildroot/abicheck.$animal_name>.
87+
Specifies the root directory for ABI comparison data. If not set, defaults to
88+
C<buildroot/abicheck.$animal_name>.
7389
7490
=item B<binaries_rel_path>
7591
76-
A hash reference mapping binary names to their relative paths for ABI comparison. Defaults to:
92+
A hash reference mapping binary names to their relative paths for ABI
93+
comparison. Defaults to:
7794
7895
{
7996
'postgres' => 'bin/postgres',
@@ -92,7 +109,8 @@ An array reference containing flags to pass to C<abidw>. Defaults to:
92109
93110
=item B<tag_for_branch>
94111
95-
A hash reference mapping branch names to their corresponding tags for ABI comparison. Defaults to empty hash which means latest tags for all branches:
112+
A hash reference mapping branch names to their corresponding tags for ABI
113+
comparison. Defaults to empty hash which means latest tags for all branches:
96114
97115
{}
98116
@@ -104,19 +122,23 @@ A hash reference mapping branch names to their corresponding tags for ABI compar
104122
105123
=item *
106124
107-
This module have msvc related duped from run_build.pl script but later I realised C<abidiff> supports only elf binaries. Maybe those functions can be used in future if some other ABI Compliance checking tool supports them.
125+
This module have msvc related duped from run_build.pl script but later I
126+
realised C<abidiff> supports only elf binaries. Maybe those functions can be
127+
used in future if some other ABI Compliance checking tool supports them.
108128
109129
=item *
110130
111-
This module only works for stable branches in compliance with the PostgreSQL ABI policy for minor releases.
131+
This module only works for stable branches in compliance with the PostgreSQL
132+
ABI policy for minor releases.
112133
113134
=item *
114135
115136
Debug information is required for build to be able to use this module
116137
117138
=item *
118139
119-
Before using this module, ensure that you have the build-essential, abigail-tools, git installed for your animal.
140+
Before using this module, ensure that you have the build-essential,
141+
abigail-tools, git installed for your animal.
120142
121143
=back
122144
@@ -139,7 +161,7 @@ package PGBuild::Modules::ABICompCheck;
139161
use PGBuild::Log;
140162
use PGBuild::Options;
141163
use PGBuild::SCM;
142-
use PGBuild::Utils qw(:DEFAULT $branch_root);
164+
use PGBuild::Utils qw(:DEFAULT $branch_root $steps_completed);
143165

144166
use strict;
145167
use warnings;
@@ -160,7 +182,7 @@ sub emit {
160182

161183
my $hooks = {
162184
# 'need-run' => \&need_run,
163-
'install' => \&install, # Main ABI comparison logic runs after install
185+
'installcheck' => \&installcheck, # Main ABI comparison logic runs after install
164186
'cleanup' => \&cleanup, # Clean up temporary files after build
165187
};
166188

@@ -173,6 +195,12 @@ sub setup
173195
my $conf = shift; # ref to the whole config object
174196
my $pgsql = shift; # postgres build dir
175197

198+
if ($^O ne 'linux')
199+
{
200+
emit("Only Linux is supported for ABICompCheck Module, skipping.");
201+
return;
202+
}
203+
176204
# Only proceed if this is a stable branch with git SCM, not using msvc
177205
if ($conf->{scm} ne 'git')
178206
{
@@ -184,11 +212,6 @@ sub setup
184212
emit("Skipping ABI check, '$branch' is not a stable branch.");
185213
return;
186214
}
187-
if ($conf->{using_msvc})
188-
{
189-
emit("MSVC builds are not supported for ABICompCheck Module, skipping.");
190-
return;
191-
}
192215

193216
# Ensure debug information is available in compilation - required for libabigail tools
194217
if ($conf->{using_meson})
@@ -272,19 +295,19 @@ sub setup
272295
}
273296

274297
# Main function - runs after PostgreSQL installation to perform ABI comparison
275-
sub install
298+
sub installcheck
276299
{
277300
my $self = shift;
278301
return unless step_wanted('abi_comp-check');
279302

280-
emit "install";
303+
emit "installcheck";
281304
my $scm = PGBuild::SCM->new($self->{bfconf});
282305

283306
my $pgbranch = $self->{pgbranch};
284307
my $abi_compare_loc = "$self->{abi_compare_root}/$pgbranch";
285308
mkdir $abi_compare_loc unless -d $abi_compare_loc;
286309
my $tag_for_branch = $self->{tag_for_branch} || {};
287-
my $latest_tag;
310+
my $baseline_tag;
288311

289312
# find the tag to compare with for the branch
290313
if (exists $tag_for_branch->{$pgbranch})
@@ -298,23 +321,23 @@ sub install
298321
return;
299322
}
300323
# use the first tag from the list in case of regex
301-
emit "Using $tags[0] as the latest tag for branch $pgbranch based on pattern '$tag_pattern'";
302-
$latest_tag = $tags[0];
324+
emit "Using $tags[0] as the baseline tag for branch $pgbranch based on pattern '$tag_pattern'";
325+
$baseline_tag = $tags[0];
303326
}else{
304327
emit "Finding latest tag for branch $pgbranch";
305-
$latest_tag = run_log(qq{git -C ./pgsql describe --tags --abbrev=0 2>/dev/null}); # Find the latest tag
328+
$baseline_tag = run_log(qq{git -C ./pgsql describe --tags --abbrev=0 2>/dev/null}); # Find the latest tag
306329
}
307-
chomp $latest_tag;
330+
chomp $baseline_tag;
308331
my $comparison_ref = '';
309332
$comparison_ref = run_log(qq{git -C ./pgsql merge-base master bf_$pgbranch}); # Find the very first commit for current branch
310333
die "git merge-base failed: $?" if $?;
311334
chomp $comparison_ref;
312335

313-
if ($latest_tag) {
336+
if ($baseline_tag) {
314337
# if some latest tag is found, then get the commit SHA for the latest tagged commit
315338
# and compare with the first commit for current branch
316339
# using `git merge-base --is-ancestor A B` to
317-
my $tag_commit = run_log(qq{git -C ./pgsql rev-list -n 1 $latest_tag});
340+
my $tag_commit = run_log(qq{git -C ./pgsql rev-list -n 1 $baseline_tag});
318341
die "git rev-list failed: $?" if $?;
319342
chomp $tag_commit;
320343

@@ -323,8 +346,8 @@ sub install
323346
# If the latest tag is not an ancestor of the first branch commit
324347
# we need to use the latest tag as the comparison reference
325348
# else we use the first commit of the branch instead of tag
326-
$comparison_ref = $latest_tag;
327-
emit "Latest tag: $latest_tag";
349+
$comparison_ref = $baseline_tag;
350+
emit "Baseline tag: $baseline_tag";
328351
}
329352
}
330353

@@ -429,15 +452,16 @@ sub install
429452
my ($diff_found, $diff_log) = $self->_compare_and_log_abi_diff($comparison_ref, $pgbranch);
430453

431454
# Add comparison results to output
455+
my $status=0;
432456
if ($diff_found)
433457
{
434458
push(@saveout, $diff_log->log_string);
459+
$status=1;
435460
}
436461
else
437462
{
438463
push(@saveout, "no abi diffs found in this run\n");
439464
}
440-
441465
# Include tag build logs if we rebuilt
442466
if ($rebuild_tag)
443467
{
@@ -457,6 +481,9 @@ sub install
457481
# Write final report to build farm logs
458482
writelog("abi-compliance-check", \@saveout);
459483

484+
send_result('ABICompCheck', $status, \@saveout) if $status;
485+
$steps_completed .= " ABICompCheck";
486+
460487
return;
461488
}
462489

0 commit comments

Comments
 (0)