forked from lix-project/hydra
Merge pull request #1068 from DeterminateSystems/fix-some-warnings
Fix some warnings
This commit is contained in:
commit
7227395a72
|
@ -429,7 +429,6 @@
|
||||||
CatalystAuthenticationStoreDBIxClass
|
CatalystAuthenticationStoreDBIxClass
|
||||||
CatalystAuthenticationStoreLDAP
|
CatalystAuthenticationStoreLDAP
|
||||||
CatalystDevel
|
CatalystDevel
|
||||||
CatalystDispatchTypeRegex
|
|
||||||
CatalystPluginAccessLog
|
CatalystPluginAccessLog
|
||||||
CatalystPluginAuthorizationRoles
|
CatalystPluginAuthorizationRoles
|
||||||
CatalystPluginCaptcha
|
CatalystPluginCaptcha
|
||||||
|
|
|
@ -8,7 +8,6 @@ use Hydra::Plugin;
|
||||||
use Hydra::Model::DB;
|
use Hydra::Model::DB;
|
||||||
use Catalyst::Runtime '5.70';
|
use Catalyst::Runtime '5.70';
|
||||||
use Catalyst qw/ConfigLoader
|
use Catalyst qw/ConfigLoader
|
||||||
Unicode::Encoding
|
|
||||||
Static::Simple
|
Static::Simple
|
||||||
StackTrace
|
StackTrace
|
||||||
Authentication
|
Authentication
|
||||||
|
|
|
@ -15,6 +15,9 @@ use JSON;
|
||||||
use List::Util qw[min max];
|
use List::Util qw[min max];
|
||||||
use List::MoreUtils qw{any};
|
use List::MoreUtils qw{any};
|
||||||
use Net::Prometheus;
|
use Net::Prometheus;
|
||||||
|
use Types::Standard qw/StrMatch/;
|
||||||
|
|
||||||
|
use constant NARINFO_REGEX => qr{^([a-z0-9]{32})\.narinfo$};
|
||||||
|
|
||||||
# Put this controller at top-level.
|
# Put this controller at top-level.
|
||||||
__PACKAGE__->config->{namespace} = '';
|
__PACKAGE__->config->{namespace} = '';
|
||||||
|
@ -349,17 +352,17 @@ sub nix_cache_info :Path('nix-cache-info') :Args(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub narinfo :LocalRegex('^([a-z0-9]+).narinfo$') :Args(0) {
|
sub narinfo :Path :Args(StrMatch[NARINFO_REGEX]) {
|
||||||
my ($self, $c) = @_;
|
my ($self, $c, $narinfo) = @_;
|
||||||
|
|
||||||
if (!isLocalStore) {
|
if (!isLocalStore) {
|
||||||
notFound($c, "There is no binary cache here.");
|
notFound($c, "There is no binary cache here.");
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
my $hash = $c->req->captures->[0];
|
my ($hash) = $narinfo =~ NARINFO_REGEX;
|
||||||
|
|
||||||
die if length($hash) != 32;
|
die("Hash length was not 32") if length($hash) != 32;
|
||||||
my $path = queryPathFromHashPart($hash);
|
my $path = queryPathFromHashPart($hash);
|
||||||
|
|
||||||
if (!$path) {
|
if (!$path) {
|
||||||
|
|
|
@ -17,7 +17,7 @@ sub parse_payload :prototype($$) {
|
||||||
my ($channel_name, $payload) = @_;
|
my ($channel_name, $payload) = @_;
|
||||||
my @payload = split /\t/, $payload;
|
my @payload = split /\t/, $payload;
|
||||||
|
|
||||||
my $parser = %channels_to_events{$channel_name};
|
my $parser = $channels_to_events{$channel_name};
|
||||||
unless (defined $parser) {
|
unless (defined $parser) {
|
||||||
die "Invalid channel name: '$channel_name'";
|
die "Invalid channel name: '$channel_name'";
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,7 +279,7 @@ sub requirePost {
|
||||||
|
|
||||||
|
|
||||||
sub trim {
|
sub trim {
|
||||||
my $s = shift;
|
my $s = shift // "";
|
||||||
$s =~ s/^\s+|\s+$//g;
|
$s =~ s/^\s+|\s+$//g;
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -644,7 +644,7 @@ sub checkJobsetWrapped {
|
||||||
# Hash the arguments to hydra-eval-jobs and check the
|
# Hash the arguments to hydra-eval-jobs and check the
|
||||||
# JobsetInputHashes to see if the previous evaluation had the same
|
# JobsetInputHashes to see if the previous evaluation had the same
|
||||||
# inputs. If so, bail out.
|
# inputs. If so, bail out.
|
||||||
my @args = ($jobset->nixexprinput, $jobset->nixexprpath, inputsToArgs($inputInfo));
|
my @args = ($jobset->nixexprinput // "", $jobset->nixexprpath // "", inputsToArgs($inputInfo));
|
||||||
my $argsHash = sha256_hex("@args");
|
my $argsHash = sha256_hex("@args");
|
||||||
my $prevEval = getPrevJobsetEval($db, $jobset, 0);
|
my $prevEval = getPrevJobsetEval($db, $jobset, 0);
|
||||||
if (defined $prevEval && $prevEval->hash eq $argsHash && !$dryRun && !$jobset->forceeval && $prevEval->flake eq $flakeRef) {
|
if (defined $prevEval && $prevEval->hash eq $argsHash && !$dryRun && !$jobset->forceeval && $prevEval->flake eq $flakeRef) {
|
||||||
|
|
48
t/Controller/Root/narinfo.t
Normal file
48
t/Controller/Root/narinfo.t
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Setup;
|
||||||
|
use Data::Dumper;
|
||||||
|
use JSON qw(decode_json);
|
||||||
|
my %ctx = test_init(
|
||||||
|
# Without this, the test will fail because a `file:` store is not treated as a
|
||||||
|
# local store by `isLocalStore` in src/lib/Hydra/Helper/Nix.pm, and any
|
||||||
|
# requests to /HASH.narinfo will fail.
|
||||||
|
use_external_destination_store => 0
|
||||||
|
);
|
||||||
|
|
||||||
|
require Hydra::Schema;
|
||||||
|
require Hydra::Model::DB;
|
||||||
|
require Hydra::Helper::Nix;
|
||||||
|
|
||||||
|
use Test2::V0;
|
||||||
|
require Catalyst::Test;
|
||||||
|
use HTTP::Request::Common;
|
||||||
|
Catalyst::Test->import('Hydra');
|
||||||
|
|
||||||
|
my $db = Hydra::Model::DB->new;
|
||||||
|
hydra_setup($db);
|
||||||
|
|
||||||
|
my $project = $db->resultset('Projects')->create({name => "tests", displayname => "", owner => "root"});
|
||||||
|
|
||||||
|
my $jobset = createBaseJobset("basic", "basic.nix", $ctx{jobsdir});
|
||||||
|
|
||||||
|
ok(evalSucceeds($jobset), "Evaluating jobs/basic.nix should exit with return code 0");
|
||||||
|
for my $build (queuedBuildsForJobset($jobset)) {
|
||||||
|
ok(runBuild($build), "Build '".$build->job."' from jobs/basic.nix should exit with return code 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
subtest "/HASH.narinfo" => sub {
|
||||||
|
my $build_redirect = request(GET '/job/tests/basic/empty_dir/latest-finished');
|
||||||
|
my $url = URI->new($build_redirect->header('location'))->path;
|
||||||
|
my $json = request(GET $url, Accept => 'application/json');
|
||||||
|
my $data = decode_json($json->content);
|
||||||
|
my $outpath = $data->{buildoutputs}{out}{path};
|
||||||
|
my ($hash) = $outpath =~ qr{/nix/store/([a-z0-9]{32}).*};
|
||||||
|
my $narinfo_response = request(GET "/$hash.narinfo");
|
||||||
|
ok($narinfo_response->is_success, "Getting the narinfo of a build");
|
||||||
|
|
||||||
|
my ($storepath) = $narinfo_response->content =~ qr{StorePath: (.*)};
|
||||||
|
is($storepath, $outpath, "The returned store path is the same as the out path")
|
||||||
|
};
|
||||||
|
|
||||||
|
done_testing;
|
28
t/Helper/CatalystUtils.t
Normal file
28
t/Helper/CatalystUtils.t
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Setup;
|
||||||
|
use Test2::V0;
|
||||||
|
use Hydra::Helper::CatalystUtils;
|
||||||
|
|
||||||
|
subtest "trim" => sub {
|
||||||
|
my %values = (
|
||||||
|
"" => "",
|
||||||
|
"🌮" => '🌮',
|
||||||
|
" 🌮" => '🌮',
|
||||||
|
"🌮 " => '🌮',
|
||||||
|
" 🌮 " => '🌮',
|
||||||
|
"\n🌮 " => '🌮',
|
||||||
|
"\n\t🌮\n\n\t" => '🌮',
|
||||||
|
);
|
||||||
|
|
||||||
|
for my $input (keys %values) {
|
||||||
|
my $value = $values{$input};
|
||||||
|
is(trim($input), $value, "Trim the value: " . $input);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $uninitialized;
|
||||||
|
|
||||||
|
is(trim($uninitialized), '', "Trimming an uninitialized value");
|
||||||
|
};
|
||||||
|
|
||||||
|
done_testing;
|
Loading…
Reference in a new issue