brizental pushed to branch main at The Tor Project / Applications / tor-browser-bundle-testsuite Commits: d5afb7c3 by Beatriz Rizental at 2026-04-14T14:37:44-03:00 Bug 40091: Execute test pipeline trigger after each build This commit doesn't implement the actual triggering logic, just the Perl side where the trigger script is run. - - - - - 4 changed files: - config/tb-build-06.torproject.org - tmpl/details_rbm_build.html - tmpl/report_tor-browser_build.txt - + tools/post-build-trigger.py Changes: ===================================== config/tb-build-06.torproject.org ===================================== @@ -12,8 +12,9 @@ my $name = "tor-browser-$date"; my $builds_dir_root = '/home/tb-builder/nightly-builds'; my $reports_dir = "$builds_dir_root/reports"; +my $publish_url = "https://nightlies.tbb.torproject.org/nightly-builds/tor-browser-builds/$tbb_..."; -my $run_rsync = sub { +sub run_rsync { # we fork to run the rsync in the background # we do a double fork to prevent having zombie processes my $pid = fork; @@ -27,6 +28,30 @@ my $run_rsync = sub { exit; }; +my $test_post = sub { + my ($tbbinfos, $test) = @_; + run_rsync(); + + return unless $test->{type} eq 'rbm_build'; + return unless $test->{results} && $test->{results}{success}; + return unless $test->{publish_dir}; + + my ($stdout, $stderr, $success) = capture_exec( + 'python3', "$FindBin::Bin/tools/post-build-trigger.py", + '--step-name', $test->{name}, + '--publish-url', $publish_url, + ); + print STDERR $stderr if $stderr; + if (!$success) { + $test->{gitlab_pipeline_url} = 'failed run'; + return; + } + chomp $stdout; + $test->{gitlab_pipeline_url} = $stdout && $stdout =~ m{^https?://\S+$} + ? $stdout + : 'failed run'; +}; + if (-d "$reports_dir/r/$name") { print "Doing nothing: $name already done\n"; return ( args => [] ); @@ -35,7 +60,7 @@ if (-d "$reports_dir/r/$name") { my $testsuite = TBBTestSuite::TestSuite::TorBrowserBuild->new({ tbb_version => $tbb_version, publish_dir => "$builds_dir_root/tor-browser-builds/$tbb_version", - publish_url => "https://nightlies.tbb.torproject.org/nightly-builds/tor-browser-builds/$tbb_...", + publish_url => $publish_url, rbm_local_conf => "$FindBin::Bin/rbm-config/tb-build-06.torproject.org.rbm.local.conf", }); @@ -59,6 +84,6 @@ my %res = ( 'pierov@torproject.org', ], 'email-from' => 'Tor Browser Nightly Builds <tb-builder@tb-build-06.torproject.org>', - 'test_post' => $run_rsync, + 'test_post' => $test_post, ); %res; ===================================== tmpl/details_rbm_build.html ===================================== @@ -3,4 +3,7 @@ [% IF tbbfiles.$tbbfile.publish_url %] <li><a href="[% tbbfiles.$tbbfile.publish_url %]/[% test.publish_dir %]">build files</a></li> [% END %] +[% IF test.gitlab_pipeline_url %] + <li>GitLab test pipeline: <a href="[% test.gitlab_pipeline_url %]">[% test.gitlab_pipeline_url %]</a></li> +[% END %] </ul> ===================================== tmpl/report_tor-browser_build.txt ===================================== @@ -8,5 +8,8 @@ Results [% FOREACH test IN tbbfiles.$tbbfile.tests -%] [% IF test.results -%] [% test.name %]: [% test.results.success ? 'ok' : 'failed (' _ test.fail_type _ ')' %] + [% IF test.type == 'rbm_build' -%] + GitLab test pipeline: [% test.gitlab_pipeline_url ? test.gitlab_pipeline_url : 'failed run' %] + [% END -%] [% END -%] [% END %] ===================================== tools/post-build-trigger.py ===================================== @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 + +from __future__ import annotations + +import argparse +import logging +import sys + + +logger = logging.getLogger(__name__) + + +def setup_logging() -> None: + logging.basicConfig( + level=logging.INFO, + format="%(levelname)s: %(message)s", + # IMPORTANT! + # + # Perl captures this script's stdout and, if it is non-empty, stores it + # as `gitlab_pipeline_url` for the current build step. We need to keep logs + # on stderr and only print to stdout when its the resulting pipeline URL. + stream=sys.stderr, + ) + + +def parse_args() -> argparse.Namespace: + parser = argparse.ArgumentParser( + description="Post-build trigger hook for triggering GitLab CI pipelines." + ) + parser.add_argument( + "--step-name", + required=True, + help=""" + Name of the build step that just finished. + List of possible values can be found in + TBBTestSuite/TestSuite/TorBrowserBuild.pm (set_tests) + """, + ) + parser.add_argument( + "--publish-url", + required=True, + help="URL where build artifacts are published for the build artifacts.", + ) + return parser.parse_args() + + +def main() -> int: + setup_logging() + args = parse_args() + logger.info( + f"post-build-trigger.py not implemented yet " + f"(step={args.step_name}, publish_url={args.publish_url})" + ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-bundle-testsuite/... -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-bundle-testsuite/... You're receiving this email because of your account on gitlab.torproject.org. Manage all notifications: https://gitlab.torproject.org/-/profile/notifications | Help: https://gitlab.torproject.org/help
participants (1)
-
brizental (@brizental)