add hydra #75
6 changed files with 1337 additions and 5 deletions
1055
ci/hydra/add-ca-support.patch
Normal file
1055
ci/hydra/add-ca-support.patch
Normal file
File diff suppressed because it is too large
Load diff
84
ci/hydra/add-gitea-push-hook.patch
Normal file
84
ci/hydra/add-gitea-push-hook.patch
Normal file
|
@ -0,0 +1,84 @@
|
|||
diff --git a/doc/manual/src/webhooks.md b/doc/manual/src/webhooks.md
|
||||
index 2b26cd61..674e1064 100644
|
||||
--- a/doc/manual/src/webhooks.md
|
||||
+++ b/doc/manual/src/webhooks.md
|
||||
@@ -1,9 +1,12 @@
|
||||
# Webhooks
|
||||
|
||||
-Hydra can be notified by github's webhook to trigger a new evaluation when a
|
||||
+Hydra can be notified by github or gitea with webhooks to trigger a new evaluation when a
|
||||
jobset has a github repo in its input.
|
||||
-To set up a github webhook go to `https://github.com/<yourhandle>/<yourrepo>/settings` and in the `Webhooks` tab
|
||||
-click on `Add webhook`.
|
||||
+
|
||||
+## GitHub
|
||||
+
|
||||
+To set up a webhook for a GitHub repository go to `https://github.com/<yourhandle>/<yourrepo>/settings`
|
||||
+and in the `Webhooks` tab click on `Add webhook`.
|
||||
|
||||
- In `Payload URL` fill in `https://<your-hydra-domain>/api/push-github`.
|
||||
- In `Content type` switch to `application/json`.
|
||||
@@ -11,3 +14,14 @@ click on `Add webhook`.
|
||||
- For `Which events would you like to trigger this webhook?` keep the default option for events on `Just the push event.`.
|
||||
|
||||
Then add the hook with `Add webhook`.
|
||||
+
|
||||
+## Gitea
|
||||
+
|
||||
+To set up a webhook for a Gitea repository go to the settings of the repository in your Gitea instance
|
||||
+and in the `Webhooks` tab click on `Add Webhook` and choose `Gitea` in the drop down.
|
||||
+
|
||||
+- In `Target URL` fill in `https://<your-hydra-domain>/api/push-gitea`.
|
||||
+- Keep HTTP method `POST`, POST Content Type `application/json` and Trigger On `Push Events`.
|
||||
+- Change the branch filter to match the git branch hydra builds.
|
||||
+
|
||||
+Then add the hook with `Add webhook`.
|
||||
diff --git a/src/lib/Hydra/Controller/API.pm b/src/lib/Hydra/Controller/API.pm
|
||||
index 8ebed599..06f35d4b 100644
|
||||
--- a/src/lib/Hydra/Controller/API.pm
|
||||
+++ b/src/lib/Hydra/Controller/API.pm
|
||||
@@ -285,6 +285,23 @@ sub push_github : Chained('api') PathPart('push-github') Args(0) {
|
||||
$c->response->body("");
|
||||
}
|
||||
|
||||
+sub push_gitea : Chained('api') PathPart('push-gitea') Args(0) {
|
||||
+ my ($self, $c) = @_;
|
||||
+
|
||||
+ $c->{stash}->{json}->{jobsetsTriggered} = [];
|
||||
+
|
||||
+ my $in = $c->request->{data};
|
||||
+ my $url = $in->{repository}->{clone_url} or die;
|
||||
+ $url =~ s/.git$//;
|
||||
+ print STDERR "got push from Gitea repository $url\n";
|
||||
+
|
||||
+ triggerJobset($self, $c, $_, 0) foreach $c->model('DB::Jobsets')->search(
|
||||
+ { 'project.enabled' => 1, 'me.enabled' => 1 },
|
||||
+ { join => 'project'
|
||||
+ , where => \ [ 'me.flake like ? or exists (select 1 from JobsetInputAlts where project = me.project and jobset = me.name and value like ?)', [ 'flake', "%$url%"], [ 'value', "%$url%" ] ]
|
||||
+ });
|
||||
+ $c->response->body("");
|
||||
+}
|
||||
|
||||
|
||||
1;
|
||||
diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm
|
||||
index c6843d29..1b33db2a 100644
|
||||
--- a/src/lib/Hydra/Controller/Root.pm
|
||||
+++ b/src/lib/Hydra/Controller/Root.pm
|
||||
@@ -32,6 +32,7 @@ sub noLoginNeeded {
|
||||
|
||||
return $whitelisted ||
|
||||
$c->request->path eq "api/push-github" ||
|
||||
+ $c->request->path eq "api/push-gitea" ||
|
||||
$c->request->path eq "google-login" ||
|
||||
$c->request->path eq "github-redirect" ||
|
||||
$c->request->path eq "github-login" ||
|
||||
@@ -77,7 +78,7 @@ sub begin :Private {
|
||||
$_->supportedInputTypes($c->stash->{inputTypes}) foreach @{$c->hydra_plugins};
|
||||
|
||||
# XSRF protection: require POST requests to have the same origin.
|
||||
- if ($c->req->method eq "POST" && $c->req->path ne "api/push-github") {
|
||||
+ if ($c->req->method eq "POST" && $c->req->path ne "api/push-github" && $c->req->path ne "api/push-gitea") {
|
||||
my $referer = $c->req->header('Referer');
|
||||
$referer //= $c->req->header('Origin');
|
||||
my $base = $c->req->base;
|
70
ci/hydra/jobset-inputs-for-flakes.patch
Normal file
70
ci/hydra/jobset-inputs-for-flakes.patch
Normal file
|
@ -0,0 +1,70 @@
|
|||
diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm
|
||||
index eeb4232a..b6e9519c 100644
|
||||
--- a/src/lib/Hydra/Controller/Jobset.pm
|
||||
+++ b/src/lib/Hydra/Controller/Jobset.pm
|
||||
@@ -294,26 +294,24 @@ sub updateJobset {
|
||||
# Set the inputs of this jobset.
|
||||
$jobset->jobsetinputs->delete;
|
||||
|
||||
- if ($type == 0) {
|
||||
- foreach my $name (keys %{$c->stash->{params}->{inputs}}) {
|
||||
- my $inputData = $c->stash->{params}->{inputs}->{$name};
|
||||
- my $type = $inputData->{type};
|
||||
- my $value = $inputData->{value};
|
||||
- my $emailresponsible = defined $inputData->{emailresponsible} ? 1 : 0;
|
||||
- my $types = knownInputTypes($c);
|
||||
-
|
||||
- badRequest($c, "Invalid input name ‘$name’.") unless $name =~ /^[[:alpha:]][\w-]*$/;
|
||||
- badRequest($c, "Invalid input type ‘$type’; valid types: $types.") unless defined $c->stash->{inputTypes}->{$type};
|
||||
-
|
||||
- my $input = $jobset->jobsetinputs->create(
|
||||
- { name => $name,
|
||||
- type => $type,
|
||||
- emailresponsible => $emailresponsible
|
||||
- });
|
||||
-
|
||||
- $value = checkInputValue($c, $name, $type, $value);
|
||||
- $input->jobsetinputalts->create({altnr => 0, value => $value});
|
||||
- }
|
||||
+ foreach my $name (keys %{$c->stash->{params}->{inputs}}) {
|
||||
+ my $inputData = $c->stash->{params}->{inputs}->{$name};
|
||||
+ my $type = $inputData->{type};
|
||||
+ my $value = $inputData->{value};
|
||||
+ my $emailresponsible = defined $inputData->{emailresponsible} ? 1 : 0;
|
||||
+ my $types = knownInputTypes($c);
|
||||
+
|
||||
+ badRequest($c, "Invalid input name ‘$name’.") unless $name =~ /^[[:alpha:]][\w-]*$/;
|
||||
+ badRequest($c, "Invalid input type ‘$type’; valid types: $types.") unless defined $c->stash->{inputTypes}->{$type};
|
||||
+
|
||||
+ my $input = $jobset->jobsetinputs->create(
|
||||
+ { name => $name,
|
||||
+ type => $type,
|
||||
+ emailresponsible => $emailresponsible
|
||||
+ });
|
||||
+
|
||||
+ $value = checkInputValue($c, $name, $type, $value);
|
||||
+ $input->jobsetinputalts->create({altnr => 0, value => $value});
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/root/edit-jobset.tt b/src/root/edit-jobset.tt
|
||||
index 61e3636f..73f11a72 100644
|
||||
--- a/src/root/edit-jobset.tt
|
||||
+++ b/src/root/edit-jobset.tt
|
||||
@@ -42,7 +42,15 @@
|
||||
[% END %]
|
||||
|
||||
[% BLOCK renderJobsetInputs %]
|
||||
- <table class="table table-striped table-condensed show-on-legacy">
|
||||
+ <div class="card show-on-flake border-danger">
|
||||
+ <div class="text-danger card-body">
|
||||
+ <h5 class="card-title">Jobset Inputs don't take any effect for flakes</h5>
|
||||
+ <p class="card-text">
|
||||
+ These are only available to configure Hydra plugins.
|
||||
+ </p>
|
||||
+ </div>
|
||||
+ </div>
|
||||
+ <table class="table table-striped table-condensed">
|
||||
<thead>
|
||||
<tr><th></th><th>Input name</th><th>Type</th><th style="width: 50%">Value</th><th>Notify committers</th></tr>
|
||||
</thead>
|
16
ci/hydra/remove-hydra-size-limit.patch
Normal file
16
ci/hydra/remove-hydra-size-limit.patch
Normal file
|
@ -0,0 +1,16 @@
|
|||
diff --git a/src/hydra-queue-runner/build-remote.cc b/src/hydra-queue-runner/build-remote.cc
|
||||
index 21a6c331..05380681 100644
|
||||
--- a/src/hydra-queue-runner/build-remote.cc
|
||||
+++ b/src/hydra-queue-runner/build-remote.cc
|
||||
@@ -468,11 +468,6 @@ void State::buildRemote(ref<Store> destStore,
|
||||
infos.insert_or_assign(info.path, info);
|
||||
}
|
||||
|
||||
- if (totalNarSize > maxOutputSize) {
|
||||
- result.stepStatus = bsNarSizeLimitExceeded;
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
/* Copy each path. */
|
||||
printMsg(lvlDebug, "copying outputs of ‘%s’ from ‘%s’ (%d bytes)",
|
||||
localStore->printStorePath(step->drvPath), machine->sshName, totalNarSize);
|
101
flake.lock
101
flake.lock
|
@ -126,6 +126,45 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"hydra": {
|
||||
"inputs": {
|
||||
"nix": "nix",
|
||||
"nixpkgs": [
|
||||
"hydra",
|
||||
"nix",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1679916613,
|
||||
"narHash": "sha256-Nj9U0V7Zv7XoRDdO7ECphTk6jHfOgeZe6G0x4FQLpJ0=",
|
||||
"owner": "NixOS",
|
||||
"repo": "hydra",
|
||||
"rev": "082495e34e094cae1eb49dbfc5648938e23c6355",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"repo": "hydra",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"lowdown-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1633514407,
|
||||
"narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=",
|
||||
"owner": "kristapsdz",
|
||||
"repo": "lowdown",
|
||||
"rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "kristapsdz",
|
||||
"repo": "lowdown",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"mautrix-cleanup": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
|
@ -149,18 +188,56 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix": {
|
||||
"inputs": {
|
||||
"lowdown-src": "lowdown-src",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nixpkgs-regression": "nixpkgs-regression"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1677045134,
|
||||
"narHash": "sha256-jUc2ccTR8f6MGY2pUKgujm+lxSPNGm/ZAP+toX+nMNc=",
|
||||
"owner": "nixos",
|
||||
"repo": "nix",
|
||||
"rev": "4acc684ef7b3117c6d6ac12837398a0008a53d85",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "2.13.3",
|
||||
"repo": "nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1682072342,
|
||||
"narHash": "sha256-7Julr+vO2rdUlXW32xAc7wxXsovGSVtvLV7533mbZAc=",
|
||||
"lastModified": 1670461440,
|
||||
"narHash": "sha256-jy1LB8HOMKGJEGXgzFRLDU1CBGL0/LlkolgnqIsF0D8=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e7c59bac33955b86f9a4a2bb4bcc08f8d01ac216",
|
||||
"rev": "04a75b2eecc0acf6239acf9dd04485ff8d14f425",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-22.11-small",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-regression": {
|
||||
"locked": {
|
||||
"lastModified": 1643052045,
|
||||
"narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
|
@ -180,14 +257,30 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1682072342,
|
||||
"narHash": "sha256-7Julr+vO2rdUlXW32xAc7wxXsovGSVtvLV7533mbZAc=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e7c59bac33955b86f9a4a2bb4bcc08f8d01ac216",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"attic": "attic",
|
||||
"flake-compat": "flake-compat_2",
|
||||
"flake-utils": "flake-utils",
|
||||
"gomod2nix": "gomod2nix",
|
||||
"hydra": "hydra",
|
||||
"mautrix-cleanup": "mautrix-cleanup",
|
||||
"nixpkgs": "nixpkgs"
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
|
|
16
flake.nix
16
flake.nix
|
@ -23,12 +23,16 @@
|
|||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
inputs.utils.follows = "flake-utils";
|
||||
};
|
||||
hydra = {
|
||||
url = "github:NixOS/hydra";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = {
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
gomod2nix,
|
||||
hydra,
|
||||
...
|
||||
} @ inputs:
|
||||
flake-utils.lib.eachSystem ["aarch64-darwin" "aarch64-linux" "x86_64-darwin" "x86_64-linux" "riscv64-linux"] (
|
||||
|
@ -111,7 +115,17 @@
|
|||
vf2KernelPackages = pkgs.linuxPackagesFor vf2Kernel;
|
||||
}
|
||||
else {}
|
||||
);
|
||||
) // (if system == "aarch64-linux" || system == "x86_64-linux" then {
|
||||
hydra = hydra.packages.${system}.hydra.overrideAttrs (super: {
|
||||
doCheck = false;
|
||||
patches = (super.patches or []) ++ [
|
||||
./ci/hydra/add-ca-support.patch
|
||||
./ci/hydra/add-gitea-push-hook.patch
|
||||
./ci/hydra/jobset-inputs-for-flakes.patch
|
||||
./ci/hydra/remove-hydra-size-limit.patch
|
||||
];
|
||||
});
|
||||
} else {});
|
||||
|
||||
overlays = import ./overlays;
|
||||
modules = import ./modules;
|
||||
|
|
Reference in a new issue