Merge pull request #866 from Infinisil/github-status-flakes

Fix Github status plugin for flakes
This commit is contained in:
Eelco Dolstra 2021-02-16 17:00:46 +01:00 committed by GitHub
commit a39b479280
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -57,17 +57,14 @@ sub common {
my @inputs = defined $inputs_cfg ? ref $inputs_cfg eq "ARRAY" ? @$inputs_cfg : ($inputs_cfg) : (); my @inputs = defined $inputs_cfg ? ref $inputs_cfg eq "ARRAY" ? @$inputs_cfg : ($inputs_cfg) : ();
my %seen = map { $_ => {} } @inputs; my %seen = map { $_ => {} } @inputs;
while (my $eval = $evals->next) { while (my $eval = $evals->next) {
foreach my $input (@inputs) {
my $i = $eval->jobsetevalinputs->find({ name => $input, altnr => 0 }); my $sendStatus = sub {
next unless defined $i; my ($input, $owner, $repo, $rev) = @_;
my $uri = $i->uri;
my $rev = $i->revision; my $key = $owner . "-" . $repo . "-" . $rev;
my $key = $uri . "-" . $rev; return if exists $seen{$input}->{$key};
next if exists $seen{$input}->{$key};
$seen{$input}->{$key} = 1; $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 $url = "https://api.github.com/repos/$owner/$repo/statuses/$rev";
my $req = HTTP::Request->new('POST', $url); my $req = HTTP::Request->new('POST', $url);
$req->header('Content-Type' => 'application/json'); $req->header('Content-Type' => 'application/json');
@ -91,6 +88,25 @@ sub common {
} else { } else {
print STDERR "GithubStatus ratelimit $limitRemaining/$limit, resets in $diff\n"; 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);
}
} }
} }
} }