Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/ofborg
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e2637d90196c
Choose a base ref
...
head repository: NixOS/ofborg
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: da9b84b9e359
Choose a head ref
  • 3 commits
  • 6 files changed
  • 1 contributor

Commits on Jan 24, 2019

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    grahamc Graham Christensen
    Copy the full SHA
    3cd8ea8 View commit details
  2. Create a type for queue job system types, and express build jobs dest…

    …inations in that form
    grahamc committed Jan 24, 2019

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    grahamc Graham Christensen
    Copy the full SHA
    6ddf619 View commit details
  3. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    grahamc Graham Christensen
    Copy the full SHA
    da9b84b View commit details
Showing with 178 additions and 475 deletions.
  1. +19 −9 ofborg/src/acl.rs
  2. +2 −0 ofborg/src/lib.rs
  3. +6 −0 ofborg/src/message/buildjob.rs
  4. +19 −0 ofborg/src/systems.rs
  5. +112 −460 ofborg/src/tasks/githubcommentposter.rs
  6. +20 −6 ofborg/src/tasks/massrebuilder.rs
28 changes: 19 additions & 9 deletions ofborg/src/acl.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use ofborg::systems::System;

pub struct ACL {
trusted_users: Vec<String>,
known_users: Vec<String>,
@@ -27,23 +29,31 @@ impl ACL {
self.repos.contains(&name.to_lowercase())
}

pub fn build_job_destinations_for_user_repo(
&self,
user: &str,
repo: &str,
) -> Vec<(Option<String>, Option<String>)> {
pub fn build_job_architectures_for_user_repo(&self, user: &str, repo: &str) -> Vec<System> {
if self.can_build_unrestricted(user, repo) {
vec![(Some("build-jobs".to_owned()), None)]
} else if self.can_build_restricted(user, repo) {
vec![
(None, Some("build-inputs-x86_64-linux".to_owned())),
(None, Some("build-inputs-aarch64-linux".to_owned())),
System::X8664Darwin,
System::X8664Linux,
System::Aarch64Linux,
]
} else if self.can_build_restricted(user, repo) {
vec![System::X8664Linux, System::Aarch64Linux]
} else {
vec![]
}
}

pub fn build_job_destinations_for_user_repo(
&self,
user: &str,
repo: &str,
) -> Vec<(Option<String>, Option<String>)> {
self.build_job_architectures_for_user_repo(user, repo)
.iter()
.map(|system| system.as_build_destination())
.collect()
}

pub fn can_build_restricted(&self, user: &str, repo: &str) -> bool {
if repo.to_lowercase() != "nixos/nixpkgs" {
return false;
2 changes: 2 additions & 0 deletions ofborg/src/lib.rs
Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@ pub mod nix;
pub mod notifyworker;
pub mod outpathdiff;
pub mod stats;
pub mod systems;
pub mod tagger;
pub mod tasks;
pub mod test_scratch;
@@ -69,6 +70,7 @@ pub mod ofborg {
pub use notifyworker;
pub use outpathdiff;
pub use stats;
pub use systems;
pub use tagger;
pub use tasks;
pub use test_scratch;
6 changes: 6 additions & 0 deletions ofborg/src/message/buildjob.rs
Original file line number Diff line number Diff line change
@@ -13,6 +13,12 @@ pub struct BuildJob {
pub statusreport: Option<ExchangeQueue>, // (Exchange, Routing Key)
}

#[derive(Serialize, Deserialize, Debug)]
pub struct QueuedBuildJobs {
pub job: BuildJob,
pub architectures: Vec<String>,
}

pub type ExchangeQueue = (Option<Exchange>, Option<RoutingKey>);
type Exchange = String;
type RoutingKey = String;
19 changes: 19 additions & 0 deletions ofborg/src/systems.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pub enum System {
X8664Linux,
Aarch64Linux,
X8664Darwin,
}

impl System {
pub fn to_string(&self) -> String {
match self {
System::X8664Linux => String::from("x86_64-linux"),
System::Aarch64Linux => String::from("aarch64-linux"),
System::X8664Darwin => String::from("x86_64-darwin"),
}
}

pub fn as_build_destination(&self) -> (Option<String>, Option<String>) {
(None, Some(format!("build-inputs-{}", self.to_string())))
}
}
Loading