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
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:
| ... | ... | @@ -12,8 +12,9 @@ my $name = "tor-browser-$date"; |
| 12 | 12 | |
| 13 | 13 | my $builds_dir_root = '/home/tb-builder/nightly-builds';
|
| 14 | 14 | my $reports_dir = "$builds_dir_root/reports";
|
| 15 | +my $publish_url = "https://nightlies.tbb.torproject.org/nightly-builds/tor-browser-builds/$tbb_version";
|
|
| 15 | 16 | |
| 16 | -my $run_rsync = sub {
|
|
| 17 | +sub run_rsync {
|
|
| 17 | 18 | # we fork to run the rsync in the background
|
| 18 | 19 | # we do a double fork to prevent having zombie processes
|
| 19 | 20 | my $pid = fork;
|
| ... | ... | @@ -27,6 +28,30 @@ my $run_rsync = sub { |
| 27 | 28 | exit;
|
| 28 | 29 | };
|
| 29 | 30 | |
| 31 | +my $test_post = sub {
|
|
| 32 | + my ($tbbinfos, $test) = @_;
|
|
| 33 | + run_rsync();
|
|
| 34 | + |
|
| 35 | + return unless $test->{type} eq 'rbm_build';
|
|
| 36 | + return unless $test->{results} && $test->{results}{success};
|
|
| 37 | + return unless $test->{publish_dir};
|
|
| 38 | + |
|
| 39 | + my ($stdout, $stderr, $success) = capture_exec(
|
|
| 40 | + 'python3', "$FindBin::Bin/tools/post-build-trigger.py",
|
|
| 41 | + '--step-name', $test->{name},
|
|
| 42 | + '--publish-url', $publish_url,
|
|
| 43 | + );
|
|
| 44 | + print STDERR $stderr if $stderr;
|
|
| 45 | + if (!$success) {
|
|
| 46 | + $test->{gitlab_pipeline_url} = 'failed run';
|
|
| 47 | + return;
|
|
| 48 | + }
|
|
| 49 | + chomp $stdout;
|
|
| 50 | + $test->{gitlab_pipeline_url} = $stdout && $stdout =~ m{^https?://\S+$}
|
|
| 51 | + ? $stdout
|
|
| 52 | + : 'failed run';
|
|
| 53 | +};
|
|
| 54 | + |
|
| 30 | 55 | if (-d "$reports_dir/r/$name") {
|
| 31 | 56 | print "Doing nothing: $name already done\n";
|
| 32 | 57 | return ( args => [] );
|
| ... | ... | @@ -35,7 +60,7 @@ if (-d "$reports_dir/r/$name") { |
| 35 | 60 | my $testsuite = TBBTestSuite::TestSuite::TorBrowserBuild->new({
|
| 36 | 61 | tbb_version => $tbb_version,
|
| 37 | 62 | publish_dir => "$builds_dir_root/tor-browser-builds/$tbb_version",
|
| 38 | - publish_url => "https://nightlies.tbb.torproject.org/nightly-builds/tor-browser-builds/$tbb_version",
|
|
| 63 | + publish_url => $publish_url,
|
|
| 39 | 64 | rbm_local_conf => "$FindBin::Bin/rbm-config/tb-build-06.torproject.org.rbm.local.conf",
|
| 40 | 65 | });
|
| 41 | 66 | |
| ... | ... | @@ -59,6 +84,6 @@ my %res = ( |
| 59 | 84 | 'pierov@xxxxxxxxxxxxxx',
|
| 60 | 85 | ],
|
| 61 | 86 | 'email-from' => 'Tor Browser Nightly Builds <tb-builder@xxxxxxxxxxxxxxxxxxxxxxxxxx>',
|
| 62 | - 'test_post' => $run_rsync,
|
|
| 87 | + 'test_post' => $test_post,
|
|
| 63 | 88 | );
|
| 64 | 89 | %res; |
| ... | ... | @@ -3,4 +3,7 @@ |
| 3 | 3 | [% IF tbbfiles.$tbbfile.publish_url %]
|
| 4 | 4 | <li><a href="">"[% tbbfiles.$tbbfile.publish_url %]/[% test.publish_dir %]">build files</a></li>
|
| 5 | 5 | [% END %]
|
| 6 | +[% IF test.gitlab_pipeline_url %]
|
|
| 7 | + <li>GitLab test pipeline: <a href="">"[% test.gitlab_pipeline_url %]">[% test.gitlab_pipeline_url %]</a></li>
|
|
| 8 | +[% END %]
|
|
| 6 | 9 | </ul> |
| ... | ... | @@ -8,5 +8,8 @@ Results |
| 8 | 8 | [% FOREACH test IN tbbfiles.$tbbfile.tests -%]
|
| 9 | 9 | [% IF test.results -%]
|
| 10 | 10 | [% test.name %]: [% test.results.success ? 'ok' : 'failed (' _ test.fail_type _ ')' %]
|
| 11 | + [% IF test.type == 'rbm_build' -%]
|
|
| 12 | + GitLab test pipeline: [% test.gitlab_pipeline_url ? test.gitlab_pipeline_url : 'failed run' %]
|
|
| 13 | + [% END -%]
|
|
| 11 | 14 | [% END -%]
|
| 12 | 15 | [% END %] |
| 1 | +#!/usr/bin/env python3
|
|
| 2 | + |
|
| 3 | +from __future__ import annotations
|
|
| 4 | + |
|
| 5 | +import argparse
|
|
| 6 | +import logging
|
|
| 7 | +import sys
|
|
| 8 | + |
|
| 9 | + |
|
| 10 | +logger = logging.getLogger(__name__)
|
|
| 11 | + |
|
| 12 | + |
|
| 13 | +def setup_logging() -> None:
|
|
| 14 | + logging.basicConfig(
|
|
| 15 | + level=logging.INFO,
|
|
| 16 | + format="%(levelname)s: %(message)s",
|
|
| 17 | + # IMPORTANT!
|
|
| 18 | + #
|
|
| 19 | + # Perl captures this script's stdout and, if it is non-empty, stores it
|
|
| 20 | + # as `gitlab_pipeline_url` for the current build step. We need to keep logs
|
|
| 21 | + # on stderr and only print to stdout when its the resulting pipeline URL.
|
|
| 22 | + stream=sys.stderr,
|
|
| 23 | + )
|
|
| 24 | + |
|
| 25 | + |
|
| 26 | +def parse_args() -> argparse.Namespace:
|
|
| 27 | + parser = argparse.ArgumentParser(
|
|
| 28 | + description="Post-build trigger hook for triggering GitLab CI pipelines."
|
|
| 29 | + )
|
|
| 30 | + parser.add_argument(
|
|
| 31 | + "--step-name",
|
|
| 32 | + required=True,
|
|
| 33 | + help="""
|
|
| 34 | + Name of the build step that just finished.
|
|
| 35 | + List of possible values can be found in
|
|
| 36 | + TBBTestSuite/TestSuite/TorBrowserBuild.pm (set_tests)
|
|
| 37 | + """,
|
|
| 38 | + )
|
|
| 39 | + parser.add_argument(
|
|
| 40 | + "--publish-url",
|
|
| 41 | + required=True,
|
|
| 42 | + help="URL where build artifacts are published for the build artifacts.",
|
|
| 43 | + )
|
|
| 44 | + return parser.parse_args()
|
|
| 45 | + |
|
| 46 | + |
|
| 47 | +def main() -> int:
|
|
| 48 | + setup_logging()
|
|
| 49 | + args = parse_args()
|
|
| 50 | + logger.info(
|
|
| 51 | + f"post-build-trigger.py not implemented yet "
|
|
| 52 | + f"(step={args.step_name}, publish_url={args.publish_url})"
|
|
| 53 | + )
|
|
| 54 | + return 0
|
|
| 55 | + |
|
| 56 | + |
|
| 57 | +if __name__ == "__main__":
|
|
| 58 | + raise SystemExit(main()) |