Skip to content

Commit

Permalink
Merge pull request #444 from cole-h/2018
Browse files Browse the repository at this point in the history
2018-ification
  • Loading branch information
grahamc committed Apr 1, 2020
2 parents c2ea19f + a872255 commit 7be15ba
Show file tree
Hide file tree
Showing 50 changed files with 727 additions and 751 deletions.
323 changes: 163 additions & 160 deletions ofborg/Cargo.nix

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ofborg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.8"
authors = ["Graham Christensen <graham@grahamc.com>"]
include = ["Cargo.toml", "Cargo.lock", "src", "test-srcs", "build.rs"]
build = "build.rs"

edition = "2018"

[dependencies]
either = "1.4.0"
Expand Down
540 changes: 323 additions & 217 deletions ofborg/crates-io.nix

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ofborg/src/acl.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ofborg::systems::System;
use crate::systems::System;

pub struct ACL {
trusted_users: Vec<String>,
Expand Down
18 changes: 4 additions & 14 deletions ofborg/src/asynccmd.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
use std::thread;

use std::collections::HashMap;
use std::io;
use std::io::BufRead;
use std::io::BufReader;
use std::io::Read;
use std::process::Child;
use std::process::Command;
use std::process::ExitStatus;
use std::process::Stdio;
use std::sync::mpsc;
use std::sync::mpsc::sync_channel;
use std::sync::mpsc::{Receiver, SyncSender};
use std::thread::JoinHandle;
use std::io::{self, BufRead, BufReader, Read};
use std::process::{Child, Command, ExitStatus, Stdio};
use std::sync::mpsc::{self, sync_channel, Receiver, SyncSender};
use std::thread::{self, JoinHandle};

// Specifically set to fall under 1/2 of the AMQP library's
// SyncSender limitation.
Expand Down
18 changes: 4 additions & 14 deletions ofborg/src/bin/build-faker.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
extern crate amqp;
extern crate env_logger;
extern crate ofborg;

extern crate hubcaps;
extern crate hyper;
extern crate hyper_native_tls;

use std::env;

use ofborg::commentparser;
use ofborg::config;
use ofborg::easyamqp;
use ofborg::message::buildjob;
use ofborg::message::{Pr, Repo};
use ofborg::notifyworker;
use ofborg::notifyworker::NotificationReceiver;
use ofborg::message::{buildjob, Pr, Repo};
use ofborg::notifyworker::{self, NotificationReceiver};
use ofborg::worker;

use std::env;

fn main() {
let cfg = config::load(env::args().nth(1).unwrap().as_ref());
ofborg::setup_log();
Expand Down
15 changes: 4 additions & 11 deletions ofborg/src/bin/builder.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
extern crate amqp;
extern crate env_logger;
extern crate ofborg;

#[macro_use]
extern crate log;

use std::env;

use amqp::Basic;
use log::{log, warn};
use ofborg::checkout;
use ofborg::config;
use ofborg::easyamqp;
use ofborg::easyamqp::TypedWrappers;
use ofborg::easyamqp::{self, TypedWrappers};
use ofborg::notifyworker;
use ofborg::tasks;

use std::env;
use std::path::Path;

fn main() {
Expand Down
16 changes: 3 additions & 13 deletions ofborg/src/bin/evaluation-filter.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
extern crate amqp;
extern crate env_logger;
extern crate ofborg;

extern crate hubcaps;
extern crate hyper;
extern crate hyper_native_tls;

use std::env;

use amqp::Basic;

use ofborg::config;
use ofborg::easyamqp;
use ofborg::easyamqp::TypedWrappers;
use ofborg::easyamqp::{self, TypedWrappers};
use ofborg::tasks;
use ofborg::worker;

use std::env;

fn main() {
let cfg = config::load(env::args().nth(1).unwrap().as_ref());
ofborg::setup_log();
Expand Down
16 changes: 3 additions & 13 deletions ofborg/src/bin/github-comment-filter.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
extern crate amqp;
extern crate env_logger;
extern crate ofborg;

extern crate hubcaps;
extern crate hyper;
extern crate hyper_native_tls;

use std::env;

use amqp::Basic;

use ofborg::config;
use ofborg::easyamqp;
use ofborg::easyamqp::TypedWrappers;
use ofborg::easyamqp::{self, TypedWrappers};
use ofborg::tasks;
use ofborg::worker;

use std::env;

fn main() {
let cfg = config::load(env::args().nth(1).unwrap().as_ref());
ofborg::setup_log();
Expand Down
16 changes: 3 additions & 13 deletions ofborg/src/bin/github-comment-poster.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
extern crate amqp;
extern crate env_logger;
extern crate ofborg;

extern crate hubcaps;
extern crate hyper;
extern crate hyper_native_tls;

use std::env;

use amqp::Basic;

use ofborg::config;
use ofborg::easyamqp;
use ofborg::easyamqp::TypedWrappers;
use ofborg::easyamqp::{self, TypedWrappers};
use ofborg::tasks;
use ofborg::worker;

use std::env;

fn main() {
let cfg = config::load(env::args().nth(1).unwrap().as_ref());
ofborg::setup_log();
Expand Down
13 changes: 4 additions & 9 deletions ofborg/src/bin/log-message-collector.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
extern crate amqp;
extern crate env_logger;
extern crate ofborg;

use std::env;
use std::path::PathBuf;

use ofborg::config;
use ofborg::easyamqp;
use ofborg::easyamqp::TypedWrappers;
use ofborg::easyamqp::{self, TypedWrappers};
use ofborg::tasks;
use ofborg::worker;

use std::env;
use std::path::PathBuf;

fn main() {
let cfg = config::load(env::args().nth(1).unwrap().as_ref());
ofborg::setup_log();
Expand Down
16 changes: 5 additions & 11 deletions ofborg/src/bin/log-message-generator.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
extern crate amqp;
extern crate env_logger;
extern crate ofborg;

use std::env;
use std::thread;
use std::time::Duration;

use ofborg::message::{Pr, Repo};

use ofborg::config;
use ofborg::easyamqp;
use ofborg::message::buildjob;
use ofborg::message::{buildjob, Pr, Repo};
use ofborg::notifyworker;
use ofborg::tasks::build;

use std::env;
use std::thread;
use std::time::Duration;

fn main() {
let cfg = config::load(env::args().nth(1).unwrap().as_ref());
ofborg::setup_log();
Expand Down
16 changes: 5 additions & 11 deletions ofborg/src/bin/mass-rebuilder.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
extern crate amqp;
extern crate env_logger;
extern crate ofborg;
extern crate sys_info;

use amqp::Basic;
use ofborg::checkout;
use ofborg::config;
use ofborg::easyamqp::{self, TypedWrappers};
use ofborg::stats;
use ofborg::tasks;
use ofborg::worker;

use std::env;
use std::path::Path;
use std::process;

use amqp::Basic;
use ofborg::easyamqp;
use ofborg::easyamqp::TypedWrappers;
use ofborg::stats;
use ofborg::worker;

fn main() {
let memory_info = sys_info::mem_info().expect("Unable to get memory information from OS");

Expand Down
8 changes: 2 additions & 6 deletions ofborg/src/bin/simple-build.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
extern crate amqp;
extern crate env_logger;
extern crate ofborg;

use std::env;

use ofborg::config;
use ofborg::nix;

use std::env;
use std::fs::File;
use std::io::Read;
use std::path::Path;
Expand Down
9 changes: 2 additions & 7 deletions ofborg/src/bin/stats.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
extern crate amqp;
extern crate hyper;
extern crate ofborg;

use ofborg::{config, easyamqp, stats, tasks, worker};
use std::env;

use amqp::Basic;
use hyper::server::{Request, Response, Server};
use ofborg::easyamqp::TypedWrappers;
use ofborg::{config, easyamqp, stats, tasks, worker};

use std::env;
use std::thread;

fn main() {
Expand Down
10 changes: 4 additions & 6 deletions ofborg/src/checkout.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use md5;
use ofborg::clone;
use ofborg::clone::GitClonable;
use std::ffi::OsStr;
use std::ffi::OsString;
use crate::clone::{self, GitClonable};

use std::ffi::{OsStr, OsString};
use std::fs;
use std::io::{Error, ErrorKind};
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -253,7 +251,7 @@ impl clone::GitClonable for CachedProject {
#[cfg(test)]
mod tests {
use super::*;
use ofborg::test_scratch::TestScratch;
use crate::test_scratch::TestScratch;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};

Expand Down
1 change: 1 addition & 0 deletions ofborg/src/clone.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use fs2::FileExt;

use std::ffi::OsStr;
use std::fs;
use std::io::{Error, ErrorKind};
Expand Down
36 changes: 20 additions & 16 deletions ofborg/src/commentparser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,21 @@ pub fn parse(text: &str) -> Option<Vec<Instruction>> {
}
}

named!(normal_token(CompleteStr) -> CompleteStr,
verify!(take_while1!(|c: char| c.is_ascii_graphic()),
|s: CompleteStr| !s.0.eq_ignore_ascii_case("@grahamcofborg"))
named!(
normal_token(CompleteStr) -> CompleteStr,
verify!(
take_while1!(|c: char| c.is_ascii_graphic()),
|s: CompleteStr| !s.0.eq_ignore_ascii_case("@grahamcofborg")
)
);
named!(parse_line_impl(CompleteStr) -> Option<Vec<Instruction>>, alt!(
do_parse!(
res: ws!(many1!(ws!(preceded!(
alt!(tag_no_case!("@grahamcofborg") | tag_no_case!("@ofborg")),
alt!(
ws!(do_parse!(
named!(
parse_line_impl(CompleteStr) -> Option<Vec<Instruction>>,
alt!(
do_parse!(
res: ws!(many1!(ws!(preceded!(
alt!(tag_no_case!("@grahamcofborg") | tag_no_case!("@ofborg")),
alt!(
ws!(do_parse!(
tag!("build") >>
pkgs: ws!(many1!(map!(normal_token, |s| s.0.to_owned()))) >>
(Some(Instruction::Build(Subset::Nixpkgs, pkgs)))
Expand All @@ -40,13 +45,12 @@ named!(parse_line_impl(CompleteStr) -> Option<Vec<Instruction>>, alt!(
// it would be better to return an error so that the caller would know one of the
// commands couldn't be handled?
value!(None, many_till!(take!(1), tag_no_case!("@grahamcofborg")))
)
)))) >>
eof!() >>
(Some(res.into_iter().filter_map(|x| x).collect()))
) |
value!(None)
));
)
)))) >> eof!()
>> (Some(res.into_iter().filter_map(|x| x).collect()))
) | value!(None)
)
);

pub fn parse_line(text: &str) -> Option<Vec<Instruction>> {
match parse_line_impl(CompleteStr(text)) {
Expand Down
5 changes: 0 additions & 5 deletions ofborg/src/commitstatus.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
extern crate amqp;
extern crate env_logger;

use hubcaps;

pub struct CommitStatus<'a> {
api: hubcaps::statuses::Statuses<'a>,
sha: String,
Expand Down
7 changes: 4 additions & 3 deletions ofborg/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::acl;
use crate::nix::Nix;

use hubcaps::{Credentials, Github, InstallationTokenGenerator, JWTCredentials};
use hyper::net::HttpsConnector;
use hyper::Client;
use hyper_native_tls::NativeTlsClient;
use nix::Nix;
use ofborg::acl;
use serde_json;

use std::collections::HashMap;
use std::fs::File;
use std::io::Read;
Expand Down
6 changes: 3 additions & 3 deletions ofborg/src/easyamqp.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use amqp;
use crate::config::RabbitMQConfig;
use crate::ofborg;

use amqp::Basic;
use ofborg;
use ofborg::config::RabbitMQConfig;

pub struct ConsumeConfig {
/// Specifies the name of the queue to consume from.
Expand Down
4 changes: 1 addition & 3 deletions ofborg/src/evalchecker.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
extern crate amqp;
extern crate env_logger;
use crate::nix;

use ofborg::nix;
use std::fs::File;
use std::path::Path;

Expand Down
2 changes: 1 addition & 1 deletion ofborg/src/ghevent/issuecomment.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ofborg::ghevent::{Comment, Issue, Repository};
use crate::ghevent::{Comment, Issue, Repository};

#[derive(Serialize, Deserialize, Debug)]
pub struct IssueComment {
Expand Down

0 comments on commit 7be15ba

Please sign in to comment.