Skip to content

Commit 9871918

Browse files
authored
Merge pull request #5 from cpu/cpu-rust-review
Small tweaks to Rust code after a review pass
2 parents 30d65e8 + 61b61dd commit 9871918

File tree

12 files changed

+165
-171
lines changed

12 files changed

+165
-171
lines changed

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: cargo
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
time: "07:00"
8+
open-pull-requests-limit: 10
9+
- package-ecosystem: "github-actions"
10+
directory: ".github/workflows"
11+
schedule:
12+
interval: "daily"
13+
time: "07:00"
14+
open-pull-requests-limit: 10

.github/workflows/rust.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Rust
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
format:
9+
name: Format
10+
runs-on: ubuntu-latest
11+
defaults:
12+
run:
13+
working-directory: ci-bench-runner
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Install rust toolchain
17+
uses: dtolnay/rust-toolchain@stable
18+
with:
19+
components: rustfmt
20+
- name: Check formatting
21+
run: cargo fmt --all -- --check
22+
23+
clippy:
24+
name: Clippy
25+
runs-on: ubuntu-latest
26+
defaults:
27+
run:
28+
working-directory: ci-bench-runner
29+
steps:
30+
- name: Checkout sources
31+
uses: actions/checkout@v4
32+
- name: Install rust toolchain
33+
uses: dtolnay/rust-toolchain@stable
34+
with:
35+
components: clippy
36+
- run: cargo clippy --locked -- --deny warnings
37+
38+
docs:
39+
name: Check for documentation errors
40+
runs-on: ubuntu-latest
41+
defaults:
42+
run:
43+
working-directory: ci-bench-runner
44+
steps:
45+
- name: Checkout sources
46+
uses: actions/checkout@v4
47+
- name: Install rust toolchain
48+
uses: dtolnay/rust-toolchain@stable
49+
- name: cargo doc
50+
run: cargo doc --locked --no-deps --document-private-items
51+
env:
52+
RUSTDOCFLAGS: -Dwarnings
53+
54+
stable:
55+
name: Stable Rust
56+
runs-on: ubuntu-latest
57+
defaults:
58+
run:
59+
working-directory: ci-bench-runner
60+
steps:
61+
- uses: actions/checkout@v4
62+
- name: Install stable rust toolchain
63+
uses: dtolnay/rust-toolchain@stable
64+
- name: Install valgrind
65+
run: sudo apt-get install -y valgrind
66+
- name: Build
67+
run: cargo build --locked --verbose
68+
- name: Run tests
69+
run: cargo test --locked --verbose

ci-bench-runner/Cargo.lock

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

ci-bench-runner/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ uuid = { version = "1.4.1", features = ["v4", "serde"] }
2727

2828
[dev-dependencies]
2929
ctor = "0.2.5"
30-
reqwest = "0.11.22"
30+
reqwest = { version = "0.11.22", default-features = false, features = ["rustls-tls-webpki-roots"] }
3131
wiremock = "0.5.19"

ci-bench-runner/build.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn main() {
2+
// In some cases if new migrations are added without accompanying Rust src changes
3+
// `cargo build` isn't smart enough to detect the need for recompilation to pick up
4+
// the new embedded migrations. This build script is the recommended workaround.
5+
// See <https://docs.rs/sqlx/latest/sqlx/macro.migrate.html#triggering-recompilation-on-migration-changes>
6+
println!("cargo:rerun-if-changed=migrations");
7+
}

ci-bench-runner/src/db.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use tokio::sync::Mutex;
1212
use uuid::Uuid;
1313

1414
/// An enqueued GitHub event
15+
#[derive(Debug)]
1516
pub struct QueuedEvent {
1617
/// An internal id for this event (i.e. not GitHub's)
1718
pub id: Uuid,
@@ -63,7 +64,7 @@ pub struct BenchJob {
6364
}
6465

6566
/// A result for a specific benchmark scenario
66-
#[derive(sqlx::FromRow)]
67+
#[derive(Debug, sqlx::FromRow)]
6768
pub struct BenchResult {
6869
/// The scenario's name
6970
pub scenario_name: String,
@@ -75,6 +76,7 @@ pub struct BenchResult {
7576
}
7677

7778
/// The results of a comparison between two branches of rustls
79+
#[derive(Debug)]
7880
pub struct ComparisonResult {
7981
/// The diffs, per scenario
8082
pub diffs: Vec<ScenarioDiff>,
@@ -123,7 +125,7 @@ impl TryFrom<i64> for ScenarioKind {
123125

124126
fn try_from(value: i64) -> Result<Self, Self::Error> {
125127
match value {
126-
0 => Ok(ScenarioKind::Icount),
128+
0 => Ok(Self::Icount),
127129
kind => bail!("invalid scenario kind: {kind}"),
128130
}
129131
}

0 commit comments

Comments
 (0)