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

tasks/eval: label package updates #503

Open
wants to merge 4 commits into
base: released
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ofborg

test

## Guidelines

1. Review the code of all PRs before triggering the bot on them.
Expand Down
54 changes: 49 additions & 5 deletions ofborg/src/tasks/eval/nixpkgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,41 @@ impl<'a> NixpkgsStrategy<'a> {
}
}

/// Takes a list of commit messages and a list of attributes in order to
/// check:
///
/// 1) if any of the commits contain the version bump indicator, `->`, at
/// the second index after splitting on whitespace; and
/// 2) if the mentioned attribute will be rebuilt.
///
/// If both of these checks return true, the `8.has: package (update)` label
/// will be added.
///
/// * `attr: 1.0.0 -> 1.1.0` will get the label
/// * `attr: move from fetchTarball -> fetchFromGitHub` will not get the
/// label
fn tag_from_commits(&self, messages: &[String], attrs: &[PackageArch]) {
for message in messages {
let message = message.replacen(':', "", 1);
let msg: Vec<&str> = message.split(char::is_whitespace).collect();

// attr: 1.0.0 -> 1.1.0
// 0 1 2 3
if msg.get(2) == Some(&"->")
&& attrs
.iter()
.map(|attr| &attr.package)
.any(|pkg| msg.get(0) == Some(&pkg.as_ref()))
{
update_labels(
&self.issue_ref,
&[String::from("8.has: package (update)")],
&[],
);
}
}
}

fn check_stdenvs_before(&mut self, dir: &Path) {
let mut stdenvs = Stdenvs::new(self.nix.clone(), dir.to_path_buf());
stdenvs.identify_before();
Expand Down Expand Up @@ -379,13 +414,22 @@ impl<'a> EvaluationStrategy for NixpkgsStrategy<'a> {
let changed_paths = co
.files_changed_from_head(&self.job.pr.head_sha)
.unwrap_or_else(|_| vec![]);
self.changed_paths = Some(changed_paths);
let commit_messages = co
.commit_messages_from_head(&self.job.pr.head_sha)
.unwrap_or_else(|_| vec!["".to_owned()]);

if let Some(ref rebuildsniff) = self.outpath_diff {
Copy link
Member

Choose a reason for hiding this comment

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

I think this needs to move to after_merge, since OutPathDiff::find_after is called there. Before that point only the original package outputs are available which is not enough to calculate the diff.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ack, you're probably right. I'll need to find a way to get the commit message(s) in there, then.

if let Some(attrs) = rebuildsniff.calculate_rebuild() {
if !attrs.is_empty() {
self.tag_from_commits(&commit_messages, &attrs);
}
}
}

self.tag_from_paths();

self.touched_packages = Some(parse_commit_messages(
&co.commit_messages_from_head(&self.job.pr.head_sha)
.unwrap_or_else(|_| vec!["".to_owned()]),
));
self.changed_paths = Some(changed_paths);
self.touched_packages = Some(parse_commit_messages(&commit_messages));

Ok(())
}
Expand Down