Hydra, the Nix-based continuous build system
Find a file
Rick van Schijndel 578a3d2292 t: increase timeouts for slow commands with high load
We've seen many fails on ofborg, at lot of them ultimately appear to come down to
a timeout being hit, resulting in something like this:

Failure executing slapadd -F /<path>/slap.d -b dc=example -l /<path>/load.ldif.

Hopefully this resolves it for most cases.
I've done some endurance testing and this helps a lot.
some other commands also regularly time-out with high load:

- hydra-init
- hydra-create-user
- nix-store --delete

This should address most issues with tests randomly failing.

Used the following script for endurance testing:

```

import os
import subprocess

run_counter = 0
fail_counter = 0

while True:
    try:
        run_counter += 1
        print(f"Starting run {run_counter}")
        env = os.environ
        env["YATH_JOB_COUNT"] = "20"
        result = subprocess.run(["perl", "t/test.pl"], env=env)
        if (result.returncode != 0):
            fail_counter += 1
        print(f"Finish run {run_counter}, total fail count: {fail_counter}")
    except KeyboardInterrupt:
        print(f"Finished {run_counter} runs with {fail_counter} fails")
        break
```

In case someone else wants to do it on their system :).
Note that YATH_JOB_COUNT may need to be changed loosely based on your
cores.
I only have 4 cores (8 threads), so for others higher numbers might
yield better results in hashing out unstable tests.
2024-07-31 17:13:28 +02:00
.github test: use ubuntu-latest 2023-03-06 07:56:05 -08:00
datadog add space 2017-07-26 16:56:16 +01:00
doc Merge pull request #1227 from SuperSandro2000/gitea-push-hook 2024-07-09 14:31:10 -04:00
examples Extend Setup Information 2020-05-02 16:04:20 +02:00
foreman foreman: run the dev server with --restart and --debug 2021-12-16 10:20:25 -05:00
nixos-modules Try again to ensure hydra module is usable 2024-05-03 12:41:17 -04:00
src Merge pull request #1227 from SuperSandro2000/gitea-push-hook 2024-07-09 14:31:10 -04:00
t t: increase timeouts for slow commands with high load 2024-07-31 17:13:28 +02:00
.editorconfig Initialize a basic editorconfig 2021-08-06 14:59:40 -04:00
.gitignore Reorganize hydra modules 2024-01-25 14:55:07 -05:00
.perlcriticrc perlcritic: level 1 2021-12-14 10:24:34 -05:00
.yath.rc tests: move to t, allow yath test from root 2021-03-05 09:49:06 -08:00
configure.ac Filter out (mosts test) when !doCheck 2024-01-25 14:55:07 -05:00
COPYING hydra: revert license change 2010-03-29 14:16:46 +00:00
default.nix Simplify default.nix and shell.nix 2020-06-17 19:19:55 +02:00
flake.lock Update to Nix 2.22 2024-05-03 10:47:43 -04:00
flake.nix Try again to ensure hydra module is usable 2024-05-03 12:41:17 -04:00
hydra-api.yaml hydra-api.yaml: document all_builds (/eval/{eval-id}/builds) 2023-08-30 15:08:11 +02:00
INSTALL hydra: use autoconf/-make 2010-09-30 14:29:15 +00:00
Makefile.am Reorganize hydra modules 2024-01-25 14:55:07 -05:00
nixos-tests.nix Try again to ensure hydra module is usable 2024-05-03 12:41:17 -04:00
package.nix package: move foreman to nativeCheckInputs 2024-01-26 17:30:07 +01:00
Procfile Procfile: sort alphabetically 2021-04-05 16:10:09 +00:00
README.md README: update wiki link 2024-05-08 21:31:32 +02:00
shell.nix Remove yet another URL literal 2022-07-10 13:31:21 +02:00
version.txt Rename version to version.txt 2021-07-05 19:47:58 +01:00

Hydra

CI

Hydra is a Continuous Integration service for Nix based projects.

Installation And Setup

Note: The instructions provided below are intended to enable new users to get a simple, local installation up and running. They are by no means sufficient for running a production server, let alone a public instance.

Enabling The Service

Running Hydra is currently only supported on NixOS. The hydra module allows for an easy setup. The following configuration can be used for a simple setup that performs all builds on localhost (Please refer to the Options page for all available options):

{
  services.hydra = {
    enable = true;
    hydraURL = "http://localhost:3000";
    notificationSender = "hydra@localhost";
    buildMachinesFiles = [];
    useSubstitutes = true;
  };
}

Creating An Admin User

Once the Hydra service has been configured as above and activate you should already be able to access the UI interface at the specified URL. However some actions require an admin user which has to be created first:

$ su - hydra
$ hydra-create-user <USER> --full-name '<NAME>' \
    --email-address '<EMAIL>' --password-prompt --role admin

Afterwards you should be able to log by clicking on "Sign In" on the top right of the web interface using the credentials specified by hydra-create-user. Once you are logged in you can click "Admin -> Create Project" to configure your first project.

Creating A Simple Project And Jobset

In order to evaluate and build anything you need to create projects that contain jobsets. Hydra supports imperative and declarative projects and many different configurations. The steps below will guide you through the required steps to creating a minimal imperative project configuration.

Creating A Project

Log in as administrator, click "Admin" and select "Create project". Fill the form as follows:

  • Identifier: hello
  • Display name: hello
  • Description: hello project

Click "Create project".

Creating A Jobset

After creating a project you are forwarded to the project page. Click "Actions" and choose "Create jobset". Fill the form with the following values:

  • Identifier: hello
  • Nix expression: examples/hello.nix in hydra
  • Check interval: 60
  • Scheduling shares: 1

We have to add two inputs for this jobset. One for nixpkgs and one for hydra (which we are referencing in the Nix expression above):

  • Input name: nixpkgs

  • Type: Git checkout

  • Value: https://github.com/nixos/nixpkgs-channels nixos-20.03

  • Input name: hydra

  • Type: Git checkout

  • Value: https://github.com/nixos/hydra

Make sure State at the top of the page is set to "Enabled" and click on "Create jobset". This concludes the creation of a jobset that evaluates ./examples/hello.nix once a minute. Clicking "Evaluations" should list the first evaluation of the newly created jobset after a brief delay.

Building And Developing

Building Hydra

You can build Hydra via nix-build using the provided default.nix:

$ nix-build

Development Environment

You can use the provided shell.nix to get a working development environment:

$ nix-shell
$ autoreconfPhase
$ configurePhase # NOTE: not ./configure
$ make

Executing Hydra During Development

When working on new features or bug fixes you need to be able to run Hydra from your working copy. This can be done using foreman:

$ nix-shell
$ # hack hack
$ make
$ foreman start

Have a look at the Procfile if you want to see how the processes are being started. In order to avoid conflicts with services that might be running on your host, hydra and postgress are started on custom ports:

  • hydra-server: 63333 with the username "alice" and the password "foobar"
  • postgresql: 64444

Note that this is only ever meant as an ad-hoc way of executing Hydra during development. Please make use of the NixOS module for actually running Hydra in production.

Checking your patches

After making your changes, verify the test suite passes and perlcritic is still happy.

Start by following the steps in Development Environment.

Then, you can run the tests and the perlcritic linter together with:

$ nix-shell
$ make check

You can run a single test with:

$ nix-shell
$ yath test ./t/foo/bar.t

And you can run just perlcritic with:

$ nix-shell
$ make perlcritic

JSON API

You can also interface with Hydra through a JSON API. The API is defined in hydra-api.yaml and you can test and explore via the swagger editor

Additional Resources

License

Hydra is licensed under GPL-3.0

Icons provided free by EmojiOne.