GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

TorBrowserBuild.pm 5.25 KB
Newer Older
1 2 3 4 5
package TBBTestSuite::TestSuite::TorBrowserBuild;

use strict;
use parent 'TBBTestSuite::TestSuite::RBMBuild';

6
use TBBTestSuite::Common qw(run_to_file);
7
use TBBTestSuite::GitRepo;
8
use File::Copy;
9
use IO::CaptureOutput qw(capture_exec);
10
use Path::Tiny;
11 12 13 14 15 16 17 18 19

sub description {
    'Tor Browser Build';
}

sub type {
    'tor-browser_build';
};

20 21 22 23 24 25 26
sub test_types {
    my $self = shift;
    my $res = $self->SUPER::test_types();
    $res->{make_incrementals} = \&make_incrementals;
    return $res;
}

27 28 29 30 31 32 33 34 35 36
sub set_tests {
    my ($testsuite) = @_;
    $testsuite->{tests} = [
        # Nightly
        {
            name  => 'nightly-linux-x86_64',
            descr => 'build tor-browser nightly linux-x86_64',
            type  => 'rbm_build',
            project => 'release',
            targets => [
37
                'noversiondir',
38 39 40 41 42
                'nightly',
                'torbrowser-linux-x86_64',
            ],
            publish_dir => 'nightly-linux-x86_64',
        },
43 44 45 46 47 48
        {
            name  => 'incrementals-nightly-linux-x86_64',
            descr => 'create incrementals for tor-browser nightly linux-x86_64',
            type  => 'make_incrementals',
            publish_dir => 'nightly-linux-x86_64',
        },
49 50 51 52 53 54
        {
            name  => 'nightly-linux-i686',
            descr => 'build tor-browser nightly linux-i686',
            type  => 'rbm_build',
            project => 'release',
            targets => [
55
                'noversiondir',
56 57 58 59 60
                'nightly',
                'torbrowser-linux-i686',
            ],
            publish_dir => 'nightly-linux-i686',
        },
61 62 63 64 65 66
        {
            name  => 'incrementals-nightly-linux-i686',
            descr => 'create incrementals for tor-browser nightly linux-i686',
            type  => 'make_incrementals',
            publish_dir => 'nightly-linux-i686',
        },
67 68 69 70 71 72
        {
            name  => 'nightly-windows-i686',
            descr => 'build tor-browser nightly windows-i686',
            type  => 'rbm_build',
            project => 'release',
            targets => [
73
                'noversiondir',
74 75 76 77 78
                'nightly',
                'torbrowser-windows-i686',
            ],
            publish_dir => 'nightly-windows-i686',
        },
79 80 81 82 83 84
        {
            name  => 'incrementals-nightly-windows-i686',
            descr => 'create incrementals for tor-browser nightly windows-i686',
            type  => 'make_incrementals',
            publish_dir => 'nightly-windows-i686',
        },
85 86 87 88 89 90 91 92 93 94 95 96
        {
            name  => 'nightly-windows-x86_64',
            descr => 'build tor-browser nightly windows-x86_64',
            type  => 'rbm_build',
            project => 'release',
            targets => [
                'noversiondir',
                'nightly',
                'torbrowser-windows-x86_64',
            ],
            publish_dir => 'nightly-windows-x86_64',
        },
97 98 99 100 101 102
        {
            name  => 'incrementals-nightly-windows-x86_64',
            descr => 'create incrementals for tor-browser nightly windows-x86_64',
            type  => 'make_incrementals',
            publish_dir => 'nightly-windows-x86_64',
        },
103 104 105 106 107 108
        {
            name  => 'nightly-osx-x86_64',
            descr => 'build tor-browser nightly osx-x86_64',
            type  => 'rbm_build',
            project => 'release',
            targets => [
109
                'noversiondir',
110 111 112 113 114
                'nightly',
                'torbrowser-osx-x86_64',
            ],
            publish_dir => 'nightly-osx-x86_64',
        },
115 116 117 118 119 120
        {
            name  => 'incrementals-nightly-osx-x86_64',
            descr => 'create incrementals for tor-browser nightly osx-x86_64',
            type  => 'make_incrementals',
            publish_dir => 'nightly-osx-x86_64',
        },
121 122 123
    ];
}

124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
sub make_incrementals {
    my ($testsuite, $test) = @_;
    $test->{results}{success} = 0;
    mkdir 'nightly' unless -d 'nightly';
    # Clean the nightly directory
    foreach my $subdir (path('nightly')->children) {
        unlink $subdir if -l $subdir;
    }
    foreach my $builddir (path($testsuite->{publish_dir} . '/..')->children) {
        if (-f "$builddir/$test->{publish_dir}/sha256sums-unsigned-build.txt") {
            symlink("$builddir/$test->{publish_dir}", 'nightly/' . $builddir->basename);
        }
    }
    my @cmd = ('make', 'incrementals-nightly');
    run_to_file("$testsuite->{'results-dir'}/$test->{name}.build.txt", @cmd)
        or return;
    $test->{results}{success} = 1;
}

143 144 145 146
sub pre_tests {
    my ($tbbinfos) = @_;
    my $gr = TBBTestSuite::GitRepo->new({
            name => 'tor-browser-build',
147
            git_url => 'https://git.torproject.org/builders/tor-browser-build.git',
148 149
        });
    $gr->clone_fetch;
150
    $gr->cmd('git', 'checkout', 'master');
151
    chdir $gr->clone_dir();
152 153
    copy($tbbinfos->{rbm_local_conf}, $gr->clone_dir() . '/rbm.local.conf')
            if $tbbinfos->{rbm_local_conf};
154 155 156 157 158 159 160 161
    my @clean = ('clean') if $tbbinfos->{make_clean};
    foreach my $cmd (('submodule-update', 'fetch', @clean)) {
        my ($out, $err, $success) = capture_exec('make', $cmd);
        if (!$success) {
            $tbbinfos->{pre_tests_error} = "Error running make $cmd:\n$out\n$err";
            return;
        }
    }
162 163 164
    if ($tbbinfos->{tbb_version}) {
        $ENV{TORBROWSER_NIGHTLY_VERSION} = $tbbinfos->{tbb_version};
    }
165 166 167
}

1;