Skip to content
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

Experiment/maintainer ping #293

Merged
merged 13 commits into from Jan 3, 2019
Merged

Experiment/maintainer ping #293

merged 13 commits into from Jan 3, 2019

Conversation

grahamc
Copy link
Member

@grahamc grahamc commented Jan 1, 2019

Ping maintainers based on the algorithm:

  1. identify all the files changed by a PR
  2. identify all the attributes changed by a PR
  3. identify the file which defines each changed attribute
  4. filter out all attributes whose containing file is not modified by the PR
  5. ping those attributes' maintainers

Presently it is "no-op": posting the list of packages under the grahamcofborg-eval-check-maintainers check to a gist and not pinging anyone. After a few days of "burning in" and seeing how it goes, I plan on actually pinging people.

Here is a demo: NixOS/nixpkgs#53142

output: https://gist.github.com/GrahamcOfBorg/fa9a84d85a7ad2633df025f2735dfa22

@tilpner
Copy link
Member

tilpner commented Jan 2, 2019

Does it need to say pkgs. for every single entry?

@grahamc
Copy link
Member Author

grahamc commented Jan 2, 2019

No, removed in 8c2a87a. Thanks!

use ofborg::nix::Nix;
use std::path::Path;
use tempfile::NamedTempFile;
use std::io::Write;
Copy link
Member

Choose a reason for hiding this comment

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

What's your import ordering system? It looks either random or append-to-bottom


impl ImpactedMaintainers {
pub fn calculate(nix: &Nix, checkout: &Path, paths: &Vec<String>, attributes: &
Vec<Vec<&str>>) -> Result<ImpactedMaintainers, CalculationError> {
Copy link
Member

Choose a reason for hiding this comment

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

&Vec is never what you want, use &[...]

.checkout_ref(&OsStr::new(&hash))
.unwrap();

let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned());
Copy link
Member

Choose a reason for hiding this comment

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

It's very subjective, but I prefer String::new(). I haven't checked whether "".to_owned() gets away with not heap allocations, but String::new() does. Feel free to ignore

attrargs.push(argstr.to_owned());
}

return self.safe_command(Operation::Evaluate, nixpkgs, attrargs, extra_paths);
Copy link
Member

Choose a reason for hiding this comment

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

Unnecessary return

@@ -150,7 +161,26 @@ impl Nix {
attrargs.push(attr);
}

return self.safe_command(Operation::Instantiate, nixpkgs, attrargs);
return self.safe_command(Operation::Instantiate, nixpkgs, attrargs, vec![]);
Copy link
Member

Choose a reason for hiding this comment

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

Unnecessary return

Copy link
Member

@FRidh FRidh left a comment

Choose a reason for hiding this comment

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

The algorithm looks good to me.

{ changedattrsjson, changedpathsjson }:
let
pkgs = import ./. {};

Copy link
Member

Choose a reason for hiding this comment

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

maybe a with pkgs.lib; with builtins; to improve the readability. Namespacing is typically good, but I don't think it's worth it here. Or do you want to keep track of what's provided by lib since it's vendored?

matching = builtins.filter
(changed: pkgs.lib.strings.hasSuffix changed filename)
changedpaths;
in (builtins.length matching) > 0;
Copy link
Member

Choose a reason for hiding this comment

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

( isEmpty = list: (length list) == 0 function in lib would be nice :) )

})
changedattrs;

validPackageAttributes = builtins.filter
Copy link
Member

Choose a reason for hiding this comment

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

indentation changes

Copy link
Member Author

Choose a reason for hiding this comment

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

Wishing for a nice nixfmt :)

)
enrichedAttrs;

attrsWithPackages = builtins.map
Copy link
Member

Choose a reason for hiding this comment

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

indentation changes

@7c6f434c
Copy link
Member

7c6f434c commented Jan 2, 2019 via email

@FRidh
Copy link
Member

FRidh commented Jan 2, 2019

@7c6f434c those cases the algorithm indeed won't cache.

As a work-around, we may continue on 4) with:

  • if an attribute doesn't have a transitive parent that is already in the result of 4), then extend 4) with that one. I think a breadth first search is needed for this.

It won't solve it entirely, but I don't think we can do any better than that.

@7c6f434c
Copy link
Member

7c6f434c commented Jan 2, 2019 via email

@grahamc
Copy link
Member Author

grahamc commented Jan 2, 2019

The current algorithm says an attribute is changed if the derivation it points to changed.

@grahamc
Copy link
Member Author

grahamc commented Jan 3, 2019

I've rebased this on top of my branch where I rustfmt'd and cargo clippy'd the codebase, and formatted the Nix code with the changes in nix-mode at NixOS/nix-mode#61. I'm thinking I'll probably deploy this in the morning unless someone would like to review it more carefully.

@grahamc grahamc merged commit 6912713 into released Jan 3, 2019
@grahamc grahamc deleted the experiment/maintainer-ping branch January 3, 2019 13:24
@grahamc
Copy link
Member Author

grahamc commented Jan 3, 2019

For people having questions about how ofborg handles' all-packages.nix: NixOS/nixpkgs#53281

it didn't ping anyone because the change was only in all-packages.nix.

@7c6f434c
Copy link
Member

7c6f434c commented Apr 5, 2019

OK, so we do need a combination of all-packages.nix defined packages, and a mass rebuild, to trigger weird behaviour. Although indeed src for an override defined in all-packages.nix is unfortunate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants