Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ jobs:
command: test
args: --all-features --no-fail-fast
env:
RUSTFLAGS: "-Zinstrument-coverage"
RUSTFLAGS: "-C instrument-coverage"
LLVM_PROFILE_FILE: "hawkbitrs-%p-%m.profraw"
- name: Install grcov
run: if [[ ! -e ~/.cargo/bin/grcov ]]; then cargo install grcov; fi
run: cargo install grcov
- name: Run grcov
run: grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "hawkbit/examples/*" --ignore "*target*" -o coverage.lcov
- name: Upload coverage to Codecov
Expand Down
19 changes: 9 additions & 10 deletions hawkbit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ repository = "https://github.com/collabora/hawkbit-rs"
documentation = "https://docs.rs/hawkbit_mock/"

[dependencies]
reqwest = { version = "0.11", features = ["json", "stream"] }
reqwest = { version = "0.12", features = ["json", "stream"] }
tokio = { version = "1.1", features = ["time", "fs"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0"
thiserror = "2.0"
url = "2.2"
strum = { version = "0.21", features = ["derive"] }
strum = { version = "0.27", features = ["derive"] }
cfg-if = "1.0"
digest = { version = "0.9", optional = true }
md-5 = { version = "0.9", optional = true }
sha-1 = { version = "0.9", optional = true }
sha2 = { version = "0.9", optional = true }
generic-array = {version = "0.14", optional = true }
digest = { version = "0.10", optional = true }
md-5 = { version = "0.10", optional = true }
sha-1 = { version = "0.10", optional = true }
sha2 = { version = "0.10", optional = true }
futures = "0.3"
bytes = "1.0"

Expand All @@ -32,12 +31,12 @@ hawkbit_mock = { path = "../hawkbit_mock/" }
structopt = "0.3"
anyhow = "1.0"
log = "0.4"
env_logger = "0.8"
env_logger = "0.11"
tempdir = "0.3"
assert_matches = "1.4"

[features]
hash-digest= ["digest", "generic-array"]
hash-digest= ["digest"]
hash-md5 = ["md-5", "hash-digest"]
hash-sha1 = ["sha-1", "hash-digest"]
hash-sha256 = ["sha2", "hash-digest"]
1 change: 1 addition & 0 deletions hawkbit/src/ddi/cancel_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl CancelAction {
}
}

#[allow(dead_code)]
#[derive(Debug, Deserialize)]
struct CancelReply {
id: String,
Expand Down
2 changes: 1 addition & 1 deletion hawkbit/src/ddi/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub(crate) async fn send_feedback_internal<T: Serialize>(
let details = details.iter().map(|m| m.to_string()).collect();
let feedback = Feedback::new(id, execution, finished, progress, details);

let reply = client.post(&url.to_string()).json(&feedback).send().await?;
let reply = client.post(url.to_string()).json(&feedback).send().await?;
reply.error_for_status()?;

Ok(())
Expand Down
42 changes: 22 additions & 20 deletions hawkbit/src/ddi/deployment_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ impl UpdatePreFetch {
}

#[derive(Debug, Deserialize)]
#[allow(dead_code)]
struct Reply {
id: String,
deployment: Deployment,
Expand Down Expand Up @@ -108,6 +109,7 @@ struct ArtifactInternal {
}

#[derive(Debug, Deserialize, Clone)]
#[allow(dead_code)]
struct Hashes {
sha1: String,
md5: String,
Expand Down Expand Up @@ -190,6 +192,7 @@ impl<'de> Deserialize<'de> for Links {
}

#[derive(Debug)]
#[allow(dead_code)]
struct Download {
content: Link,
md5sum: Option<Link>,
Expand All @@ -204,6 +207,7 @@ struct Links {
}

#[derive(Debug, Deserialize)]
#[allow(dead_code)]
struct ActionHistory {
status: String,
#[serde(default)]
Expand Down Expand Up @@ -239,7 +243,7 @@ impl Update {
}

/// An iterator on all the software chunks of the update.
pub fn chunks(&self) -> impl Iterator<Item = Chunk> {
pub fn chunks(&self) -> impl Iterator<Item = Chunk<'_>> {
let client = self.client.clone();

self.info
Expand Down Expand Up @@ -336,7 +340,7 @@ impl<'a> Chunk<'a> {
}

/// An iterator on all the artifacts of the chunk.
pub fn artifacts(&self) -> impl Iterator<Item = Artifact> {
pub fn artifacts(&self) -> impl Iterator<Item = Artifact<'_>> {
let client = self.client.clone();

self.chunk
Expand Down Expand Up @@ -396,14 +400,10 @@ impl<'a> Artifact<'a> {
.links
.https
.as_ref()
.or_else(|| self.artifact.links.http.as_ref())
.or(self.artifact.links.http.as_ref())
.expect("Missing content link in for artifact");

let resp = self
.client
.get(&download.content.to_string())
.send()
.await?;
let resp = self.client.get(download.content.to_string()).send().await?;

resp.error_for_status_ref()?;
Ok(resp)
Expand Down Expand Up @@ -503,6 +503,7 @@ impl<'a> Artifact<'a> {
}

/// A downloaded file part of a [`Chunk`].
#[allow(dead_code)]
#[derive(Debug)]
pub struct DownloadedArtifact {
file: PathBuf,
Expand Down Expand Up @@ -538,8 +539,8 @@ cfg_if::cfg_if! {
struct DownloadHasher<T>
where
T: Digest,
<T as Digest>::OutputSize: core::ops::Add,
<<T as Digest>::OutputSize as core::ops::Add>::Output: generic_array::ArrayLength<u8>,
<T as digest::OutputSizeUser>::OutputSize: core::ops::Add,
<<T as digest::OutputSizeUser>::OutputSize as core::ops::Add>::Output: digest::generic_array::ArrayLength<u8>
{
hasher: T,
expected: String,
Expand All @@ -549,8 +550,8 @@ cfg_if::cfg_if! {
impl<T> DownloadHasher<T>
where
T: Digest,
<T as Digest>::OutputSize: core::ops::Add,
<<T as Digest>::OutputSize as core::ops::Add>::Output: generic_array::ArrayLength<u8>
<T as digest::OutputSizeUser>::OutputSize: core::ops::Add,
<<T as digest::OutputSizeUser>::OutputSize as core::ops::Add>::Output: digest::generic_array::ArrayLength<u8>
{
fn update(&mut self, data: impl AsRef<[u8]>) {
self.hasher.update(data);
Expand Down Expand Up @@ -603,8 +604,8 @@ cfg_if::cfg_if! {
struct DownloadStreamHash<T>
where
T: Digest,
<T as Digest>::OutputSize: core::ops::Add,
<<T as Digest>::OutputSize as core::ops::Add>::Output: generic_array::ArrayLength<u8>,
<T as digest::OutputSizeUser>::OutputSize: core::ops::Add,
<<T as digest::OutputSizeUser>::OutputSize as core::ops::Add>::Output: digest::generic_array::ArrayLength<u8>
{
stream: Box<dyn Stream<Item = Result<Bytes, Error>> + Unpin + Send + Sync>,
hasher: DownloadHasher<T>,
Expand All @@ -613,8 +614,8 @@ cfg_if::cfg_if! {
impl<T> Stream for DownloadStreamHash<T>
where
T: Digest,
<T as Digest>::OutputSize: core::ops::Add,
<<T as Digest>::OutputSize as core::ops::Add>::Output: generic_array::ArrayLength<u8>,
<T as digest::OutputSizeUser>::OutputSize: core::ops::Add,
<<T as digest::OutputSizeUser>::OutputSize as core::ops::Add>::Output: digest::generic_array::ArrayLength<u8>,
T: Unpin,
T: Clone,
{
Expand Down Expand Up @@ -648,7 +649,7 @@ cfg_if::cfg_if! {
}
}

impl<'a> DownloadedArtifact {
impl DownloadedArtifact {
fn new(file: PathBuf, hashes: Hashes) -> Self {
Self { file, hashes }
}
Expand All @@ -661,9 +662,10 @@ impl<'a> DownloadedArtifact {
#[cfg(feature = "hash-digest")]
async fn hash<T>(&self, mut hasher: DownloadHasher<T>) -> Result<(), Error>
where
T: Digest,
<T as Digest>::OutputSize: core::ops::Add,
<<T as Digest>::OutputSize as core::ops::Add>::Output: generic_array::ArrayLength<u8>,
T: digest::Digest,
<T as digest::OutputSizeUser>::OutputSize: core::ops::Add,
<<T as digest::OutputSizeUser>::OutputSize as core::ops::Add>::Output:
digest::generic_array::ArrayLength<u8>,
{
use tokio::io::AsyncReadExt;

Expand Down
12 changes: 6 additions & 6 deletions hawkbit/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,13 @@ async fn send_deployment_feedback() {
None,
vec!["Downloading"],
);
assert_eq!(mock.hits(), 0);
assert_eq!(mock.calls(), 0);

update
.send_feedback(Execution::Proceeding, Finished::None, vec!["Downloading"])
.await
.expect("Failed to send feedback");
assert_eq!(mock.hits(), 1);
assert_eq!(mock.calls(), 1);
mock.delete();

// Send feedback with progress
Expand All @@ -257,7 +257,7 @@ async fn send_deployment_feedback() {
Some(json!({"awesome": true})),
vec!["Done"],
);
assert_eq!(mock.hits(), 0);
assert_eq!(mock.calls(), 0);

#[derive(Serialize)]
struct Progress {
Expand All @@ -274,7 +274,7 @@ async fn send_deployment_feedback() {
)
.await
.expect("Failed to send feedback");
assert_eq!(mock.hits(), 1);
assert_eq!(mock.calls(), 1);
mock.delete();
}

Expand Down Expand Up @@ -489,12 +489,12 @@ async fn cancel_action() {
Finished::None,
vec!["Cancelling"],
);
assert_eq!(mock.hits(), 0);
assert_eq!(mock.calls(), 0);

cancel_action
.send_feedback(Execution::Proceeding, Finished::None, vec!["Cancelling"])
.await
.expect("Failed to send feedback");
assert_eq!(mock.hits(), 1);
assert_eq!(mock.calls(), 1);
mock.delete();
}
2 changes: 1 addition & 1 deletion hawkbit_mock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ documentation = "https://docs.rs/hawkbit/"

[dependencies]
hawkbit = { version = "0.6.0", path = "../hawkbit/" }
httpmock = "0.5.4"
httpmock = "0.8.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Loading