Skip to content

Commit

Permalink
poe: updates ci, fixes nightly clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Dav1dde committed May 25, 2024
1 parent bbd8525 commit cb445d0
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 63 deletions.
48 changes: 19 additions & 29 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,39 @@ on: [workflow_dispatch, push, pull_request]

name: CI

env:
nightly: nightly

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v1
- uses: actions/checkout@v4
- run: rustup toolchain install stable --profile minimal --no-self-update
- uses: Swatinem/rust-cache@v2
- run: mkdir app/dist && touch app/dist/index.html
- uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
- name: Test
run: cargo test --all-features

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: rustfmt
override: true
- run: cargo +nightly fmt --all -- --check
- uses: actions/checkout@v4
- run: rustup toolchain install ${{ env.nightly }} --profile minimal --component rustfmt --no-self-update
- name: Rustfmt
run: cargo +nightly fmt --all -- --check


clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
override: true
- uses: Swatinem/rust-cache@v1
- uses: actions/checkout@v4
- name: Install Rust Toolchain
run: rustup toolchain install stable --profile minimal --component clippy --no-self-update
- uses: Swatinem/rust-cache@v2
- run: mkdir app/dist && touch app/dist/index.html
- run: cargo clippy --all-features -- -D warnings

- name: Clippy
run: cargo clippy --all-features -- -D warnings
12 changes: 6 additions & 6 deletions worker-sentry/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ impl Sentry {

transaction.timestamp = Some(protocol::Timestamp::now());
transaction.release = Some(git_version!().into());
transaction.request = self.request.clone();
transaction.user = self.user.clone();
transaction.breadcrumbs = self.breadcrumbs.clone();
transaction.request.clone_from(&self.request);
transaction.user.clone_from(&self.user);
transaction.breadcrumbs.clone_from(&self.breadcrumbs);
transaction
.contexts
.insert("trace".into(), protocol::Context::Trace(trace_context));
Expand Down Expand Up @@ -150,11 +150,11 @@ impl Sentry {
.as_ref()
.and_then(|t| t.0.name.to_owned())
.map(Into::into);
event.breadcrumbs = self.breadcrumbs.clone();
event.breadcrumbs.clone_from(&self.breadcrumbs);
event.release = Some(git_version!().into());
event.server_name = server_name;
event.request = self.request.clone();
event.user = self.user.clone();
event.request.clone_from(&self.request);
event.user.clone_from(&self.user);

let tc = self
.trace_context
Expand Down
23 changes: 1 addition & 22 deletions worker-sentry/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ pub fn serialize_id<S: serde::Serializer>(
}

pub mod ts_rfc3339 {
use std::fmt;

use serde::{de, ser};
use serde::ser;

use super::*;

Expand All @@ -40,25 +38,6 @@ pub mod ts_rfc3339 {
))),
}
}

pub(super) struct Rfc3339Deserializer;

impl<'de> de::Visitor<'de> for Rfc3339Deserializer {
type Value = Timestamp;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "an RFC3339 timestamp")
}

fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
let dt = OffsetDateTime::parse(v, &Rfc3339).map_err(|e| E::custom(format!("{e}")))?;
let secs = u64::try_from(dt.unix_timestamp()).map_err(|e| E::custom(format!("{e}")))?;
Ok(Timestamp::from_secs(secs))
}
}
}

pub mod ts_rfc3339_opt {
Expand Down
4 changes: 2 additions & 2 deletions worker/src/dangerous.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ impl Dangerous {
}

#[tracing::instrument(skip(self))]
pub async fn sign<T: Serialize>(&self, data: &T) -> Result<String>
pub async fn sign<T>(&self, data: &T) -> Result<String>
where
T: std::fmt::Debug,
T: Serialize + std::fmt::Debug,
{
let mut payload = serde_json::to_vec(data).map_err(|_| DangerousError::Serialize)?;

Expand Down
8 changes: 4 additions & 4 deletions worker/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ impl PartialMeta for &StoredPaste {
return;
};
meta.ascendancy_or_class = Some(this.ascendancy_or_class);
meta.main_skill_name = this.main_skill_name.clone();
meta.version = this.version.clone();
meta.main_skill_name.clone_from(&this.main_skill_name);
meta.version.clone_from(&this.version);
meta.last_modified = Some(self.last_modified);
}
}
Expand All @@ -114,8 +114,8 @@ impl PartialMeta for &shared::model::Paste {
return;
};
meta.ascendancy_or_class = Some(this.ascendancy_or_class);
meta.main_skill_name = this.main_skill_name.clone();
meta.version = this.version.clone();
meta.main_skill_name.clone_from(&this.main_skill_name);
meta.version.clone_from(&this.version);
meta.last_modified = Some(self.last_modified);
}
}
Expand Down

0 comments on commit cb445d0

Please sign in to comment.