Fix Github status plugin for flakes

If the root flake is a github: one, github status notifications are sent
to it. The githubstatus->inputs configuration isn't used for flakes.
This commit is contained in:
Silvan Mosberger 2021-02-06 00:02:30 +01:00
parent 1d45b63516
commit 58dd7f9ed3
No known key found for this signature in database
GPG key ID: E8F1E9EAD284E17D

View file

@ -57,17 +57,14 @@ sub common {
my @inputs = defined $inputs_cfg ? ref $inputs_cfg eq "ARRAY" ? @$inputs_cfg : ($inputs_cfg) : ();
my %seen = map { $_ => {} } @inputs;
while (my $eval = $evals->next) {
foreach my $input (@inputs) {
my $i = $eval->jobsetevalinputs->find({ name => $input, altnr => 0 });
next unless defined $i;
my $uri = $i->uri;
my $rev = $i->revision;
my $key = $uri . "-" . $rev;
next if exists $seen{$input}->{$key};
my $sendStatus = sub {
my ($input, $owner, $repo, $rev) = @_;
my $key = $owner . "-" . $repo . "-" . $rev;
return if exists $seen{$input}->{$key};
$seen{$input}->{$key} = 1;
$uri =~ m![:/]([^/]+)/([^/]+?)(?:.git)?$!;
my $owner = $1;
my $repo = $2;
my $url = "https://api.github.com/repos/$owner/$repo/statuses/$rev";
my $req = HTTP::Request->new('POST', $url);
$req->header('Content-Type' => 'application/json');
@ -91,6 +88,25 @@ sub common {
} else {
print STDERR "GithubStatus ratelimit $limitRemaining/$limit, resets in $diff\n";
}
};
if (defined $eval->flake) {
my $fl = $eval->flake;
print STDERR "Flake is $fl\n";
$eval->flake =~ m!github:([^/]+)/([^/]+)/(.+)$!;
$sendStatus->("src", $1, $2, $3);
} else {
foreach my $input (@inputs) {
my $i = $eval->jobsetevalinputs->find({ name => $input, altnr => 0 });
if (! defined $i) {
print STDERR "Evaluation $eval doesn't have input $input\n";
}
next unless defined $i;
my $uri = $i->uri;
my $rev = $i->revision;
$uri =~ m![:/]([^/]+)/([^/]+?)(?:.git)?$!;
$sendStatus->($input, $1, $2, $rev);
}
}
}
}