-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upstream features from r-rmcgibbo bot #187
base: master
Are you sure you want to change the base?
Conversation
d75a270
to
e5e01e6
Compare
propagatedBuildInputs = [ | ||
python3.pkgs.humanize | ||
# humanize fails to declare its dependency on septools correctly | ||
# https://github.com/NixOS/nixpkgs/pull/113060 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That PR is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that sufficient? I personally call this default.nix with nixpkgs from 20.09.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can backport this is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you be able to do that? I've never done a backport.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def pre_build_filter(attrs: List[Attr]) -> List[Attr]: | ||
for cmd in ( | ||
cmd | ||
for cmd in os.environ.get("NIXPKGS_REVIEW_PRE_BUILD_FILTER", "").split(":") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That ENV needs documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a potential area of discussion, @Mic92:
Despite being a small amount of code, for me this is the most important feature. The idea is that I want to run some code to manipulate the set of attrs
that the rest of the code deals with, to set some as skipped=True
based on a dynamic calculation that I can control. Basically a "plugin".
I can think of two possible ways to achieve this feature. One is as written, where nixpkgs-review
connects with these external plugins by environment variable and subprocesses them. A different way to do it that you might prefer would be to use import.metadata
entry_points
, which is kind of a python plugin feature. We could agree on the name of the entry point, and then this pre_build_filter
function would find the plugins by iterating over the matching entry points rather than looking through an environment variable. The big difference here would be that the plugin would execute inside the same process as the main python interpreter.
I am open to either mechanism.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will have a look this evening into this PR. Thanks for leading the review so far @SuperSandro2000 . Due to diverse requirements and languages used in the community a language-independent solution might be preferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ryantm is this something that nixpkgs-update could benefit from as well? If not what is missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some documentation to the README.md
Thanks for doing this! ❤️ |
88fcdd8
to
5b5393b
Compare
return None | ||
|
||
def upload_gist(self, name: str, content: str, description: str) -> Dict[str, Any]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add an option to use a different token for posting gists? I have them on my bot account but would like to post as me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you want to control this by providing an environment variable like GITHUB_GIST_TOKEN
that would have a higher precedence than the other mechanisms for setting the token?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats how I do it right now. Would be great if you could add this here, too :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding build logs within the comment instead of a gist? NixOS/nixpkgs#125133 (comment)
Than we don't have this issue at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems strictly worse to me. At least in my browser (firefox), there's no dedicated HTML page for files embedded within the comment, so glancing at each log requires downloading the file and navigating to the downloads folder and opening it up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.
@@ -5,6 +5,14 @@ python3.pkgs.buildPythonApplication rec { | |||
name = "nixpkgs-review"; | |||
src = ./.; | |||
buildInputs = [ makeWrapper ]; | |||
|
|||
propagatedBuildInputs = [ | |||
python3.pkgs.humanize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually I want get rid of humanize/backport again, but I can also do this later on master.
Right now we are unsetting PYTHONPATH to avoid injecting dependencies into nix-shell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you prefer if I vendor the naturaldelta
function from humanize
into this PR, or we could also do something based on wrappers so that we get python3.pkgs.humanize
on sys.path even though external settings of PYTHONPATH are ignored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vendoring the code is probably less hacky. Maybe we can also rewrite the function if it is less complex.
…tly to gist.github.com
… from which to fetch the ofborg evalation. This is not required for normal users, but can be useful when nixpkgs-review is run as part of a distributed system like r-rmcgibbo, and you want to use an ofborg evaluation that has since been invalidated by a force-push to the PR and you do not want to fall back to local evaluation.
@rmcgibbo thank you for this! ❤️ |
@rmcgibbo Can you take a look at the tests failures? I think it is unable to parse remotes that are local files. |
@Mic92 the test log has expired, please rerun it |
@Mic92 why can't I rerun the tests? |
I made a half-heared attempt to resolve the conflicts. |
I've re-based my fork onto the current top-of-tree, and tried to split my (otherwise disorganized) commits into a logical set of features. Each commit should be separate enough to review independently.
The commits are:
--post-logs
feature to post the build logs of failed packages to gist.github.com and to provide a link to the log in the github commit. In order to stay within usage restrictions of gist.github.com, this truncates the logs to 1MB if they're extremely long, and also strips out ANSI color codes. It also takes some care to try to capture stderr from thenix build
process that might be relevant. For example, hash mismatches are not reported in the log accessible vianix log
, and so you need to take other measures to capture them and associate them with the log.--prefer-edit
feature. If running nixpkgs-review from multiple systems with the same github account (e.g. aarch64-linux and x86_64-linux), this feature causes the second upload of the github comment to edit the first comment, to avoid an extra ping to each github user subscribed on the thread.nixpkgs-review
will call and external binary to filter the package set. this hook is used by the r-rmcgibbo bot to implement a dynamic form the the skip-packages feature that tries to skip packages such that the estimated build time falls within a cutoff. This is sufficiently complicated (it involves approximately solving a combinatorial optimization problem called the precedence constrained knapsack problem) that it makes sense as a hook to an external program.cc #171 @SuperSandro2000
I will ping this PR once my implementation of the pre-build-filter is available. I'm cleaning that up next.