All Projects → Mic92 → Nixpkgs Review

Mic92 / Nixpkgs Review

Licence: mit
Review pull-requests on https://github.com/NixOS/nixpkgs

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Nixpkgs Review

Neat Starter
Starter Template for Netlify CMS, Eleventy, Alphine JS & Tailwind CSS
Stars: ✭ 104 (-2.8%)
Mutual labels:  hacktoberfest
Ansible Role Bootstrap
Prepare your system to be managed by Ansible.
Stars: ✭ 106 (-0.93%)
Mutual labels:  hacktoberfest
Nextgrowingtextview
📝 The next in the generations of 'growing textviews' optimized for iOS 8 and above.
Stars: ✭ 1,540 (+1339.25%)
Mutual labels:  hacktoberfest
Opentelemetry Operator
Kubernetes Operator for OpenTelemetry Collector
Stars: ✭ 104 (-2.8%)
Mutual labels:  hacktoberfest
Wemake Python Styleguide
The strictest and most opinionated python linter ever!
Stars: ✭ 1,714 (+1501.87%)
Mutual labels:  hacktoberfest
Readyresponder
Local Incident Management System - This is used for tracking resources for Local Emergency Management
Stars: ✭ 106 (-0.93%)
Mutual labels:  hacktoberfest
Aixlib
A Modelica model library for building performance simulations
Stars: ✭ 104 (-2.8%)
Mutual labels:  hacktoberfest
Go Algorithms
Algorithms and data structures for golang
Stars: ✭ 1,529 (+1328.97%)
Mutual labels:  hacktoberfest
Carbon
Carbon is one of the components of Graphite, and is responsible for receiving metrics over the network and writing them down to disk using a storage backend.
Stars: ✭ 1,435 (+1241.12%)
Mutual labels:  hacktoberfest
Crawler Detect
🕷 CrawlerDetect is a PHP class for detecting bots/crawlers/spiders via the user agent
Stars: ✭ 1,549 (+1347.66%)
Mutual labels:  hacktoberfest
Excelr
An Interface to 'jExcel.js' Library
Stars: ✭ 106 (-0.93%)
Mutual labels:  hacktoberfest
Awesome Wagtail
A curated list of awesome packages, articles, and other cool resources from the Wagtail community.
Stars: ✭ 1,527 (+1327.1%)
Mutual labels:  hacktoberfest
Code With Love
Open source programming algorithms
Stars: ✭ 107 (+0%)
Mutual labels:  hacktoberfest
Go Compression.github.io
The Hitchhiker's Guide to Compression
Stars: ✭ 106 (-0.93%)
Mutual labels:  hacktoberfest
Wavedrom
🌊 Digital timing diagram rendering engine
Stars: ✭ 1,668 (+1458.88%)
Mutual labels:  hacktoberfest
Doc8
Style checker for sphinx (or other) rst documentation.
Stars: ✭ 105 (-1.87%)
Mutual labels:  hacktoberfest
Botogram
Just focus on your bots.
Stars: ✭ 106 (-0.93%)
Mutual labels:  hacktoberfest
Sir Lancebot
A Discord bot started as a community project for Hacktoberfest 2018, later evolved to an introductory project for aspiring new developers starting out with open source development.
Stars: ✭ 105 (-1.87%)
Mutual labels:  hacktoberfest
Corona
Solar2D Game Engine main repository (ex Corona SDK)
Stars: ✭ 1,679 (+1469.16%)
Mutual labels:  hacktoberfest
Rando Php
RandoPhp is a open source library that implements random generators (Integer, Char, Byte, Sequences, Boolean) and take random sample from arrays
Stars: ✭ 107 (+0%)
Mutual labels:  hacktoberfest

nixpkgs-review

Build Status

Review pull-requests on https://github.com/NixOS/nixpkgs. nixpkgs-review automatically builds packages changed in the pull requests

NOTE: this project used to be called nix-review

Features

  • ofborg support: reuses evaluation output of CI to skip local evaluation, but also fallbacks if ofborg is not finished
  • provides a nix-shell with all packages that did not fail to build
  • remote builder support
  • allows to build a subset of packages (great for mass-rebuilds)
  • allow to build nixos tests
  • markdown reports
  • GitHub integration:
    • post PR comments with results
    • approve or merge PRs (the last one requires maintainer permission)
    • Show PR comments/reviews
  • logs per built or failed package
  • symlinks built packages to result directory for inspection

Installation

nixpkgs-review is included in nixpkgs. Older versions of nixpkgs might still call it nix-review.

To use it without installing it, use:

$ nix run nixpkgs.nixpkgs-review

To install it:

$ nix-env -f '<nixpkgs>' -iA nixpkgs-review

To run it from the git repository:

$ nix-build
$ ./result/bin/nixpkgs-review

Note that this asserts formatting with the latest version of black, so you may need to specify a more up to date version of NixPkgs:

$ nix-build -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixpkgs-unstable.tar.gz
$ ./result/bin/nixpkgs-review

Development Environment

For IDEs:

$ nix-build -A env -o .venv

or just use:

./bin/nixpkgs-review

Usage

Frist, change to your local nixpkgs repository directory, i.e.:

cd ~/git/nixpkgs

Note that your local checkout git will be not affected by nixpkgs-review, since it will use git-worktree to perform fast checkouts.

Then run nixpkgs-review by providing the pull request number...

$ nixpkgs-review pr 37242

... or the full pull request url:

$ nixpkgs-review pr https://github.com/NixOS/nixpkgs/pull/37242

The output will then look as follows:

$ git fetch --force https://github.com/NixOS/nixpkgs pull/37242/head:refs/nixpkgs-review/0
$ git worktree add /home/joerg/git/nixpkgs/.review/pr-37242 1cb9f643480612696de93fb2f2a2f3340d0e3156
Preparing /home/joerg/git/nixpkgs/.review/pr-37242 (identifier pr-37242)
Checking out files: 100% (14825/14825), done.
HEAD is now at 1cb9f643480 redis: 4.0.7 -> 4.0.8
Building in /tmp/nox-review-4ml2epyy: redis
$ nix-build --no-out-link --keep-going --max-jobs 4 --option build-use-sandbox true <nixpkgs> -A redis
/nix/store/jbp7m1gshmk8an8sb14glwijgw1chvvq-redis-4.0.8
$ nix-shell -p redis
[nix-shell:~/git/nixpkgs]$ /nix/store/jbp7m1gshmk8an8sb14glwijgw1chvvq-redis-4.0.8/bin/redis-cli --version
redis-cli 4.0.8

To review a local commit without pull request, use the following command:

$ nixpkgs-review rev HEAD

Instead of HEAD also a commit or branch can be given.

To review uncommitted changes, use the following command:

$ nixpkgs-review wip

Staged changes can be reviewed like this:

$ nixpkgs-review wip --staged

If you'd like to post the nixpkgs-review results as a formatted PR comment, pass the --post-result flag:

$ nixpkgs-review pr --post-result 37242

Often, after reviewing a diff on a pull request, you may want to say "This diff looks good to me, approve/merge it provided that there are no package build failures". To do so run the following subcommands from within the nix-shell provided by nixpkgs-review

$ nixpkgs-review pr 37242
nix-shell> nixpkgs-review approve
# Or, if you have maintainer access and would like to merge (provided no build failures):
nix-shell> nixpkgs-review merge
# It is also possible to upload the result report from here
nix-shell> nixpkgs-review post-result
# Review-comments can also be shown
nix-shell> nixpkgs-review comments

Using nixpkgs-review in scripts or other programs

After building, nixpkgs-review will normally start a nix-shell with the packages built, to allow for interactive testing. To use nixpkgs-review non-interactively in scripts, use the --no-shell command, which can allow for batch processing of multiple reviews or use in scripts/bots.

Example testing multiple unrelated PRs and posting the build results as PR comments for later review:

for pr in 807{60..70}; do
    nixpkgs-review pr --no-shell --post-result $pr && echo "PR $pr succeeded" || echo "PR $pr failed"
done

nixpkgs-review also accepts a --run flag that allows to run a custom command inside the nix-shell instead of an interactive session:

$ nixpkgs-review pr --run 'jq < report.json' 113814
# ...
{
  "blacklisted": [],
  "broken": [],
  "built": [
    "cargo-deny"
  ],
  "failed": [],
  "non-existant": [],
  "pr": 113814,
  "system": "x86_64-linux",
  "tests": []
}

Review multiple pull requests at once

nixpkgs-review accept multiple pull request numbers at once:

$ nixpkgs-review pr 94524 94494 94522 94493 94520

This will first evaluate & build all pull requests in serial. Than a nix-shell will be opened for each of them after the previous shell has been closed.

Tipp: Since it's hard to keep track of the numbers, for each opened shell also the corresponding pull request url showed.

Remote builder:

Nix-review will pass all arguments given in --build-arg to nix-build:

$ nixpkgs-review pr --build-args="--builders 'ssh://[email protected]'" 37244

As an alternative one can also specify remote builder as usual in /etc/nix/machines or via the nix.buildMachines nixos options in configuration.nix. This allows to parallelize builds across multiple machines.

Github api token

Some commands (i.e. post-result or merge) require a Github API token, and even for read-only calls github returns 403 error messages if your IP hits the rate limit for unauthenticated calls.

To use a token, first create a personal access token. If you plan to post comments with the reports generated you need to add the repo:public_repo scope.

Then use either the GITHUB_TOKEN environment variable or the --token parameter of the pr subcommand.

$ GITHUB_TOKEN=5ae04810f1e9f17c3297ee4c9e25f3ac1f437c26 nixpkgs-review pr  37244

Additionally nixpkgs-review will also read the oauth_token stored by hub.

Checkout strategy (recommend for r-ryantm + cachix)

By default nixpkgs-review pr will merge the pull request into the pull request's target branch (most commonly master). However at times mass-rebuilding commits have been applied in the target branch, but not yet built by hydra. Often those are not relevant for the current review, but will significantly increase the local build time. For this case the --checkout option can specified to override the default behavior (merge). By setting its value to commit, nixpkgs-review will checkout the user's pull request branch without merging it:

$ nixpkgs-review pr --checkout commit 44534

Only building a subset of packages

To build only certain packages use the --package (or -p) flag.

$ nixpkgs-review pr -p openjpeg -p ImageMagick 49262

There is also the --package-regex option that takes a regular expression to match against the attribute name.

# build only linux kernels but not the packages
$ nixpkgs-review pr --package-regex 'linux_' 51292

To skip building certain packages use the --skip-package (or -P) flag.

$ nixpkgs-review pr -P ImageMagick 49262

There is also the --skip-package-regex option that takes a regular expression to match against the attribute name. Unlike the --package-regex option a full match is required which means you probably want to work with .* or \w+.

# skip building linux kernels but not the packages
$ nixpkgs-review pr --skip-packages-regex 'linux_.*' 51292

-p, -P, --package-regex and --skip-package-regex can be used together, in which case the matching packages will merged.

Running tests

NixOS tests can be run by using the --package feature and our nixosTests attribute set:

$ nixpkgs-review pr -p nixosTests.ferm 47077

Ignoring ofborg evaluations

By default, nixpkgs-review will use ofborg's evaluation result if available to figure out what packages need to be rebuilt. This can be turned off using --eval local, which is useful if ofborg's evaluation result is outdated. Even if using --eval ofborg, nixpkgs-review will fallback to local evaluation if ofborg's result is not (yet) available.

Review changes in personal forks

Both the rev and the wip subcommand support a --remote argument to overwrite the upstream repository URL (defaults to https://github.com/NixOS/nixpkgs). The following example will use the mayflower nixpkg's fork to fetch the branch where the changes will be merged into:

$ nixpkgs-review --remote https://github.com/mayflower/nixpkgs wip

Note that this has been not yet implemented for pull requests i.e. pr subcommand.

Review changes for other operating systems/architectures

The --system flag allows to set a system different from the current one. Note that the result nix-shell may not be able to execute all hooks correctly since the architecture/operating system mismatches.

$ nixpkgs-review --system aarch64-linux pr 98734

Roadmap

  • [ ] build on multiple platforms
  • [ ] test backports
  • [ ] show pull request description + diff during review

Run tests

Just like nixpkgs-review also the tests are lightning fast:

$ python3 -m unittest discover .

We also use python3's type hints. To check them use mypy:

$ mypy nixpkgs_review

Related projects:

  • nox-review:
    • works but is as slow as a snail: the checkout process of nox-review is slow since it requires multiple git fetches. Also it cannot make use of ofborg's evaluation
    • it only builds all packages without providing a nix-shell for review
  • niff:
    • only provides a list of packages that have changed, but does not build packages
    • also needs to evaluate changed attributes locally instead of using ofborg
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].