Commit 16e629f6 authored by Georg Koppen's avatar Georg Koppen
Browse files

Merge remote-tracking branch 'boklm/bug_25101_v12'

parents b61a0497 608fbb6f
......@@ -2,10 +2,10 @@
nightly_build_user: tbb-nightly
nightly_build_cron_hour: 2
nightly_build_cron_minute: 20
nightly_build_keep_builds: 2
nightly_build_keep_builds: 3
testsuite_dir: "/home/{{ nightly_build_user }}/tbb-testsuite"
testsuite_git_url: https://git.torproject.org/tor-browser-bundle-testsuite.git
testsuite_git_commit: d5e23151bf4ff48146c0c33355fe70def5e4d3f2
testsuite_git_commit: ea0942f9da2bdbaf3f140f3baaed1bb56ee9af69
nightly_build_wwwdir: "/home/{{ nightly_build_user }}/www"
nightly_build_nginx_enable: true
nightly_build_nginx_listen: 127.0.0.1:80
#!/usr/bin/perl -w
# Copyright (c) 2019, The Tor Project, Inc.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
#
# * Neither the names of the copyright owners nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# 'prune-old-builds' is a script to prune old builds.
#
#
# Usage:
# $ ./prune-old-builds [options] <directory>
#
#
# Available options:
#
# --dry-run
# Don't delete anything, but say what would be deleted.
#
# --prefix <prefix>
# Prefix of the directories to be removed. Default is 'tbb-nightly.'.
#
# --separator <c>
# Separator character to separate the year, month, day in the directory
# names. Default is '.'.
#
# --days <n>
# Number of days that we should keep. Default is 6.
#
# --weeks <n>
# Number of monday builds that we should keep. Default is 3.
#
# --months <n>
# Number of 1st day of the month builds that we should keep.
# Default is 3.
use strict;
use Getopt::Long;
use DateTime;
use DateTime::Duration;
use File::Path qw(remove_tree);
my %options = (
days => 6,
weeks => 3,
months => 3,
prefix => 'tbb-nightly.',
separator => '.',
);
sub keep_builds {
my %res;
my $day = DateTime::Duration->new(days => 1);
my $week = DateTime::Duration->new(weeks => 1);
my $month = DateTime::Duration->new(months => 1);
my $n = $options{days};
my $dt = DateTime->now;
while ($n) {
$res{ $options{prefix} . $dt->ymd($options{separator}) } = 1;
$dt = $dt - $day;
$n--;
}
my $w = $options{weeks};
while ($dt->day_of_week != 1) {
$dt = $dt - $day;
}
while ($w) {
$res{ $options{prefix} . $dt->ymd($options{separator}) } = 1;
$dt = $dt - $week;
$w--;
}
my $m = $options{months};
$dt = DateTime->now;
while ($dt->day != 1) {
$dt = $dt - $day;
}
while ($m) {
$res{ $options{prefix} . $dt->ymd($options{separator}) } = 1;
$dt = $dt - $month;
$m--;
}
return \%res;
}
sub clean_directory {
my ($directory) = @_;
my $k = keep_builds;
chdir $directory || die "Error entering $directory";
foreach my $file (glob "$options{prefix}*") {
next unless $file =~ m/^$options{prefix}\d{4}$options{separator}\d{2}$options{separator}\d{2}$/;
next if $k->{$file};
if ($options{'dry-run'}) {
print "Would remove $file\n";
} else {
remove_tree($file);
}
}
}
my @opts = qw(days=i weeks=i months=i prefix=s dry-run!);
Getopt::Long::GetOptions(\%options, @opts);
die "Missing argument: directory to clean" unless @ARGV;
foreach my $dir (@ARGV) {
clean_directory($dir);
}
......@@ -39,6 +39,13 @@
mode: 0644
owner: "{{ nightly_build_user }}"
- name: prune-old-builds
copy:
src: prune-old-builds
dest: "/home/{{ nightly_build_user }}/prune-old-builds"
mode: 0755
owner: "{{ nightly_build_user }}"
- name: add start-tbb-nightly script
template:
src: start-tbb-nightly
......
......@@ -2,4 +2,4 @@
cd {{ testsuite_dir }}
export RBM_NO_DEBUG=1
./tbb-testsuite --config=tbb-nightly "$@"
./tools/prune-old-builds/prune-old-builds --prefix '' --days {{ nightly_build_keep_builds }} ./tor-browser-builds
/home/{{ nightly_build_user }}/prune-old-builds --days {{ nightly_build_keep_builds }} ./tor-browser-builds
......@@ -5,6 +5,7 @@ use DateTime;
use TBBTestSuite::TestSuite::TorBrowserBuild;
my $date = DateTime->now->ymd;
my $tbb_version = 'tbb-nightly.' . DateTime->now->ymd('.');
my $name = "tor-browser-$date";
if (-d "$options->{'reports-dir'}/r/$name") {
......@@ -13,8 +14,9 @@ if (-d "$options->{'reports-dir'}/r/$name") {
}
my $testsuite = TBBTestSuite::TestSuite::TorBrowserBuild->new({
publish_dir => "$FindBin::Bin/tor-browser-builds/$date",
publish_url => "{{ nightly_build_url }}/tor-browser-builds/$date",
tbb_version => $tbb_version,
publish_dir => "$FindBin::Bin/tor-browser-builds/$tbb_version",
publish_url => "{{ nightly_build_url }}/tor-browser-builds/$tbb_version",
rbm_local_conf => "$FindBin::Bin/rbm-config/tbb-nightly.rbm.local.conf",
make_clean => 1,
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment