add hydra patch for gitea status on flakes
This commit is contained in:
parent
b7f046e59e
commit
87459e2018
2 changed files with 87 additions and 0 deletions
|
@ -7,6 +7,11 @@
|
|||
});
|
||||
soundtouch = nixpkgs-soundtouch.legacyPackages.${system}.soundtouch;
|
||||
tdesktop = nixpkgs-tdesktop.legacyPackages.${system}.tdesktop;
|
||||
hydra = prev.hydra.overrideAttrs (old: {
|
||||
patches = [
|
||||
../../extra/hydra.patch
|
||||
];
|
||||
});
|
||||
})
|
||||
];
|
||||
}
|
||||
|
|
82
extra/hydra.patch
Normal file
82
extra/hydra.patch
Normal file
|
@ -0,0 +1,82 @@
|
|||
diff --git a/src/lib/Hydra/Plugin/GiteaStatus.pm b/src/lib/Hydra/Plugin/GiteaStatus.pm
|
||||
index 426c93f5..0ffc7cf6 100644
|
||||
--- a/src/lib/Hydra/Plugin/GiteaStatus.pm
|
||||
+++ b/src/lib/Hydra/Plugin/GiteaStatus.pm
|
||||
@@ -52,34 +52,51 @@ sub common {
|
||||
});
|
||||
|
||||
while (my $eval = $evals->next) {
|
||||
- my $giteastatusInput = $eval->jobsetevalinputs->find({ name => "gitea_status_repo" });
|
||||
- next unless defined $giteastatusInput && defined $giteastatusInput->value;
|
||||
- my $i = $eval->jobsetevalinputs->find({ name => $giteastatusInput->value, altnr => 0 });
|
||||
- next unless defined $i;
|
||||
- my $gitea_url = $eval->jobsetevalinputs->find({ name => "gitea_http_url" });
|
||||
-
|
||||
- my $repoOwner = $eval->jobsetevalinputs->find({ name => "gitea_repo_owner" })->value;
|
||||
- my $repoName = $eval->jobsetevalinputs->find({ name => "gitea_repo_name" })->value;
|
||||
- my $accessToken = $self->{config}->{gitea_authorization}->{$repoOwner};
|
||||
-
|
||||
- my $rev = $i->revision;
|
||||
- my $domain = URI->new($i->uri)->host;
|
||||
- my $host;
|
||||
- unless (defined $gitea_url) {
|
||||
- $host = "https://$domain";
|
||||
+ my $sendStatus = sub {
|
||||
+ my ($input, $host, $owner, $repo, $rev) = @_;
|
||||
+
|
||||
+ my $accessToken = $self->{config}->{gitea_authorization}->{$repoOwner};
|
||||
+ my $url = "$host/api/v1/repos/$repoOwner/$repoName/statuses/$rev";
|
||||
+
|
||||
+ print STDERR "GiteaStatus POSTing $state to $url\n";
|
||||
+ my $req = HTTP::Request->new('POST', $url);
|
||||
+ $req->header('Content-Type' => 'application/json');
|
||||
+ $req->header('Authorization' => "token $accessToken");
|
||||
+ $req->content($body);
|
||||
+ my $res = $ua->request($req);
|
||||
+ print STDERR $res->status_line, ": ", $res->decoded_content, "\n" unless $res->is_success;
|
||||
+
|
||||
+ };
|
||||
+ if (defined $eval->flake) {
|
||||
+ my $fl = $eval->flake;
|
||||
+ print STDERR "Flake is $fl\n";
|
||||
+ if ($eval->flake =~ m!git\+https://git\.chir\.rs/([^/]+)/([^/]+)\?.*rev=([[:xdigit:]]{40})$!) {
|
||||
+ $sendStatus->("src", "https://git.chir.rs", $1, $2, $3);
|
||||
+ } else {
|
||||
+ print STDERR "Can't parse flake, skipping Gitea status update\n";
|
||||
+ }
|
||||
} else {
|
||||
- $host = $gitea_url->value;
|
||||
- }
|
||||
-
|
||||
- my $url = "$host/api/v1/repos/$repoOwner/$repoName/statuses/$rev";
|
||||
+ my $giteastatusInput = $eval->jobsetevalinputs->find({ name => "gitea_status_repo" });
|
||||
+ next unless defined $giteastatusInput && defined $giteastatusInput->value;
|
||||
+ my $i = $eval->jobsetevalinputs->find({ name => $giteastatusInput->value, altnr => 0 });
|
||||
+ next unless defined $i;
|
||||
+ my $gitea_url = $eval->jobsetevalinputs->find({ name => "gitea_http_url" });
|
||||
+
|
||||
+ my $repoOwner = $eval->jobsetevalinputs->find({ name => "gitea_repo_owner" })->value;
|
||||
+ my $repoName = $eval->jobsetevalinputs->find({ name => "gitea_repo_name" })->value;
|
||||
+
|
||||
+ my $rev = $i->revision;
|
||||
+ my $domain = URI->new($i->uri)->host;
|
||||
+ my $host;
|
||||
+ unless (defined $gitea_url) {
|
||||
+ $host = "https://$domain";
|
||||
+ } else {
|
||||
+ $host = $gitea_url->value;
|
||||
+ }
|
||||
+
|
||||
+ $sendStatus->($giteaStatusInput, $host, $repoOwner, $repoName, $rev);
|
||||
|
||||
- print STDERR "GiteaStatus POSTing $state to $url\n";
|
||||
- my $req = HTTP::Request->new('POST', $url);
|
||||
- $req->header('Content-Type' => 'application/json');
|
||||
- $req->header('Authorization' => "token $accessToken");
|
||||
- $req->content($body);
|
||||
- my $res = $ua->request($req);
|
||||
- print STDERR $res->status_line, ": ", $res->decoded_content, "\n" unless $res->is_success;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue