Skip to content

Commit 67a1423

Browse files
authored
Basic ci (#10)
* cleanup * basic ci * clippy * dependency
1 parent 4ad68c6 commit 67a1423

File tree

11 files changed

+104
-107
lines changed

11 files changed

+104
-107
lines changed

.github/workflows/ci.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
format:
9+
name: Format
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- uses: dtolnay/rust-toolchain@stable
15+
with:
16+
components: rustfmt
17+
18+
- name: Check format
19+
run: |
20+
cargo fmt --all -- --check
21+
22+
clippy:
23+
name: Clippy
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- uses: dtolnay/rust-toolchain@stable
30+
with:
31+
components: clippy
32+
33+
- name: Install dependencies
34+
run: |
35+
sudo apt-get update;
36+
DEBIAN_FRONTEND=noninteractive sudo apt-get install --no-install-recommends -yq libfontconfig1-dev
37+
38+
- name: Run clippy
39+
run: |
40+
cargo clippy -- -D warnings
41+
42+
check:
43+
name: Check
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Checkout repository
47+
uses: actions/checkout@v4
48+
49+
- uses: dtolnay/rust-toolchain@stable
50+
51+
- name: Install dependencies
52+
run: |
53+
sudo apt-get update;
54+
DEBIAN_FRONTEND=noninteractive sudo apt-get install --no-install-recommends -yq libfontconfig1-dev
55+
56+
- name: Check
57+
run: |
58+
cargo check
59+
60+
test:
61+
name: Test
62+
runs-on: ubuntu-latest
63+
steps:
64+
- name: Checkout repository
65+
uses: actions/checkout@v4
66+
67+
- uses: dtolnay/rust-toolchain@stable
68+
69+
- name: Install dependencies
70+
run: |
71+
sudo apt-get update;
72+
DEBIAN_FRONTEND=noninteractive sudo apt-get install --no-install-recommends -yq libfontconfig1-dev
73+
74+
- name: Test
75+
run: |
76+
cargo test

results/9/c994bdf71a39c3f29067aba4e1be0c2542894881/compile-time.stats/build-16.json

Lines changed: 0 additions & 38 deletions
This file was deleted.

results/9/c994bdf71a39c3f29067aba4e1be0c2542894881/compile-time.stats/build-8.json

Lines changed: 0 additions & 38 deletions
This file was deleted.

results/9/c994bdf71a39c3f29067aba4e1be0c2542894881/stats.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/bin/collect.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ enum Commands {
4141
}
4242

4343
impl Commands {
44+
#[allow(clippy::wrong_self_convention)]
4445
fn to_metrics(self, recur: bool) -> Vec<Box<dyn Metrics>> {
4546
match self {
4647
Commands::BinarySize { example } => {
@@ -58,8 +59,7 @@ impl Commands {
5859
Commands::All => {
5960
if recur {
6061
Commands::iter()
61-
.map(|command| command.to_metrics(false))
62-
.flatten()
62+
.flat_map(|command| command.to_metrics(false))
6363
.collect()
6464
} else {
6565
vec![]
@@ -96,7 +96,7 @@ fn main() {
9696
let metrics_to_run = cli.command.to_metrics(true);
9797

9898
let output_prefix = Path::new(&cli.out)
99-
.join(commit.chars().nth(0).unwrap().to_string())
99+
.join(commit.chars().next().unwrap().to_string())
100100
.join(commit.chars().nth(1).unwrap().to_string())
101101
.join(&commit);
102102

src/bin/graphs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use twitcher::stats::{Stats, find_stats_files};
1010

1111
fn main() -> Result<(), Box<dyn std::error::Error>> {
1212
fs::create_dir_all("graphs").unwrap();
13-
let stats: Vec<Stats> = find_stats_files(&Path::new("results"))
13+
let stats: Vec<Stats> = find_stats_files(Path::new("results"))
1414
.iter()
1515
.map(|path| {
1616
let file = File::open(path).unwrap();
@@ -21,7 +21,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
2121

2222
let keys: HashSet<_> = stats.iter().flat_map(|stat| stat.metrics.keys()).collect();
2323
for metric in keys {
24-
println!("Metric: {}", metric);
24+
println!("Metric: {metric}");
2525
let mut data = stats
2626
.iter()
2727
.flat_map(|stat| {
@@ -40,7 +40,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
4040
let min = data.iter().min_by_key(|d| d.2).unwrap().2;
4141
let max = data.iter().max_by_key(|d| d.2).unwrap().2;
4242

43-
let out = format!("graphs/{}.svg", metric);
43+
let out = format!("graphs/{metric}.svg");
4444

4545
let root = SVGBackend::new(&out, (1536, 512)).into_drawing_area();
4646
root.fill(&WHITE)?;
@@ -58,7 +58,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
5858
.unwrap();
5959

6060
root.present().expect("Unable to write result to file, please make sure 'plotters-doc-data' dir exists under current dir");
61-
println!("Result has been saved to {}", out);
61+
println!("Result has been saved to {out}");
6262
}
6363

6464
Ok(())

src/bin/index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn main() {
88
// Prepare the context with some data
99
let mut context = tera::Context::new();
1010

11-
let stats: Stats = find_stats_files(&Path::new("results"))
11+
let stats: Stats = find_stats_files(Path::new("results"))
1212
.first()
1313
.map(|path| {
1414
let file = File::open(path).unwrap();

src/binary_size.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub struct BinarySize {
1111
impl BinarySize {
1212
pub fn on(example_name: String) -> Self {
1313
Self {
14-
example_name: if example_name == "" {
14+
example_name: if example_name.is_empty() {
1515
"breakout".to_string()
1616
} else {
1717
example_name

src/compile_time.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct CompileTime {
1616
impl CompileTime {
1717
pub fn on(example_name: String, nb_jobs: u32) -> Self {
1818
Self {
19-
example_name: if example_name == "" {
19+
example_name: if example_name.is_empty() {
2020
"breakout".to_string()
2121
} else {
2222
example_name
@@ -57,7 +57,7 @@ impl Metrics for CompileTime {
5757
self.nb_jobs
5858
);
5959
let results: Hyperfine = serde_json::from_reader(
60-
std::fs::File::open(&format!("build-{}.json", self.nb_jobs)).unwrap(),
60+
std::fs::File::open(format!("build-{}.json", self.nb_jobs)).unwrap(),
6161
)
6262
.unwrap();
6363
HashMap::from([

src/crate_compile_time.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl Metrics for CrateCompileTime {
7979
);
8080

8181
let timings: HashMap<String, Vec<CrateTiming>> = serde_json::from_reader(
82-
std::fs::File::open(&format!("crate-stats-{}.json", self.nb_jobs)).unwrap(),
82+
std::fs::File::open(format!("crate-stats-{}.json", self.nb_jobs)).unwrap(),
8383
)
8484
.unwrap();
8585
timings
@@ -91,51 +91,51 @@ impl Metrics for CrateCompileTime {
9191
statistical::mean(&durations);
9292
vec![
9393
(
94-
format!("{}.{}.mean", key, crate_name),
94+
format!("{key}.{crate_name}.mean"),
9595
(statistical::mean(&durations) * 1000.0) as u64,
9696
),
9797
(
98-
format!("{}.{}.median", key, crate_name),
98+
format!("{key}.{crate_name}.median"),
9999
(statistical::median(&durations) * 1000.0) as u64,
100100
),
101101
(
102-
format!("{}.{}.min", key, crate_name),
102+
format!("{key}.{crate_name}.min"),
103103
(durations.iter().map(|d| (d * 1000.0) as u64).min().unwrap()),
104104
),
105105
(
106-
format!("{}.{}.max", key, crate_name),
106+
format!("{key}.{crate_name}.max"),
107107
(durations.iter().map(|d| (d * 1000.0) as u64).max().unwrap()),
108108
),
109109
(
110-
format!("{}.{}.std_dev", key, crate_name),
110+
format!("{key}.{crate_name}.std_dev"),
111111
(statistical::standard_deviation(&durations, None) * 1000.0) as u64,
112112
),
113113
(
114-
format!("{}.{}.rmeta-mean", key, crate_name),
114+
format!("{key}.{crate_name}.rmeta-mean"),
115115
(statistical::mean(&rmeta_times) * 1000.0) as u64,
116116
),
117117
(
118-
format!("{}.{}.rmeta-median", key, crate_name),
118+
format!("{key}.{crate_name}.rmeta-median"),
119119
(statistical::median(&rmeta_times) * 1000.0) as u64,
120120
),
121121
(
122-
format!("{}.{}.rmeta-min", key, crate_name),
122+
format!("{key}.{crate_name}.rmeta-min"),
123123
(rmeta_times
124124
.iter()
125125
.map(|d| (d * 1000.0) as u64)
126126
.min()
127127
.unwrap()),
128128
),
129129
(
130-
format!("{}.{}.rmeta-max", key, crate_name),
130+
format!("{key}.{crate_name}.rmeta-max"),
131131
(rmeta_times
132132
.iter()
133133
.map(|d| (d * 1000.0) as u64)
134134
.max()
135135
.unwrap()),
136136
),
137137
(
138-
format!("{}.{}.rmeta-std_dev", key, crate_name),
138+
format!("{key}.{crate_name}.rmeta-std_dev"),
139139
(statistical::standard_deviation(&rmeta_times, None) * 1000.0) as u64,
140140
),
141141
]

0 commit comments

Comments
 (0)