Skip to content

Commit

Permalink
Runs CI for all crates in workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
xfbs committed Oct 20, 2023
1 parent 6460682 commit f5f6a62
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: rustup update && rustup component add rustfmt
- run: cargo fmt -- --check
- run: cargo fmt --check --all

clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: rustup update && rustup component add clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --all-targets -- -D warnings -D clippy::all
- run: cargo clippy --all-targets --workspace -- -D warnings -D clippy::all

test:
runs-on: ubuntu-latest
Expand All @@ -29,7 +29,7 @@ jobs:
lfs: 'true'
- run: rustup update
- uses: Swatinem/rust-cache@v2
- run: cargo test
- run: cargo test --workspace
env:
RUST_BACKTRACE: 1

Expand All @@ -40,7 +40,7 @@ jobs:
- run: rustup update
- uses: Swatinem/rust-cache@v2
- run: cargo install cargo-deny || true
- run: cargo deny check
- run: cargo deny --workspace check

typos:
runs-on: ubuntu-latest
Expand Down
6 changes: 4 additions & 2 deletions registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
name = "buffrs-registry"
version = "0.1.0"
edition = "2021"
description = "Registry for buffrs, a modern protocol buffer package manager"
license = "Apache-2.0"

[dependencies]
buffrs = { path = "../" }
buffrs = { path = "../", version = "0.6.4" }
prost = "0.12.1"
tonic = "0.10.2"
clap = { version = "4.3", features = ["cargo", "derive", "env"] }
Expand All @@ -16,4 +18,4 @@ eyre = "0.6.8"
url = "2.4.1"

[build-dependencies]
buffrs = { path = "../" }
buffrs = { path = "../", version = "0.6.4" }
2 changes: 1 addition & 1 deletion registry/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ use clap::Parser;
async fn main() -> eyre::Result<()> {
let config = Options::parse();
tracing_subscriber::fmt::init();
let db = connect(&config.database.as_str()).await.unwrap();
let _db = connect(config.database.as_str()).await.unwrap();
Ok(())
}
26 changes: 17 additions & 9 deletions src/credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use miette::{miette, Context, Diagnostic, IntoDiagnostic};
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, env, path::PathBuf};
use std::{collections::HashMap, env, io::ErrorKind, path::PathBuf};
use thiserror::Error;
use tokio::fs;

Expand Down Expand Up @@ -63,14 +63,22 @@ impl Credentials {

/// Reads the credentials from the file system
pub async fn read() -> miette::Result<Self> {
let raw: RawCredentialCollection = toml::from_str(
&fs::read_to_string(location().into_diagnostic()?)
.await
.into_diagnostic()
.wrap_err(ReadError(CREDENTIALS_FILE))?,
)
.into_diagnostic()
.wrap_err(DeserializationError(ManagedFile::Credentials))?;
let location = location().into_diagnostic()?;

// if the file does not exist, we don't need to treat it as an error.
let contents = match fs::read_to_string(&location).await {
Ok(contents) => contents,
Err(error) if error.kind() == ErrorKind::NotFound => Default::default(),
Err(error) => {
return Err(error)
.into_diagnostic()
.wrap_err(ReadError(CREDENTIALS_FILE))
}
};

let raw: RawCredentialCollection = toml::from_str(&contents)
.into_diagnostic()
.wrap_err(DeserializationError(ManagedFile::Credentials))?;

Ok(raw.into())
}
Expand Down

0 comments on commit f5f6a62

Please sign in to comment.