Skip to content

Commit

Permalink
update rust + run clippy (#57)
Browse files Browse the repository at this point in the history
* update rust + run clippy

* try stable

* use beta

* try alekitto/grcov

* try codecov

* remove Z flag

* remove panic

* coveralls

* remove dbg
  • Loading branch information
leshow authored Dec 2, 2024
1 parent 1bbcc41 commit 106f890
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 26 deletions.
31 changes: 16 additions & 15 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ jobs:
strategy:
matrix:
rust:
- nightly
- stable
env:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: "-Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off"
SQLX_OFFLINE: true
steps:
- name: Checkout sources
uses: actions/checkout@v2
Expand All @@ -127,25 +131,22 @@ jobs:
toolchain: ${{ matrix.rust }}
override: true
components: llvm-tools-preview
- name: Run coverage
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --exclude register_derive_impl --workspace --no-fail-fast
env:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Cinstrument-coverage -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests"
RUSTDOCFLAGS: "-Zprofile -Ccodegen-units=1 -Cinstrument-coverage -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests"
SQLX_OFFLINE: true
- name: rust-grcov
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate code coverage
id: coverage
uses: actions-rs/[email protected]
run: cargo llvm-cov --all-features --exclude register_derive_impl --workspace --no-fail-fast --lcov --output-path lcov.info
env:
SQLX_OFFLINE: true
NODE_COVERALLS_DEBUG: true
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v3
# with:
# # token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
# files: lcov.info
# fail_ci_if_error: true
- name: Coveralls upload
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ${{ steps.coverage.outputs.report }}
path-to-lcov: lcov.info
debug: true
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.77.2 as builder
FROM rust:1.83.0 as builder
# set workdir
WORKDIR /usr/src/dora
COPY . .
Expand Down
3 changes: 1 addition & 2 deletions bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ fn main() -> Result<()> {
// parses from cli or environment var
let config = cli::Config::parse();
let trace_config = trace::Config::parse(&config.dora_log)?;
debug!(?config);
debug!(?trace_config);
debug!(?config, ?trace_config);
if let Err(err) = dotenv::dotenv() {
debug!(?err, ".env file not loaded");
}
Expand Down
1 change: 0 additions & 1 deletion bin/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ fn discover_req_addr() -> Result<()> {
.target("192.168.2.1".parse::<std::net::IpAddr>().unwrap())
.port(9900_u16)
.build()?;

// create a client that sends dhcpv4 messages
let mut client = Client::<v4::Message>::new(settings);
// create DISCOVER msg with a requested IP
Expand Down
4 changes: 2 additions & 2 deletions libs/client-classification/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub struct PacketDetails<'a> {
}

// useful for testing
impl<'a> Default for PacketDetails<'a> {
impl Default for PacketDetails<'_> {
fn default() -> Self {
Self {
iface: "eth0",
Expand Down Expand Up @@ -305,7 +305,7 @@ fn split(a: String, del: &str, n: usize) -> Val {
a.split(del)
.nth(n - 1)
.map(ToString::to_string)
.unwrap_or(String::new()),
.unwrap_or_default(),
)
}

Expand Down
2 changes: 1 addition & 1 deletion libs/config/src/v4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ impl<'a> NetRangeIter<'a> {
}
}

impl<'a> Iterator for NetRangeIter<'a> {
impl Iterator for NetRangeIter<'_> {
type Item = Ipv4Addr;

// skips any IPs in exclusions
Expand Down
6 changes: 3 additions & 3 deletions libs/icmp-ping/src/icmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct EchoRequest<'a> {
pub payload: &'a [u8],
}

impl<'a> PartialEq for EchoRequest<'a> {
impl PartialEq for EchoRequest<'_> {
fn eq(&self, other: &Self) -> bool {
// ident potentially will be altered by the kernel because we use DGRAM
self.seq_cnt == other.seq_cnt && self.payload == other.payload
Expand All @@ -49,7 +49,7 @@ impl PartialEq<EchoReply> for EchoRequest<'_> {
}
}

impl<'a> Encode<Icmpv4> for EchoRequest<'a> {
impl Encode<Icmpv4> for EchoRequest<'_> {
fn encode(&self, buffer: &mut [u8]) -> Result<(), Error> {
let mut packet =
icmp::echo_request::MutableEchoRequestPacket::new(buffer).ok_or(Error::InvalidSize)?;
Expand All @@ -65,7 +65,7 @@ impl<'a> Encode<Icmpv4> for EchoRequest<'a> {
}
}

impl<'a> Encode<Icmpv6> for EchoRequest<'a> {
impl Encode<Icmpv6> for EchoRequest<'_> {
fn encode(&self, buffer: &mut [u8]) -> Result<(), Error> {
// icmpv6::MutableIcmpv6Packet does not have a way to set ident and seq_cnt, so we'll do it manually here
// set type
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.77.2
1.83.0

0 comments on commit 106f890

Please sign in to comment.