Skip to content
/ rfcs Public
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 0000-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
feature: (fill me in with a unique ident, my_awesome_feature)
start-date: (fill me in with today's date, YYYY-MM-DD)
author: (name of the main author)
co-authors: (find a buddy later to help our with the RFC)
co-authors: (find a buddy later to help out with the RFC)
related-issues: (will contain links to implementation PRs)
---

Expand Down
86 changes: 86 additions & 0 deletions rfcs/0021-pr-testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
feature: pr-testing
start-date: 2017-11-06
author: @globin
co-authors: @grahamc
related-issues: https://github.com/NixOS/hydra/pull/516 https://github.com/mayflower/nixborg
---

# Summary
[summary]: #summary

In order to properly test Pull Requests and reduce the maintainers' workload
we need automation to build PRs on Hydra. This RFC specifies an architecture
to achieve this and contains a reference implementation.

# Motivation
[motivation]: #motivation

We currently have peaks of ~70 PRs a month at release time, this consumes an
immense amount of maintainers' time to test the PRs.

Another issue is the difficulty of testing mass-rebuilds. Only a few people
have resources for themselves to test such computation intensive builds and
Hydra access is limited to only a small amount of people.

Due to having already built all packages prior to merging this would reduce
the need for staging.

# Detailed design
[design]: #detailed-design

The general idea is to have a service which receives webhooks from github,
then requires some acknowledgement of a maintainer to build/test a PR and
Copy link
Member

@7c6f434c 7c6f434c Nov 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re: «a maintainer» — maybe add something about supporting a flexible definition of a maintainer (any NixOS project member/Nixpkgs committer or the package maintainer who doesn't yet have access) to «Future work»? Not in the main body, because this discussion should not delay checking if Hydra can build all PRs. Maybe also people who have multiple accepted commits to the package.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #19 also.

AFAIK the current implementation of that bot just has a hardcoded list of people who should be allowed access.

I think that people from the maintainers file + anyone who currently has commit access should be allowed to instruct the bot via @-mentions.

Copy link
Member Author

@globin globin Nov 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently "a maintainer" refers to a contributor with commit access, "member" in GitHub terminology, I'll clarify this. In the current test instance this doesn't work as @nixborg is not member of the NixOS GitHub org and therefore cannot read the membership status. That's why it currently has an additional hard-coded whitelist, which should be removed in the future..

subsequently schedules a jobset on Hydra.

## Details of the reference implementation at https://github.com/mayflower/nixborg
(to be moved to the NixOS github organisation if accepted)

The current implementation consists of three seperate services:
- nixborg: flask app to receive github hooks and fill a queue (currently redis, probably switching to rabbitmq in the future)
- nixborg-workers: workers consuming the queue, doing the git handling, commenting on github, HTTP requesting to nixbot-receiver
- nixbot-receiver: stdlib-dependency-only python script to be run on Hydra that calls out to hydra-update-jobset (PR: https://github.com/NixOS/hydra/pull/516)

1. the main service `nixborg` listens for `issue_comment` hooks containing `@nixborg build`
2. `nixborg` passes the hook on to the `nixborg-workers`
3. a `nixborg-worker` rebases the PR on the base branch of the PR (mainly master, staging or release-XX.XX)
4. the rebased branch gets pushed to a `pr-XXXXX` branch
5. a `nixborg-worker` HTTP calls out to the `nixbot-receiver` on Hydra with all necessary information for a jobset; this message is HMAC authenticated
6. `nixbot-receiver` passes on the information to create/update a jobset `pr-XXXXX` with the newly implemented `hydra-update-jobset` CLI utility

Some small remarks on the architecture:
- the rebasing is done in order to:
- make sure Hydra builds a commit that has been reviewed by a maintainer (currently contributer with commit access, GitHub terminology: "member")
- checks for race conditions of maintainer confirming the build vs last push
- ensure an older PR is tested based on the current state of the base branch
- `nixbot-receiver` is implemented as a stdlib-dependency-only python script not doing any logic to have a stable interface to Hydra that doesn't need to be updated
often, when iterating on nixborg and to not have a large footprint (cpu, memory, disk space)

# Alternatives
[alternatives]: #alternatives

- The Hydra jobset management could be achieved by using declarative jobsets, this does not work out currently as jobsets cannot be compared across projects
- [bors](https://bors.tech/) is the bot the Rust developers use to automate their testing with buildbot. It would have to be adapted to call out to Hydra
and currently AFAIK is not that easy to run yourself, when not using heroku. A lot of nixborg is inspired by bors.

# Unresolved questions
[unresolved]: #unresolved-questions

- Which "release.nix" should be used to test:
- We probably want to test aarch64 and x86_64-darwin, not only x86_64-linux, as only a little number of maintainers/pull requesters have access to these architectures.
- We probably want to also test NixOS module tests, especially for PRs touching these
- Can Hydra handle the additional workload by this, we probably have to start with a small number of PRs being tested to evaluate this.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That, and maybe perform initial tests only x86_64-linux? How the Hydra capacity (or maybe scaling costs, if cloud builds are used regularly — I do not know) compare across targets?


# Future work
[future]: #future-work

- "Rollup testing": Rebase a small number of PRs ontop of each other to reduce jobset creation and speedup testing
- With the addition of a webhook sent by Hydra and machine-readable status reporting by Hydra this can be extended to automatically merge PRs
- This can be combined with [drafted RFC #19, MAINTAINERS file and utility](https://github.com/NixOS/rfcs/pull/19) to allow maintainers that aren't GH org members test PRs
that only touch packages they maintain.
- A mentionbot (also see drafted RFC #19) could be handled by nixborg

# Drawbacks
[drawbacks]: #drawbacks

- Higher load on Hydra