Merge pull request #1003 from DeterminateSystems/perlcritic-level-4

perlcritic: level 4
This commit is contained in:
Eelco Dolstra 2021-09-27 20:23:55 +02:00 committed by GitHub
commit 2745226ada
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
98 changed files with 163 additions and 60 deletions

View file

@ -1,4 +1,4 @@
theme = community
# 5 is the least complainy, 1 is the most complainy
severity = 5
severity = 4

View file

@ -454,14 +454,14 @@
DigestSHA1
EmailMIME
EmailSender
FileSlurp
FileSlurper
FileWhich
final.nix.perl-bindings
git
IOCompress
IPCRun
JSON
JSONAny
JSONMaybeXS
JSONXS
LWP
LWPProtocolHttps

View file

@ -1,5 +1,7 @@
# IMPORTANT: if you delete this file your app will not work as
# expected. you have been warned
use strict;
use warnings;
use inc::Module::Install;
name 'Hydra';

View file

@ -1,5 +1,8 @@
package Hydra::Config;
use strict;
use warnings;
our %configGeneralOpts = (-UseApacheInclude => 1, -IncludeAgain => 1, -IncludeRelative => 1);
1;

View file

@ -8,11 +8,10 @@ use Hydra::Helper::Nix;
use Hydra::Helper::CatalystUtils;
use Hydra::Controller::Project;
use JSON;
use JSON::Any;
use JSON::MaybeXS;
use DateTime;
use Digest::SHA qw(sha256_hex);
use Text::Diff;
use File::Slurp;
use IPC::Run qw(run);
@ -67,7 +66,7 @@ sub latestbuilds : Chained('api') PathPart('latestbuilds') Args(0) {
push @list, buildToHash($_) foreach @latest;
$c->stash->{'plain'} = {
data => scalar (JSON::Any->objToJson(\@list))
data => scalar (encode_json(\@list))
};
$c->forward('Hydra::View::Plain');
}
@ -108,7 +107,7 @@ sub jobsets : Chained('api') PathPart('jobsets') Args(0) {
push @list, jobsetToHash($_) foreach @jobsets;
$c->stash->{'plain'} = {
data => scalar (JSON::Any->objToJson(\@list))
data => scalar (encode_json(\@list))
};
$c->forward('Hydra::View::Plain');
}
@ -126,7 +125,7 @@ sub queue : Chained('api') PathPart('queue') Args(0) {
push @list, buildToHash($_) foreach @builds;
$c->stash->{'plain'} = {
data => scalar (JSON::Any->objToJson(\@list))
data => scalar (encode_json(\@list))
};
$c->forward('Hydra::View::Plain');
}
@ -170,7 +169,7 @@ sub nrbuilds : Chained('api') PathPart('nrbuilds') Args(0) {
@arr = reverse(@arr);
$c->stash->{'plain'} = {
data => scalar (JSON::Any->objToJson(\@arr))
data => scalar (encode_json(\@arr))
};
$c->forward('Hydra::View::Plain');
}

View file

@ -8,7 +8,6 @@ use Hydra::Helper::Nix;
use Hydra::Helper::CatalystUtils;
use File::Basename;
use File::stat;
use File::Slurp;
use Data::Dump qw(dump);
use Nix::Store;
use Nix::Config;

View file

@ -6,6 +6,7 @@ use warnings;
use base 'Hydra::Base::Controller::ListBuilds';
use Hydra::Helper::Nix;
use Hydra::Helper::CatalystUtils;
use JSON::MaybeXS;
use Net::Prometheus;
sub job : Chained('/') PathPart('job') CaptureArgs(3) {
@ -50,7 +51,7 @@ sub shield :Chained('job') PathPart('shield') Args(0) {
$c->response->content_type('application/json');
$c->stash->{'plain'} = {
data => scalar (JSON::Any->objToJson(
data => scalar (encode_json(
{
schemaVersion => 1,
label => "hydra build",

View file

@ -4,7 +4,7 @@ use utf8;
use strict;
use warnings;
use base 'Hydra::Base::Controller::REST';
use File::Slurp;
use File::Slurper qw(read_text);
use Crypt::RandPasswd;
use Digest::SHA1 qw(sha1_hex);
use Hydra::Helper::Nix;
@ -165,7 +165,7 @@ sub github_login :Path('/github-login') Args(0) {
my $client_id = $c->config->{github_client_id} or die "github_client_id not configured.";
my $client_secret = $c->config->{github_client_secret} // do {
my $client_secret_file = $c->config->{github_client_secret_file} or die "github_client_secret nor github_client_secret_file is configured.";
my $client_secret = read_file($client_secret_file);
my $client_secret = read_text($client_secret_file);
$client_secret =~ s/\s+//;
$client_secret;
};

View file

@ -1,6 +1,7 @@
package Hydra::Event;
use strict;
use warnings;
use Hydra::Event::BuildFinished;
use Hydra::Event::BuildStarted;
use Hydra::Event::StepFinished;

View file

@ -1,6 +1,7 @@
package Hydra::Helper::AddBuilds;
use strict;
use warnings;
use utf8;
use Encode;
use JSON;
@ -14,7 +15,6 @@ use File::stat;
use File::Path;
use File::Temp;
use File::Spec;
use File::Slurp;
use Hydra::Helper::CatalystUtils;
our @ISA = qw(Exporter);

View file

@ -2,6 +2,7 @@ package Hydra::Helper::CatalystUtils;
use utf8;
use strict;
use warnings;
use Exporter;
use Readonly;
use Nix::Store;

View file

@ -1,10 +1,10 @@
package Hydra::Helper::Email;
use strict;
use warnings;
use Email::MIME;
use Email::Sender::Simple qw(sendmail);
use Exporter 'import';
use File::Slurp;
use Hydra::Helper::Nix;
use Sys::Hostname::Long;

View file

@ -1,6 +1,7 @@
package Hydra::Helper::Escape;
use strict;
use warnings;
use base qw(Exporter);
use Hydra::Helper::AttributeSet;

View file

@ -1,6 +1,7 @@
package Hydra::Helper::Nix;
use strict;
use warnings;
use Exporter;
use File::Path;
use File::Basename;
@ -65,8 +66,8 @@ sub getStatsdConfig {
my %statsd = defined $cfg ? ref $cfg eq "HASH" ? %$cfg : ($cfg) : ();
return {
"host" => %statsd{'host'} // 'localhost',
"port" => %statsd{'port'} // 8125,
"host" => $statsd{'host'} // 'localhost',
"port" => $statsd{'port'} // 8125,
}
}
@ -83,20 +84,20 @@ sub getHydraNotifyPrometheusConfig {
return undef;
}
my $cfg = $cfg->{prometheus};
if (!defined($cfg)) {
my $promcfg = $cfg->{prometheus};
if (!defined($promcfg)) {
return undef;
}
if (ref $cfg ne "HASH") {
if (ref $promcfg ne "HASH") {
print STDERR "Error reading Hydra's configuration file: hydra_notify.prometheus should be a block.\n";
return undef;
}
if (defined($cfg->{"listen_address"}) && defined($cfg->{"port"})) {
if (defined($promcfg->{"listen_address"}) && defined($promcfg->{"port"})) {
return {
"listen_address" => $cfg->{'listen_address'},
"port" => $cfg->{'port'},
"listen_address" => $promcfg->{'listen_address'},
"port" => $promcfg->{'port'},
};
} else {
print STDERR "Error reading Hydra's configuration file: hydra_notify.prometheus should include listen_address and port.\n";
@ -140,8 +141,8 @@ sub registerRoot {
my ($path) = @_;
my $link = gcRootFor $path;
return if -e $link;
open ROOT, ">$link" or die "cannot create GC root `$link' to `$path'";
close ROOT;
open my $root, ">$link" or die "cannot create GC root `$link' to `$path'";
close $root;
}
@ -305,7 +306,8 @@ sub getEvals {
{ order_by => "id DESC", rows => 1 });
my $curInfo = getEvalInfo($cache, $curEval);
my $prevInfo = getEvalInfo($cache, $prevEval) if defined $prevEval;
my $prevInfo;
$prevInfo = getEvalInfo($cache, $prevEval) if defined $prevEval;
# Compute what inputs changed between each eval.
my @changedInputs;
@ -340,12 +342,12 @@ sub getMachines {
for my $machinesFile (@machinesFiles) {
next unless -e $machinesFile;
open CONF, "<$machinesFile" or die;
while (<CONF>) {
open my $conf, "<$machinesFile" or die;
while (my $line = <$conf>) {
chomp;
s/\#.*$//g;
next if /^\s*$/;
my @tokens = split /\s/, $_;
my @tokens = split /\s/, $line;
my @supportedFeatures = split(/,/, $tokens[5] || "");
my @mandatoryFeatures = split(/,/, $tokens[6] || "");
$machines{$tokens[0]} =
@ -357,7 +359,7 @@ sub getMachines {
, mandatoryFeatures => [ @mandatoryFeatures ]
};
}
close CONF;
close $conf;
}
return \%machines;

View file

@ -1,6 +1,7 @@
package Hydra::Model::DB;
use strict;
use warnings;
use base 'Catalyst::Model::DBIC::Schema';
sub getHydraPath {

View file

@ -1,6 +1,7 @@
package Hydra::Plugin;
use strict;
use warnings;
use Module::Pluggable
search_path => "Hydra::Plugin",
instantiate => 'new';

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::BazaarInput;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use Digest::SHA qw(sha256_hex);
use File::Path;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::BitBucketPulls;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use HTTP::Request;
use LWP::UserAgent;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::BitBucketStatus;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use HTTP::Request;
use JSON;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::CircleCINotification;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use HTTP::Request;
use LWP::UserAgent;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::CompressLog;
use strict;
use warnings;
use utf8;
use parent 'Hydra::Plugin';
use Hydra::Helper::CatalystUtils;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::CoverityScan;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use File::Basename;
use LWP::UserAgent;
@ -51,12 +52,12 @@ sub buildFinished {
my $tarballs = "$storePath/tarballs";
my $covTarball;
opendir TARBALLS, $tarballs or die;
while (readdir TARBALLS) {
next unless $_ =~ /.*-coverity-int\.(tgz|lzma|xz|bz2|zip)$/;
$covTarball = "$tarballs/$_"; last;
opendir my $tarballs_handle, $tarballs or die;
while (my $file = readdir $tarballshandle) {
next unless $file =~ /.*-coverity-int\.(tgz|lzma|xz|bz2|zip)$/;
$covTarball = "$tarballs/$file"; last;
}
closedir TARBALLS;
closedir $tarballs_handle;
unless (defined $covTarball) {
print STDERR "CoverityScan.pm: Coverity tarball not found in $tarballs; skipping upload...\n";
@ -81,7 +82,8 @@ sub buildFinished {
my $versionRE = "(?:[A-Za-z0-9\.\-]+)";
my $shortName = basename($covTarball);
my $version = $2 if $shortName =~ /^($pkgNameRE)-($versionRE)-coverity-int.*$/;
my $version;
$version = $2 if $shortName =~ /^($pkgNameRE)-($versionRE)-coverity-int.*$/;
die "CoverityScan.pm: Couldn't parse build version for upload! ($shortName)"
unless defined $version;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::DarcsInput;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use Digest::SHA qw(sha256_hex);
use File::Path;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::DeclarativeJobsets;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use Hydra::Helper::AddBuilds;

View file

@ -2,6 +2,7 @@ package Hydra::Plugin::EmailNotification;
use utf8;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use POSIX qw(strftime);
use Template;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::GitInput;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use Digest::SHA qw(sha256_hex);
use File::Path;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::GiteaStatus;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use HTTP::Request;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::GithubPulls;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use HTTP::Request;
use LWP::UserAgent;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::GithubRefs;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use HTTP::Request;
use LWP::UserAgent;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::GithubStatus;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use HTTP::Request;
use JSON;

View file

@ -15,6 +15,7 @@
package Hydra::Plugin::GitlabPulls;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use HTTP::Request;
use LWP::UserAgent;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::GitlabStatus;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use HTTP::Request;
use JSON;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::HipChatNotification;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use LWP::UserAgent;
use Hydra::Helper::CatalystUtils;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::InfluxDBNotification;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use HTTP::Request;
use LWP::UserAgent;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::MercurialInput;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use Digest::SHA qw(sha256_hex);
use File::Path;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::PathInput;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use POSIX qw(strftime);
use Hydra::Helper::Nix;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::RunCommand;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use experimental 'smartmatch';
use JSON;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::S3Backup;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use File::Temp;
use File::Basename;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::SlackNotification;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use HTTP::Request;
use LWP::UserAgent;

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::SoTest;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use Hydra::Helper::CatalystUtils;
use HTTP::Request;
@ -101,8 +102,8 @@ sub buildFinished {
open( $authfile, "<", $sotest->{authfile} )
or die "Cannot open Sotest authfile \${\$sotest->{authfile}}";
while (<$authfile>) {
if ( $_ =~ /(.+):(.+)/m ) {
while (my $line = <$authfile>) {
if ( $line =~ /(.+):(.+)/m ) {
$sotest_username = $1;
$sotest_password = $2;
}

View file

@ -1,6 +1,7 @@
package Hydra::Plugin::SubversionInput;
use strict;
use warnings;
use parent 'Hydra::Plugin';
use Digest::SHA qw(sha256_hex);
use Hydra::Helper::Nix;

View file

@ -1,3 +1,5 @@
package Hydra::View::JSON;
use strict;
use warnings;
use base qw(Catalyst::View::JSON);
1;

View file

@ -1,5 +1,7 @@
package Hydra::View::NARInfo;
use strict;
use warnings;
use File::Basename;
use Hydra::Helper::CatalystUtils;
use MIME::Base64;
@ -7,7 +9,6 @@ use Nix::Manifest;
use Nix::Store;
use Nix::Utils;
use base qw/Catalyst::View/;
use strict;
sub process {
my ($self, $c) = @_;

View file

@ -1,6 +1,7 @@
package Hydra::View::NixClosure;
use strict;
use warnings;
use base qw/Catalyst::View/;
use IO::Pipe;

View file

@ -1,6 +1,7 @@
package Hydra::View::NixExprs;
use strict;
use warnings;
use base qw/Catalyst::View/;
use Hydra::Helper::Nix;
use Hydra::Helper::Escape;

View file

@ -1,6 +1,7 @@
package Hydra::View::NixLog;
use strict;
use warnings;
use base qw/Catalyst::View/;
use Hydra::Helper::CatalystUtils;

View file

@ -1,6 +1,7 @@
package Hydra::View::NixManifest;
use strict;
use warnings;
use base qw/Catalyst::View/;
use Hydra::Helper::Nix;
use Nix::Store;

View file

@ -1,6 +1,7 @@
package Hydra::View::NixNAR;
use strict;
use warnings;
use base qw/Catalyst::View/;
use Hydra::Helper::CatalystUtils;

View file

@ -1,6 +1,7 @@
package Hydra::View::TT;
use strict;
use warnings;
use base 'Catalyst::View::TT';
use Hydra::Helper::Nix;
use Time::Seconds;

View file

@ -1,6 +1,7 @@
#! /usr/bin/env perl
use strict;
use warnings;
use utf8;
use Hydra::Model::DB;

View file

@ -1,6 +1,7 @@
#! /usr/bin/env perl
use strict;
use warnings;
use Hydra::Schema;
use Hydra::Helper::Nix;
use Hydra::Model::DB;

View file

@ -1,5 +1,8 @@
#! /usr/bin/env perl
use strict;
use warnings;
BEGIN {
$ENV{CATALYST_SCRIPT_GEN} = 40;
}

View file

@ -1,12 +1,13 @@
#! /usr/bin/env perl
use strict;
use warnings;
use utf8;
use Config::General;
use Data::Dump qw(dump);
use Digest::SHA qw(sha256_hex);
use Encode;
use File::Slurp;
use File::Slurper qw(read_text);
use Hydra::Helper::AddBuilds;
use Hydra::Helper::CatalystUtils;
use Hydra::Helper::Email;
@ -121,7 +122,8 @@ sub fetchInputBuild {
my $versionRE = "(?:[A-Za-z0-9\.\-]+)";
my $relName = ($prevBuild->releasename or $prevBuild->nixname);
my $version = $2 if $relName =~ /^($pkgNameRE)-($versionRE)$/;
my $version;
$version = $2 if $relName =~ /^($pkgNameRE)-($versionRE)$/;
my $mainOutput = getMainOutput($prevBuild);
@ -166,7 +168,8 @@ sub fetchInputSystemBuild {
my $versionRE = "(?:[A-Za-z0-9\.\-]+)";
my $relName = ($prevBuild->releasename or $prevBuild->nixname);
my $version = $2 if $relName =~ /^($pkgNameRE)-($versionRE)$/;
my $version;
$version = $2 if $relName =~ /^($pkgNameRE)-($versionRE)$/;
my $input =
{ storePath => getMainOutput($prevBuild)->path
@ -568,7 +571,7 @@ sub checkJobsetWrapped {
die "multiple alternatives for the input containing the declarative project specification are not supported\n"
if scalar @declInputs != 1;
my $declFile = $declInput->{storePath} . "/" . $project->declfile;
my $declText = read_file($declFile)
my $declText = read_text($declFile)
or die "Couldn't read declarative specification file $declFile: $!\n";
my $declSpec;
eval {

View file

@ -1,10 +1,11 @@
#! /usr/bin/env perl
use strict;
use warnings;
use Hydra::Schema;
use Hydra::Helper::Nix;
use Hydra::Model::DB;
use File::Slurp;
use File::Slurper qw(read_text);
use SQL::SplitStatement;
use List::Util qw(max);
@ -24,7 +25,7 @@ my $maxSchemaVersion = max (map { /.*\/upgrade-(\d.*)\.sql/; $1 } (glob "$home/s
my @tables = $dbh->tables;
if (! grep { /SchemaVersion/i } @tables) {
print STDERR "initialising the Hydra database schema...\n";
my $schema = read_file(
my $schema = read_text(
$dbh->{Driver}->{Name} eq 'Pg' ? "$home/sql/hydra.sql" :
die "unsupported database type $dbh->{Driver}->{Name}\n");
my @statements = $sql_splitter->split($schema);
@ -57,7 +58,7 @@ QUOTE
for (my $n = $schemaVersion; $n < $maxSchemaVersion; $n++) {
my $m = $n + 1;
print STDERR "upgrading Hydra schema from version $n to $m\n";
my $schema = read_file("$home/sql/upgrade-$m.sql");
my $schema = read_text("$home/sql/upgrade-$m.sql");
my @statements = $sql_splitter->split($schema);
eval {
$dbh->begin_work;

View file

@ -1,6 +1,7 @@
#! /usr/bin/env perl
use strict;
use warnings;
use utf8;
use Getopt::Long;
use HTTP::Server::PSGI;

View file

@ -1,6 +1,7 @@
#! /usr/bin/env perl
use strict;
use warnings;
use File::Basename;
use Fcntl;
use IO::File;
@ -25,9 +26,9 @@ my $client = Net::Amazon::S3::Client->new( s3 => Net::Amazon::S3->new( retry =>
my $db = Hydra::Model::DB->new();
my $gcRootsDir = getGCRootsDir;
opendir DIR, $gcRootsDir or die;
my @roots = readdir DIR;
closedir DIR;
opendir my $dir, $gcRootsDir or die;
my @roots = readdir $dir;
closedir $dir;
my @actual_roots = ();
foreach my $link (@roots) {

View file

@ -1,10 +1,11 @@
#! /usr/bin/env perl
use strict;
use warnings;
use utf8;
use Hydra::Helper::Nix;
use Net::Statsd;
use File::Slurp;
use File::Slurper qw(read_text);
use JSON;
use Getopt::Long qw(:config gnu_getopt);
@ -92,7 +93,7 @@ while (1) {
1;
} or do { warn "$@"; };
my $meminfo = read_file("/proc/meminfo", err_mode => 'quiet') // "";
my $meminfo = read_text("/proc/meminfo") // "";
$meminfo =~ m/Dirty:\s*(\d+) kB/;
if (defined $1) {
my $dirty = $1 / (1024.0 * 1024.0);

View file

@ -1,5 +1,8 @@
#! /usr/bin/env perl
use strict;
use warnings;
BEGIN {
$ENV{CATALYST_SCRIPT_GEN} = 40;
}

View file

@ -1,6 +1,7 @@
#! /usr/bin/env perl
use strict;
use warnings;
use File::Path;
use File::stat;
use File::Basename;
@ -62,9 +63,9 @@ sub keepBuild {
# Read the current GC roots.
print STDERR "*** reading current roots...\n";
my $gcRootsDir = getGCRootsDir;
opendir DIR, $gcRootsDir or die;
my @roots = readdir DIR;
closedir DIR;
opendir my $dir, $gcRootsDir or die;
my @roots = readdir $dir;
closedir $dir;
# For scheduled builds, we register the derivation as a GC root.

View file

@ -1,4 +1,6 @@
use Cwd;
use strict;
use warnings;
die "$0: dbi connection string required \n" if scalar @ARGV != 1;

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
my %ctx = test_init(hydra_config => q|

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
my %ctx = test_init(

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
my %ctx = test_init(hydra_config => q|

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
use Data::Dumper;
my %ctx = test_init();

View file

@ -1,5 +1,6 @@
use feature 'unicode_strings';
use strict;
use warnings;
use Setup;
use IO::Uncompress::Bunzip2 qw(bunzip2);
use Archive::Tar;

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
use Data::Dumper;
my %ctx = test_init();

View file

@ -1,5 +1,6 @@
use feature 'unicode_strings';
use strict;
use warnings;
use Setup;
use JSON qw(decode_json encode_json);

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
my %ctx = test_init();

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
use Data::Dumper;
my %ctx = test_init();

View file

@ -1,5 +1,6 @@
use feature 'unicode_strings';
use strict;
use warnings;
use Setup;
use JSON qw(decode_json encode_json);

View file

@ -1,5 +1,6 @@
use feature 'unicode_strings';
use strict;
use warnings;
use Setup;
use JSON qw(decode_json encode_json);

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Hydra::Event;
use Test2::V0;

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
my %ctx = test_init();

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
my %ctx = test_init();

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
my %ctx = test_init();

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
use Data::Dumper;
use Test2::V0;

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
my %ctx = test_init();

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
my %ctx = test_init();

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
use JSON;
use File::Copy;

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
my %ctx = test_init();

View file

@ -1,5 +1,6 @@
use feature 'unicode_strings';
use strict;
use warnings;
use Setup;
my %ctx = test_init();

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
my %ctx = test_init();

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
use TestScmInput;

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
use TestScmInput;

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
use TestScmInput;

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
use TestScmInput;

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
use TestScmInput;

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
use TestScmInput;

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
use TestScmInput;

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
use TestScmInput;

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use Setup;
use TestScmInput;

View file

@ -1,6 +1,7 @@
package Setup;
use strict;
use warnings;
use Exporter;
use Test::PostgreSQL;
use File::Temp;
@ -49,7 +50,7 @@ sub test_init {
$ENV{'NIX_CONF_DIR'} = "$dir/nix/etc/nix";
make_path($ENV{'NIX_CONF_DIR'});
my $nixconf = "$ENV{'NIX_CONF_DIR'}/nix.conf";
my $nix_config = "sandbox = false\n" . $opts{'nix_config'};
my $nix_config = "sandbox = false\n" . ($opts{'nix_config'} || "");
write_file($nixconf, $nix_config);
$ENV{'HYDRA_CONFIG'} = "$dir/hydra.conf";

View file

@ -1,5 +1,6 @@
use feature 'unicode_strings';
use strict;
use warnings;
use Setup;
my %ctx = test_init(

View file

@ -1,4 +1,5 @@
use strict;
use warnings;
use File::Basename;
use Hydra::Model::DB;
use Hydra::Helper::Nix;
@ -38,12 +39,12 @@ ok(-e "/tmp/s3/hydra/$successful_hash.nar", "The nar of a build that's a root is
ok(-e "/tmp/s3/hydra/$successful_hash.narinfo", "The narinfo of a build that's a root is not removed by gc");
my $gcRootsDir = getGCRootsDir;
opendir DIR, $gcRootsDir or die;
while(readdir DIR) {
next if $_ eq "." or $_ eq "..";
unlink "$gcRootsDir/$_";
opendir my $dir, $gcRootsDir or die;
while(my $file = readdir $dir) {
next if $file eq "." or $file eq "..";
unlink "$gcRootsDir/$file";
}
closedir DIR;
closedir $dir;
system("hydra-s3-backup-collect-garbage");
ok(not -e "/tmp/s3/hydra/$successful_hash.nar", "The nar of a build that's not a root is removed by gc");
ok(not -e "/tmp/s3/hydra/$successful_hash.narinfo", "The narinfo of a build that's not a root is removed by gc");

View file

@ -1,5 +1,6 @@
use feature 'unicode_strings';
use strict;
use warnings;
use Setup;
my %ctx = test_init();

View file

@ -1,5 +1,6 @@
use feature 'unicode_strings';
use strict;
use warnings;
use Setup;
my %ctx = test_init();

View file

@ -1,5 +1,6 @@
use feature 'unicode_strings';
use strict;
use warnings;
use Setup;
my %ctx = test_init();

View file

@ -1,3 +1,5 @@
use strict;
use warnings;
use LWP::UserAgent;
use JSON;