Skip to content

Commit 9963e32

Browse files
Bump dependencies
1 parent 7037bb8 commit 9963e32

File tree

12 files changed

+881
-1323
lines changed

12 files changed

+881
-1323
lines changed

Cargo.lock

Lines changed: 741 additions & 1195 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,33 @@ name = "rust-log-analyzer"
33
version = "0.1.0"
44
authors = ["Rust Project Developers"]
55
license = "MIT"
6-
edition = "2018"
6+
edition = "2021"
77

88
[dependencies]
9-
aho-corasick = "0.6"
10-
atomicwrites = "0.2"
9+
aho-corasick = "0.7"
10+
atomicwrites = "0.4"
1111
bincode = "1.0"
12-
brotli = "1.2"
13-
digest = "0.7"
12+
brotli = "3.3"
1413
failure = "0.1"
15-
futures = "0.1"
14+
futures = "0.3"
1615
fnv = "1.0"
17-
hex = "0.3"
18-
hmac = "0.6"
19-
hyper = "0.12"
16+
hex = "0.4"
17+
hmac = "0.12"
18+
hyper = { version = "0.14.25", features = ["http1", "server", "runtime"] }
2019
lazy_static = "1.0"
21-
regex = "0.2"
22-
reqwest = "0.9"
20+
regex = "1.7.1"
21+
reqwest = { version = "0.11.14", features = ["json", "blocking"] }
2322
serde = "1.0"
2423
serde_derive = "1.0"
2524
serde_json = "1.0"
26-
sha-1 = "0.7"
25+
sha1 = "0.10"
2726
walkdir = "2.1"
28-
structopt = "0.2.16"
29-
dotenv = "0.14"
30-
crossbeam = "0.7"
27+
dotenv = "0.15"
28+
crossbeam = "0.8"
3129
percent-encoding = "2.1.0"
3230
threadpool = "1.8.1"
3331
tracing = "0.1.16"
34-
tracing-subscriber = "0.2.8"
32+
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
3533
atty = "0.2.14"
34+
clap = { version = "4.1.8", features = ["derive"] }
35+
tokio = { version = "1.26.0", features = ["rt-multi-thread", "rt"] }

src/bin/offline/dl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub fn download(
3737
only_passed: bool,
3838
only_failed: bool,
3939
) -> rla::Result<()> {
40-
let client = reqwest::Client::new();
40+
let client = reqwest::blocking::Client::new();
4141
let filter_branches = filter_branches
4242
.iter()
4343
.map(|s| s.as_str())

src/bin/rla-offline.rs

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -13,140 +13,141 @@ extern crate tracing;
1313
extern crate rust_log_analyzer as rla;
1414
extern crate walkdir;
1515

16+
use clap::Parser;
1617
use std::path::PathBuf;
17-
use structopt::StructOpt;
1818

1919
mod offline;
2020
mod util;
2121

22-
#[derive(StructOpt)]
23-
#[structopt(
22+
#[derive(Debug, Parser)]
23+
#[command(
2424
name = "Rust Log Analyzer Offline Tools",
2525
about = "A collection of tools to run the log analyzer without starting a server."
2626
)]
2727
enum Cli {
28-
#[structopt(
28+
#[command(
2929
name = "cat",
3030
about = "Read, and optionally process, a previously downloaded log file, then dump it to stdout."
3131
)]
3232
Cat {
33-
#[structopt(
34-
short = "s",
33+
#[arg(
34+
short = 's',
3535
long = "strip-control",
3636
help = "Removes all ASCII control characters, except newlines, before dumping."
3737
)]
3838
strip_control: bool,
39-
#[structopt(
40-
short = "d",
39+
#[arg(
40+
short = 'd',
4141
long = "decode-utf8",
4242
help = "Lossily decode as UTF-8 before dumping."
4343
)]
4444
decode_utf8: bool,
45-
#[structopt(help = "The log file to read and dump.")]
45+
#[arg(help = "The log file to read and dump.")]
4646
input: PathBuf,
4747
},
4848

49-
#[structopt(name = "learn", about = "Learn from previously downloaded log files.")]
49+
#[command(name = "learn", about = "Learn from previously downloaded log files.")]
5050
Learn {
51-
#[structopt(long = "ci", help = "CI platform to download from.")]
51+
#[arg(long = "ci", help = "CI platform to download from.")]
5252
ci: util::CliCiPlatform,
53-
#[structopt(
54-
short = "i",
53+
#[arg(
54+
short = 'i',
5555
long = "index-file",
5656
help = "The index file to read / write. An existing index file is updated."
5757
)]
5858
index_file: PathBuf,
59-
#[structopt(
60-
short = "m",
59+
#[arg(
60+
short = 'm',
6161
long = "multiplier",
6262
default_value = "1",
6363
help = "A multiplier to apply when learning."
6464
)]
6565
multiplier: u32,
66-
#[structopt(
66+
#[arg(
6767
help = "The log files to learn from.\nDirectories are traversed recursively. Hidden files are ignore."
6868
)]
6969
logs: Vec<PathBuf>,
7070
},
7171

72-
#[structopt(
72+
#[command(
7373
name = "extract-dir",
7474
about = "Extract potential error messages from all log files in a directory, writing the results to a different directory."
7575
)]
7676
ExtractDir {
77-
#[structopt(long = "ci", help = "CI platform to download from.")]
77+
#[arg(long = "ci", help = "CI platform to download from.")]
7878
ci: util::CliCiPlatform,
79-
#[structopt(
80-
short = "i",
79+
#[arg(
80+
short = 'i',
8181
long = "index-file",
8282
help = "The index file to read / write."
8383
)]
8484
index_file: PathBuf,
85-
#[structopt(
86-
short = "s",
85+
#[arg(
86+
short = 's',
8787
long = "source",
8888
help = "The directory in which to (non-recursively) look for log files. Hidden files are ignored."
8989
)]
9090
source: PathBuf,
91-
#[structopt(
92-
short = "d",
91+
#[arg(
92+
short = 'd',
9393
long = "destination",
9494
help = "The directory in which to write the results. All non-hidden will be deleted from the directory."
9595
)]
9696
dest: PathBuf,
9797
},
9898

99-
#[structopt(
99+
#[command(
100100
name = "extract-one",
101101
about = "Extract a potential error message from a single log file."
102102
)]
103103
ExtractOne {
104-
#[structopt(long = "ci", help = "CI platform to download from.")]
104+
#[arg(long = "ci", help = "CI platform to download from.")]
105105
ci: util::CliCiPlatform,
106-
#[structopt(
107-
short = "i",
106+
#[arg(
107+
short = 'i',
108108
long = "index-file",
109109
help = "The index file to read / write."
110110
)]
111111
index_file: PathBuf,
112-
#[structopt(help = "The log file to analyze.")]
112+
#[arg(help = "The log file to analyze.")]
113113
log: PathBuf,
114114
},
115115

116-
#[structopt(name = "dl", about = "Download build logs from the CI platform.")]
116+
#[command(name = "dl", about = "Download build logs from the CI platform.")]
117117
Dl {
118-
#[structopt(long = "ci", help = "CI platform to download from.")]
118+
#[arg(long = "ci", help = "CI platform to download from.")]
119119
ci: util::CliCiPlatform,
120-
#[structopt(long = "repo", help = "Repository to download from.")]
120+
#[arg(long = "repo", help = "Repository to download from.")]
121121
repo: String,
122-
#[structopt(short = "o", long = "output", help = "Log output directory.")]
122+
#[arg(short = 'o', long = "output", help = "Log output directory.")]
123123
output: PathBuf,
124-
#[structopt(short = "c", long = "count", help = "Number of _builds_ to process.")]
124+
#[arg(short = 'c', long = "count", help = "Number of _builds_ to process.")]
125125
count: u32,
126-
#[structopt(
127-
short = "s",
126+
#[arg(
127+
short = 's',
128128
long = "skip",
129129
default_value = "0",
130130
help = "Number of _builds_ to skip."
131131
)]
132132
skip: u32,
133-
#[structopt(
134-
short = "b",
135-
long = "branch",
136-
multiple = true,
137-
help = "Branches to filter by."
138-
)]
133+
#[arg(short = 'b', long = "branch", help = "Branches to filter by.")]
139134
branches: Vec<String>,
140-
#[structopt(long = "passed", help = "Only download passed builds and jobs.")]
135+
#[arg(long = "passed", help = "Only download passed builds and jobs.")]
141136
passed: bool,
142-
#[structopt(long = "failed", help = "Only download failed builds and jobs.")]
137+
#[arg(long = "failed", help = "Only download failed builds and jobs.")]
143138
failed: bool,
144139
},
145140
}
146141

142+
#[test]
143+
fn verify_cli() {
144+
use clap::CommandFactory;
145+
Cli::command().debug_assert()
146+
}
147+
147148
fn main() {
148149
dotenv::dotenv().ok();
149-
util::run(|| match Cli::from_args() {
150+
util::run(|| match Cli::parse() {
150151
Cli::Cat {
151152
strip_control,
152153
decode_utf8,

src/bin/rla-server.rs

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,73 +16,77 @@ extern crate regex;
1616
extern crate rust_log_analyzer as rla;
1717
extern crate serde_json;
1818

19-
use hyper::rt::Future;
19+
use clap::Parser;
2020
use std::process;
2121
use std::sync::Arc;
2222
use std::thread;
23-
use structopt::StructOpt;
2423

2524
mod server;
2625
mod util;
2726

28-
#[derive(StructOpt)]
29-
#[structopt(
27+
#[derive(Parser, Debug)]
28+
#[command(
3029
name = "Rust Log Analyzer WebHook Server",
3130
about = "A http server that listens for GitHub webhooks and posts comments with potential causes on failed builds."
3231
)]
3332
struct Cli {
34-
#[structopt(
35-
short = "p",
33+
#[arg(
34+
short = 'p',
3635
long = "port",
3736
default_value = "8080",
3837
help = "The port to listen on for HTTP connections."
3938
)]
4039
port: u16,
41-
#[structopt(
42-
short = "b",
40+
#[arg(
41+
short = 'b',
4342
long = "bind",
4443
default_value = "127.0.0.1",
4544
help = "The address to bind."
4645
)]
4746
bind: std::net::IpAddr,
48-
#[structopt(
49-
short = "i",
47+
#[arg(
48+
short = 'i',
5049
long = "index-file",
5150
help = "The index file to read / write. An existing index file is updated."
5251
)]
5352
index_file: std::path::PathBuf,
54-
#[structopt(
53+
#[arg(
5554
long = "debug-post",
5655
help = "Post all comments to the given issue instead of the actual PR. Format: \"user/repo#id\""
5756
)]
5857
debug_post: Option<String>,
59-
#[structopt(
58+
#[arg(
6059
long = "webhook-verify",
6160
help = "If enabled, web hooks that cannot be verified are rejected."
6261
)]
6362
webhook_verify: bool,
64-
#[structopt(long = "ci", help = "CI platform to interact with.")]
63+
#[arg(long = "ci", help = "CI platform to interact with.")]
6564
ci: util::CliCiPlatform,
66-
#[structopt(long = "repo", help = "Repository to interact with.")]
65+
#[arg(long = "repo", help = "Repository to interact with.")]
6766
repo: String,
68-
#[structopt(
67+
#[arg(
6968
long = "secondary-repo",
7069
help = "Secondary repositories to listen for builds.",
71-
required = false,
72-
multiple = true
70+
required = false
7371
)]
7472
secondary_repos: Vec<String>,
75-
#[structopt(
73+
#[arg(
7674
long = "query-builds-from-primary-repo",
7775
help = "Always query builds from the primary repo instead of the repo receiving them."
7876
)]
7977
query_builds_from_primary_repo: bool,
8078
}
8179

80+
#[test]
81+
fn verify_cli() {
82+
use clap::CommandFactory;
83+
Cli::command().debug_assert()
84+
}
85+
8286
fn main() {
8387
dotenv::dotenv().ok();
8488
util::run(|| {
85-
let args = Cli::from_args();
89+
let args = Cli::parse();
8690

8791
let addr = std::net::SocketAddr::new(args.bind, args.port);
8892

@@ -111,14 +115,24 @@ fn main() {
111115
process::exit(0);
112116
});
113117

114-
let server = hyper::server::Server::bind(&addr).serve(move || {
115-
let s = service.clone();
116-
hyper::service::service_fn(move |req| s.call(req))
117-
});
118+
let s = service.clone();
119+
let server =
120+
hyper::server::Server::bind(&addr).serve(hyper::service::make_service_fn(move |_| {
121+
let s = s.clone();
122+
async move {
123+
Ok::<_, hyper::Error>(hyper::service::service_fn(move |req| {
124+
let s = s.clone();
125+
async move { s.call(req).await }
126+
}))
127+
}
128+
}));
118129

119-
hyper::rt::run(server.map_err(|e| {
120-
error!("server error: {}", e);
121-
}));
130+
tokio::runtime::Runtime::new()?
131+
.block_on(server)
132+
.map_err(|e| {
133+
error!("server error: {}", e);
134+
e
135+
})?;
122136

123137
Ok(())
124138
});

0 commit comments

Comments
 (0)