-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Persist invited users #6
Conversation
I didn't actually test this since the setup to do so isn't easy. I think it should work but would appreciate if someone who has access to the existing infrastructure could run it. |
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.
Overall LGTM, just a few comments.
Thanks for taking initiative on this! I had been meaning to get around to it, but... y'know, life, work, holidays, yadda-yadda.
I wanted to be added to the NixOS organization and was told that wouldn't happen until this issue was closed 🙈. Thanks for the quick review @cole-h, I think I addressed all comments. |
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.
Looks pretty good to me, I'll give this a test shortly. Thank you for working on this!
One thing I'm thinking is maybe the Invited struct should receive a logger and print log messages in the error cases which right now just ?
: IO errors especially are hard to track down, and parsing can be a bit fraught, though this parsing is super simple. What do you think?
I also think we should probably export a gauge of how many entries are loaded and saved, for monitoring purposes.
Does this sound good? I can help with these things if you'd like!
@grahamc Thanks for the review. Just pushed some more changes which I think should address all your suggestions. |
It looks like it isn't quite right. Check this out, after this run the invitations list is empty and these two metrics are notable:
|
It looks like the problem is this early return: Lines 198 to 202 in c44ecfb
Lines 188 to 316 in c44ecfb
|
Locally I applied this diff: diff --git a/src/op_sync_team.rs b/src/op_sync_team.rs
index 91a7d06..37a0aac 100644
--- a/src/op_sync_team.rs
+++ b/src/op_sync_team.rs
@@ -228,7 +228,7 @@ pub fn sync_team(
if let Some(limit) = limit {
if (additions.get() + removals.get()) >= limit {
info!(logger, "Hit maximum change limit");
- return Ok(());
+ break;
}
}
match action { and am seeing saves correctly. However, I noticed the order is not stable,
so I further added this patch: diff --git a/src/invited.rs b/src/invited.rs
index 4d77e3d..aaa7704 100644
--- a/src/invited.rs
+++ b/src/invited.rs
@@ -78,9 +78,13 @@ impl Invited {
err
})?;
- let string = self
+ let mut values = self
.invited
.iter()
+ .collect::<Vec<_>>();
+ values.sort();
+ let string = values
+ .into_iter()
.map(|id| id.to_string())
.collect::<Vec<_>>()
.join("\n");
diff --git a/src/maintainers.rs b/src/maintainers.rs
index 8896cb6..74bd9b4 100644
--- a/src/maintainers.rs
+++ b/src/maintainers.rs
@@ -53,7 +53,7 @@ impl GitHubName {
}
}
-#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, Deserialize)]
+#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Copy, Clone, Deserialize)]
pub struct GitHubID(u64);
impl std::fmt::Display for GitHubID { and it is looking good from here:
What do you think about these two patches? |
LGTM. |
@grahamc I applied both your suggestions! 👍 Another alternative for the unstable ordering would have been to just use a |
Thanks, merged and applied: NixOS/rfc39-record@d6bca12 and it is working. Thank you! |
Fix #3.
An option
--invited-list
is added which takes a file path where github ids of invited users will be persisted. This is a plain text file where one github id (a number) is stored per line (this makes it easy to manually edit).