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 theme = community
# 5 is the least complainy, 1 is the most complainy # 5 is the least complainy, 1 is the most complainy
severity = 5 severity = 4

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,7 +4,7 @@ use utf8;
use strict; use strict;
use warnings; use warnings;
use base 'Hydra::Base::Controller::REST'; use base 'Hydra::Base::Controller::REST';
use File::Slurp; use File::Slurper qw(read_text);
use Crypt::RandPasswd; use Crypt::RandPasswd;
use Digest::SHA1 qw(sha1_hex); use Digest::SHA1 qw(sha1_hex);
use Hydra::Helper::Nix; 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_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 = $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_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 =~ s/\s+//;
$client_secret; $client_secret;
}; };

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,6 +1,7 @@
#! /usr/bin/env perl #! /usr/bin/env perl
use strict; use strict;
use warnings;
use File::Basename; use File::Basename;
use Fcntl; use Fcntl;
use IO::File; 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 $db = Hydra::Model::DB->new();
my $gcRootsDir = getGCRootsDir; my $gcRootsDir = getGCRootsDir;
opendir DIR, $gcRootsDir or die; opendir my $dir, $gcRootsDir or die;
my @roots = readdir DIR; my @roots = readdir $dir;
closedir DIR; closedir $dir;
my @actual_roots = (); my @actual_roots = ();
foreach my $link (@roots) { foreach my $link (@roots) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,4 +1,5 @@
use strict; use strict;
use warnings;
use File::Basename; use File::Basename;
use Hydra::Model::DB; use Hydra::Model::DB;
use Hydra::Helper::Nix; 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"); 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; my $gcRootsDir = getGCRootsDir;
opendir DIR, $gcRootsDir or die; opendir my $dir, $gcRootsDir or die;
while(readdir DIR) { while(my $file = readdir $dir) {
next if $_ eq "." or $_ eq ".."; next if $file eq "." or $file eq "..";
unlink "$gcRootsDir/$_"; unlink "$gcRootsDir/$file";
} }
closedir DIR; closedir $dir;
system("hydra-s3-backup-collect-garbage"); 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.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"); 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 feature 'unicode_strings';
use strict; use strict;
use warnings;
use Setup; use Setup;
my %ctx = test_init(); my %ctx = test_init();

View file

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

View file

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

View file

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