Hydra, for Lix
Find a file
Tobias Pflug 1bcb8d0be9 Use pg_isready for readiness check
Co-authored-by: Graham Christensen <graham@grahamc.com>
2020-05-15 12:37:16 +02:00
.github/workflows Add hydra OpenAPI description (#750) 2020-05-11 10:04:46 -04:00
datadog add space 2017-07-26 16:56:16 +01:00
doc Remove the "releases" feature 2020-05-06 12:39:21 +02:00
examples Extend Setup Information 2020-05-02 16:04:20 +02:00
scripts Use pg_isready for readiness check 2020-05-15 12:37:16 +02:00
src schema/Builds: use jobset_id instead of jobset name matches 2020-05-13 10:12:56 -04:00
tests Get rid of dependency to SQLite 2020-04-16 00:42:40 +02:00
.gitignore Add runHydra shell 2020-05-15 12:37:16 +02:00
bootstrap hydra: Simplify `bootstrap'. 2011-01-14 10:52:47 +00:00
configure.ac Remove outdated email address 2020-03-31 12:58:24 +02:00
COPYING hydra: revert license change 2010-03-29 14:16:46 +00:00
default.nix Add comment about edolstra/flake-compat 2020-05-02 18:56:30 +02:00
flake.lock flake.lock: Update 2020-05-12 16:03:29 +02:00
flake.nix Use pg_ctl for readiness check 2020-05-15 12:37:16 +02:00
hydra-api.yaml Add hydra OpenAPI description (#750) 2020-05-11 10:04:46 -04:00
hydra-module.nix Merge remote-tracking branch 'origin/master' into flake 2019-09-24 19:03:18 +02:00
INSTALL hydra: use autoconf/-make 2010-09-30 14:29:15 +00:00
Makefile.am Install hydra-module.nix into $out/share/nix 2013-07-28 11:24:31 -04:00
Procfile Add runHydra shell 2020-05-15 12:37:16 +02:00
README.md README.md: info about runHydra/foreman 2020-05-15 12:37:16 +02:00
run-hydra.nix Use pg_ctl for readiness check 2020-05-15 12:37:16 +02:00
shell.nix Default to devShell in shell.nix 2020-05-15 12:37:16 +02:00
version hydra: fix tarball build, add pre suffix to tarballs 2010-09-30 15:02:42 +00: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 <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

Development Workflow

When working on new features or bug fixes you want to be able to run Hydra from your working copy. There are two ways to do this. One is better for interactive development and provides faster feedback cycles, the other is more convenient for a single test run of Hydra from the working copy (suiteable for PR reviews).

Using runHydra

Hydra can be built and executed using the runHydra shell:

$ nix-shell default.nix -A runHydra

This will spawn a shell that starts hydra-server, hydra-queue-runner, hydra-evaluator and postgres using foreman. In order to not collide with potentially existing installations running on default ports hydra and postgres are running on custom ports:

  • hydra-server: 63333
  • postgresql: 64444

Note: In some cases you may want to skip test execution. You can do so by passing doCheck false:

$ nix-shell default.nix -A runHydra --arg doCheck false

Using foreman

When you are actively working on the code, you need fast feedback cycles and thus want incremental builds. Instead of using runHydra you can just run foreman start directly in the normal nix-shell environment:

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

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.