Hydra: Difference between revisions
imported>Makefu remove explicit hydra init, as |
imported>Makefu update evaluation description |
||
Line 72: | Line 72: | ||
Defines all the jobs which are described in your release. By convention a file called<code>release.nix</code> is being used. See the [https://nixos.org/hydra/manual/#idm140737315920320 Hydra manual for Build Recipes] for a thorough description of the structure. | Defines all the jobs which are described in your release. By convention a file called<code>release.nix</code> is being used. See the [https://nixos.org/hydra/manual/#idm140737315920320 Hydra manual for Build Recipes] for a thorough description of the structure. | ||
* Evaluation: | * Evaluation: | ||
The | The process of interpreting nix code into a list of <code>.drv files</code>. These files are the build recipes for all related outputs. You can introspect these files by running <code>nix show-derivation nixpkgs.hello</code> | ||
* Build: | * Build: | ||
Instantiation of a Job which is being triggered by being part of the release set | Instantiation of a Job which is being triggered by being part of the release set |
Revision as of 14:37, 27 March 2018
Hydra is a tool for continuous integration testing and software release that uses a purely functional language to describe build jobs and their dependencies. Continuous integration is a simple technique to improve the quality of the software development process. An automated system continuously or periodically checks out the source code of a project, builds it, runs tests, and produces reports for the developers. Thus, various errors that might accidentally be committed into the code base are automatically caught.
From the Hydra manual
The Hydra manual provides an overview of the functionality and features of hydra, as well as an up-to-date installation guide.
Installation
Since 2017, hydra is available as a NixOS module and therefore a full deployment can be enabled as easy as
services.hydra = {
enable = true;
hydraURL = "http://localhost:3000"; # externally visible URL
notificationSender = "hydra@localhost"; # e-mail of hydra service
# a standalone hydra will require you to unset the buildMachinesFiles list to avoid using a nonexistant /etc/nix/machines
buildMachinesFiles = [];
# you will probably also want, otherwise *everything* will be built from scratch
useSubstitutes = true;
};
The module will automatically enable postgresql if you do not change the services.hydra.dbi
option. Database layout will be created automatically by the hydra service, however keep in mind that some state will be stored in the database and a complete stateless configuration is currently not possible - do your backups.
- See nixos-option or the Nixos Options page for all options
Web Configuration
Hydra will provide the web interface at localhost port 3000. However you need to create a new admin user (as unix user hydra
) before being able to perform any changes:
$ hydra-create-user alice --full-name 'Alice Q. User' \
--email-address 'alice@example.org' --password foobar --role admin
Build a single Package from nixpkgs
Right now it is not possible to build a single package from nixpkgs with just that input. You will need to provide a supplementary repository which defines what to build. For examples you can check the hydra-example by makefu and in the Hydra Manual.
Imperative Building
These steps are required to build the hello
package.
- log into hydra after creating a user with
hydra-create-user
- create new project
- identifier: example-hello
- display name: example-hello
- Actions -> Create jobset
- identifier: hello
- Nix expression:
release.nix
inhydra-example
-> will evaluate the file release.nix in the given input - check interval: 60
- scheduling shares: 1
- Inputs:
Input Name | Type | Value | Note |
---|---|---|---|
nixpkgs | git checkout | https://github.com/nixos/nixpkgs-channels nixos-17.09 | will check out branch nixos-17.09, will be made available to the nix expression via <nixpkgs> .
|
hydra-example | git checkout | https://github.com/makefu/hydra-example | hydra-example is used by the jobset as input, release.nix is in the root directory |
After creation, the jobset should be in the evaluation phase where inputs will be fetched. This phase may take some time as the complete nixpkgs
repository needs to be downloaded before continuing. The result of the evaluation should be a single job which will get built.
Declarative Building
Since 2016, hydra supports declarative creation of jobsets. Check out the example repository and description by Shea Levy.
Hydra Internals
Definitions
This subsection provides an overview of the Hydra-specific definitions and how to configure them.
- Project:
A cluster of Jobs which are all coming from a single input (like a git checkout), the first thing you will need to create. Every Job should be able to be built independently from another. Most of the time the project maps to a single repository like nixpkgs
. It is comparable to the project definition in Jenkins
- Job Set:
A list of jobs which will be run. Often a Jobset fits to a certain branch (master, staging, stable). A jobset is defined by its inputs and will trigger if these inputs change, e.g. like a new commit onto a branch is added. Job sets may depend on each other
- Job:
A closure which will be built as part of a jobset (like a single package, iso image or tarball)
- Release Set:
Defines all the jobs which are described in your release. By convention a file calledrelease.nix
is being used. See the Hydra manual for Build Recipes for a thorough description of the structure.
- Evaluation:
The process of interpreting nix code into a list of.drv files
. These files are the build recipes for all related outputs. You can introspect these files by runningnix show-derivation nixpkgs.hello
- Build:
Instantiation of a Job which is being triggered by being part of the release set