Hydra/ru: Difference between revisions
Created page with "Hydra - это инструмент для непрерывного интеграционного тестирования и выпуска программного обеспечения, который использует чисто функциональный язык для описания заданий сборки и их зависимостей. Непрерывная интеграция - это простая техника, позволяющая пов..." |
Updating to match new version of source page Tags: Mobile edit Mobile web edit |
||
(19 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
<languages /> | <languages /> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
{{note| Hydra is intended to be used by Nix/NixOS package developers; it is not needed to simply use NixOS.}} | |||
</div> | |||
Hydra - это инструмент для непрерывного интеграционного тестирования и выпуска программного обеспечения, который использует чисто функциональный язык для описания заданий сборки и их зависимостей. Непрерывная интеграция - это простая техника, позволяющая повысить качество процесса разработки программного обеспечения. Автоматизированная система постоянно или периодически проверяет исходный код проекта, собирает его, запускает тесты и готовит отчеты для разработчиков. Таким образом, автоматически отлавливаются различные ошибки, которые могут быть случайно зафиксированы в кодовой базе. | Hydra - это инструмент для непрерывного интеграционного тестирования и выпуска программного обеспечения, который использует чисто функциональный язык для описания заданий сборки и их зависимостей. Непрерывная интеграция - это простая техника, позволяющая повысить качество процесса разработки программного обеспечения. Автоматизированная система постоянно или периодически проверяет исходный код проекта, собирает его, запускает тесты и готовит отчеты для разработчиков. Таким образом, автоматически отлавливаются различные ошибки, которые могут быть случайно зафиксированы в кодовой базе. | ||
Официальные серверы Hydra предоставляют готовые бинарные пакеты для ускорения процесса обновления Nixpgs: Пользователям не нужно компилировать их на своих компьютерах. | |||
Руководство [https://nixos.org/hydra/manual/ | |||
Hydra] содержит обзор функциональности и возможностей Hydra, а также актуальное руководство по установке. | |||
<span id="Installation"></span> | <span id="Installation"></span> | ||
== Установка == | == Установка == | ||
Полное развертывание может быть осуществлено так: | |||
<syntaxHighlight lang=nix> | <syntaxHighlight lang=nix> | ||
services.hydra = { | services.hydra = { | ||
Line 29: | Line 27: | ||
}; | }; | ||
</syntaxHighlight> | </syntaxHighlight> | ||
<div class="mw-translate-fuzzy"> | |||
Модуль автоматически включит postgresql, если вы не измените опцию <code>services.hydra.dbi</code>. Схема базы данных будет создана автоматически службой Hydra, однако имейте в виду, что в базе данных будет храниться некоторое состояние, и полная stateless-конфигурация в настоящее время невозможна - делайте резервные копии. | |||
</div> | </div> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
* See nixos-option or the [https://search.nixos.org/options?query=services.hydra Nixos Options page] for all options | * See nixos-option or the [https://search.nixos.org/options?query=services.hydra Nixos Options page] for all options | ||
</div> | </div> | ||
<span id="Web_Configuration"></span> | |||
=== Веб-настройка === | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Hydra will provide the web interface [http://localhost:3000/ at localhost] port 3000. However you need to create a new admin user (as UNIX user <code>hydra</code>) before being able to perform any changes: | Hydra will provide the web interface [http://localhost:3000/ at localhost] port 3000. However you need to create a new admin user (as UNIX user <code>hydra</code>) before being able to perform any changes: | ||
</div> | |||
<syntaxHighlight lang=bash> | <syntaxHighlight lang=bash> | ||
# su - hydra | # su - hydra | ||
Line 44: | Line 48: | ||
--email-address 'alice@example.org' --password-prompt --role admin | --email-address 'alice@example.org' --password-prompt --role admin | ||
</syntaxHighlight> | </syntaxHighlight> | ||
</ | |||
<span id="Virtual_machine"></span> | |||
=== Виртуальная машина === | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
If not configured explicitly to do otherwise, Hydra will specify localhost as the default build machine. By default, system features enabling builds to be performed in virtual machines like "kvm" or "nixos-test" are not enabled. Such jobs will be queued indefinitely. Those options can be activated as follows: | If not configured explicitly to do otherwise, Hydra will specify localhost as the default build machine. By default, system features enabling builds to be performed in virtual machines like "kvm" or "nixos-test" are not enabled. Such jobs will be queued indefinitely. Those options can be activated as follows: | ||
</div> | |||
<syntaxHighlight lang=nix> | <syntaxHighlight lang=nix> | ||
{ | { | ||
nix.buildMachines = [ | nix.buildMachines = [ | ||
{ hostName = "localhost"; | { hostName = "localhost"; | ||
protocol = null; | |||
system = "x86_64-linux"; | system = "x86_64-linux"; | ||
supportedFeatures = ["kvm" "nixos-test" "big-parallel" "benchmark"]; | supportedFeatures = ["kvm" "nixos-test" "big-parallel" "benchmark"]; | ||
Line 60: | Line 68: | ||
} | } | ||
</syntaxHighlight> | </syntaxHighlight> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Line 75: | Line 82: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
* Type: Flake | * Type: [[Flakes|Flake]] | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
* Flake URI: an URI to a repo containing a Flake like git+https://git.myserver.net/user/repo.git | * Flake URI: an URI to a repo containing a Flake like git+https://git.myserver.net/user/repo.git | ||
</div> | </div> | ||
Line 83: | Line 93: | ||
</div> | </div> | ||
Пример вывода Flake, который заставляет Hydra собирать все пакеты, может выглядеть следующим образом: | |||
<syntaxHighlight lang=nix> | <syntaxHighlight lang=nix> | ||
{ | { | ||
Line 97: | Line 104: | ||
... | ... | ||
}; | }; | ||
hydraJobs = { | |||
hydraJobs = { | |||
inherit (self) | inherit (self) | ||
packages; | packages; | ||
Line 107: | Line 112: | ||
} | } | ||
</syntaxHighlight> | </syntaxHighlight> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Line 117: | Line 121: | ||
</div> | </div> | ||
<syntaxHighlight lang=nix> | <syntaxHighlight lang=nix> | ||
nix.settings.allowed-uris = [ | nix.settings.allowed-uris = [ | ||
Line 125: | Line 128: | ||
]; | ]; | ||
</syntaxHighlight> | </syntaxHighlight> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
== Build a single Package from nixpkgs == | |||
</div> | </div> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
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 [https://github.com/makefu/hydra-example hydra-example by makefu] and in the [https://nixos.org/hydra/manual/#idm140737315920320 Hydra Manual]. | 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 [https://github.com/makefu/hydra-example hydra-example by makefu] and in the [https://nixos.org/hydra/manual/#idm140737315920320 Hydra Manual]. | ||
</div> | </div> | ||
<span id="Imperative_Building"></span> | |||
=== Императивная Сборка === | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
These steps are required to build the <code>hello</code> package. | These steps are required to build the <code>hello</code> package. | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
# log into Hydra after creating a user with <code>hydra-create-user</code> | # log into Hydra after creating a user with <code>hydra-create-user</code> | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
# create new project | # create new project | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
* identifier: example-hello | * identifier: example-hello | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
* display name: example-hello | * display name: example-hello | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
# Actions -> Create jobset | # Actions -> Create jobset | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
* identifier: hello | * identifier: hello | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
* Nix expression: <code>release.nix</code> in <code>hydra-example</code> -> will evaluate the file release.nix in the given input | * Nix expression: <code>release.nix</code> in <code>hydra-example</code> -> will evaluate the file release.nix in the given input | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
* check interval: 60 | * check interval: 60 | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
* scheduling shares: 1 | * scheduling shares: 1 | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
* Inputs: | * Inputs: | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
Line 158: | Line 198: | ||
After creation, the jobset should be in the '''evaluation phase''' where inputs will be fetched. This phase may take some time as the complete <code>nixpkgs</code> repository needs to be downloaded before continuing. The result of the evaluation should be a single job which will get built. | After creation, the jobset should be in the '''evaluation phase''' where inputs will be fetched. This phase may take some time as the complete <code>nixpkgs</code> repository needs to be downloaded before continuing. The result of the evaluation should be a single job which will get built. | ||
</div> | </div> | ||
<span id="Declarative_Building"></span> | |||
=== Декларативная Сборка === | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Since 2016, Hydra supports declarative creation of jobsets. Check out the [https://github.com/shlevy/declarative-hydra-example example repository and description by Shea Levy]. | Since 2016, Hydra supports declarative creation of jobsets. Check out the [https://github.com/shlevy/declarative-hydra-example example repository and description by Shea Levy]. | ||
</div> | </div> | ||
Line 166: | Line 208: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
== Hydra Internals == | == Hydra Internals == | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
=== Definitions === | === Definitions === | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
This subsection provides an overview of the Hydra-specific definitions and how to configure them. | This subsection provides an overview of the Hydra-specific definitions and how to configure them. | ||
</div> | </div> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
==== Project ==== | ==== Project ==== | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
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 <code>nixpkgs</code>. It is comparable to the project definition in Jenkins. | 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 <code>nixpkgs</code>. It is comparable to the project definition in Jenkins. | ||
</div> | </div> | ||
Line 177: | Line 228: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
==== Jobsets ==== | ==== Jobsets ==== | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
A Jobset is 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. For example when a new commit onto a branch is added. Jobsets may depend on each other. | A Jobset is 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. For example when a new commit onto a branch is added. Jobsets may depend on each other. | ||
</div> | </div> | ||
Line 182: | Line 236: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
==== Job ==== | ==== Job ==== | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
A closure which will be built as part of a job set (like a single package, iso image or tarball). | A closure which will be built as part of a job set (like a single package, iso image or tarball). | ||
</div> | </div> | ||
Line 187: | Line 244: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
==== Release Set ==== | ==== Release Set ==== | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
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. | ||
</div> | </div> | ||
Line 192: | Line 252: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
==== Evaluation ==== | ==== Evaluation ==== | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
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>. | 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>. | ||
</div> | </div> | ||
<span id="Build"></span> | |||
==== Сборка ==== | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
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. | ||
</div> | </div> | ||
<span id="Known_Issues"></span> | |||
== Известные Проблемы == | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
* hydra-queue-runner sometimes gets stuck even with builds are in the queue, and the builds are not scheduled. The issue is being tracked [https://github.com/NixOS/hydra/issues/366 here]. In the meantime, a workaround is to add a cron job that regularly restarts the hydra-queue-runner systemd service. Possible fix: [https://github.com/NixOS/hydra/commit/73ca325d1c0f7914640a63764c9a6d448fde5bd0] | * hydra-queue-runner sometimes gets stuck even with builds are in the queue, and the builds are not scheduled. The issue is being tracked [https://github.com/NixOS/hydra/issues/366 here]. In the meantime, a workaround is to add a cron job that regularly restarts the hydra-queue-runner systemd service. Possible fix: [https://github.com/NixOS/hydra/commit/73ca325d1c0f7914640a63764c9a6d448fde5bd0] | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
* If you see <code>error: unexpected end-of-file</code> it can mean multiple things, some of them are: | * If you see <code>error: unexpected end-of-file</code> it can mean multiple things, some of them are: | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
# You have a miss-match between nix versions on the Hydra server and the builder | # You have a miss-match between nix versions on the Hydra server and the builder | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
# It can also mean that <code>hydra-queue-runner</code> needs privileges on the build server. Reference: [https://github.com/NixOS/nix/issues/2789] | # It can also mean that <code>hydra-queue-runner</code> needs privileges on the build server. Reference: [https://github.com/NixOS/nix/issues/2789] | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
* The default timeout for git operations is 600 seconds [https://github.com/NixOS/hydra/issues/1181], which might cause fetches of large repositories like [https://github.com/NixOS/nixpkgs nixos/nixpkgs] to fail: <code>error fetching latest change from git repo at `https://github.com/nixos/nixpkgs': timeout</code>. The timeout can be increased with the following configuration.nix snippet: | * The default timeout for git operations is 600 seconds [https://github.com/NixOS/hydra/issues/1181], which might cause fetches of large repositories like [https://github.com/NixOS/nixpkgs nixos/nixpkgs] to fail: <code>error fetching latest change from git repo at `https://github.com/nixos/nixpkgs': timeout</code>. The timeout can be increased with the following configuration.nix snippet: | ||
</div> | </div> | ||
<syntaxHighlight lang=nix> | <syntaxHighlight lang=nix> | ||
{ | { | ||
Line 219: | Line 297: | ||
} | } | ||
</syntaxHighlight> | </syntaxHighlight> | ||
</ | |||
<span id="Hydra_for_NixOS_releases"></span> | |||
== Hydra для релизов NixOS == | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Hydra is used for managing official Nix project releases. The project Hydra server: https://hydra.nixos.org/ | Hydra is used for managing official Nix project releases. The project Hydra server: https://hydra.nixos.org/ | ||
</div> | </div> | ||
Line 228: | Line 307: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Some Hydra trackers for Nix projects: | Some Hydra trackers for Nix projects: | ||
</div> | |||
* [https://hydra.nixos.org/project/nixpkgs Nixpkgs] | * [https://hydra.nixos.org/project/nixpkgs Nixpkgs] | ||
* [https://hydra.nixos.org/project/nixos NixOS] | * [https://hydra.nixos.org/project/nixos NixOS] | ||
<span id="Resources"></span> | |||
== Источники == | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
* [https://www.youtube.com/watch?v=RXV0Y5Bn-QQ Video: Setting up a Hydra Build Farm by Peter Simons (2016)] | |||
</div> | </div> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
* [https://gist.github.com/joepie91/c26f01a787af87a96f967219234a8723 Hydra Caveats by Joepie91] | * [https://gist.github.com/joepie91/c26f01a787af87a96f967219234a8723 Hydra Caveats by Joepie91] | ||
</div> | </div> |