Hydra, for Lix
Find a file
Maximilian Bosch f9f5ab2fb1
Make gitea public URL configurable
Otherwise, it will be obtained from the jobset input that contains the
URL to the git repo to build.
2021-03-30 23:01:36 +02:00
.github Convert validate-openapi to a Hydra job 2021-01-03 18:47:05 +01:00
datadog
doc Make gitea public URL configurable 2021-03-30 23:01:36 +02:00
examples
foreman foreman/queue runner: run locally to avoid trust issues 2020-09-02 12:35:18 -04:00
src Make gitea public URL configurable 2021-03-30 23:01:36 +02:00
t Merge pull request #893 from grahamc/fake-channel-nested 2021-03-24 17:56:55 -04:00
.gitignore tests: move to t, allow yath test from root 2021-03-05 09:49:06 -08:00
.yath.rc tests: move to t, allow yath test from root 2021-03-05 09:49:06 -08:00
bootstrap
configure.ac tests: move to t, allow yath test from root 2021-03-05 09:49:06 -08:00
COPYING
default.nix Simplify default.nix and shell.nix 2020-06-17 19:19:55 +02:00
flake.lock Bump Nix version 2021-03-10 12:53:03 -05:00
flake.nix Make gitea public URL configurable 2021-03-30 23:01:36 +02:00
hydra-api.yaml Add endpoint to generate a shields.io badge 2020-12-25 15:05:34 +01:00
hydra-module.nix module: append application_name to HYDRA_DBI 2021-03-03 16:02:52 -08:00
INSTALL
Makefile.am tests: move to t, allow yath test from root 2021-03-05 09:49:06 -08:00
Procfile Add hydra-notify to devshell 2020-05-20 15:38:31 -04:00
README.md README: update with instructions on running tests 2021-02-23 17:26:56 -05:00
shell.nix Simplify default.nix and shell.nix 2020-06-17 19:19:55 +02:00
version

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 <PASSWORD> --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-crate-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 crate 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 adminstrator, 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 referrencing 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
$ ./bootstrap
$ 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.

Running Tests

After making your changes, verify the test suite still passes. After following the steps in Development Environment, run:

$ nix-shell
$ make check

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.