Fix Clippy issues and add Rust checks to CI
This commit is contained in:
parent
bad7e4c102
commit
d8fbc93e4f
14
.github/workflows/build.yaml
vendored
14
.github/workflows/build.yaml
vendored
|
@ -5,6 +5,20 @@ on:
|
|||
workflow_call:
|
||||
|
||||
jobs:
|
||||
checks:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: DeterminateSystems/nix-installer-action-cache@main
|
||||
|
||||
- name: Check Rust formatting
|
||||
run: nix develop --command cargo fmt --check
|
||||
|
||||
- name: Clippy
|
||||
run: nix develop --command cargo clippy
|
||||
|
||||
|
||||
build-artifacts-X64-macOS:
|
||||
runs-on: macos-12
|
||||
steps:
|
||||
|
|
|
@ -390,8 +390,7 @@ impl Api {
|
|||
future::join_all(futures)
|
||||
.await
|
||||
.into_iter()
|
||||
.map(|join_result| join_result.unwrap())
|
||||
.collect::<Result<()>>()?;
|
||||
.try_for_each(|join_result| join_result.unwrap())?;
|
||||
|
||||
tracing::debug!("Received all chunks for cache {:?}", allocation.0);
|
||||
|
||||
|
|
|
@ -1,21 +1,17 @@
|
|||
//! Errors.
|
||||
|
||||
use std::io::Error as IoError;
|
||||
|
||||
use axum::{
|
||||
http::StatusCode,
|
||||
response::{IntoResponse, Response},
|
||||
};
|
||||
use thiserror::Error;
|
||||
|
||||
use gha_cache::api::Error as ApiError;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error("GitHub API error: {0}")]
|
||||
ApiError(#[from] ApiError),
|
||||
Api(#[from] gha_cache::api::Error),
|
||||
|
||||
#[error("Not Found")]
|
||||
NotFound,
|
||||
|
@ -24,7 +20,7 @@ pub enum Error {
|
|||
BadRequest,
|
||||
|
||||
#[error("I/O error: {0}")]
|
||||
IoError(#[from] IoError),
|
||||
Io(#[from] std::io::Error),
|
||||
|
||||
#[error("Failed to upload paths")]
|
||||
FailedToUpload,
|
||||
|
@ -34,7 +30,7 @@ impl IntoResponse for Error {
|
|||
fn into_response(self) -> Response {
|
||||
let code = match &self {
|
||||
// HACK: HTTP 418 makes Nix throw a visible error but not retry
|
||||
Self::ApiError(_) => StatusCode::IM_A_TEAPOT,
|
||||
Self::Api(_) => StatusCode::IM_A_TEAPOT,
|
||||
Self::NotFound => StatusCode::NOT_FOUND,
|
||||
Self::BadRequest => StatusCode::BAD_REQUEST,
|
||||
_ => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
|
|
|
@ -33,7 +33,7 @@ pub async fn get_store_paths() -> Result<HashSet<PathBuf>> {
|
|||
}
|
||||
|
||||
// Special paths (so far only `.links`)
|
||||
if s.starts_with(".") {
|
||||
if s.starts_with('.') {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ pub async fn get_store_paths() -> Result<HashSet<PathBuf>> {
|
|||
pub async fn upload_paths(mut paths: Vec<PathBuf>, store_uri: &str) -> Result<()> {
|
||||
// When the daemon started Nix may not have been installed
|
||||
let env_path = Command::new("sh")
|
||||
.args(&["-lc", "echo $PATH"])
|
||||
.args(["-lc", "echo $PATH"])
|
||||
.output()
|
||||
.await?
|
||||
.stdout;
|
||||
|
@ -66,8 +66,8 @@ pub async fn upload_paths(mut paths: Vec<PathBuf>, store_uri: &str) -> Result<()
|
|||
tracing::debug!("{} paths in this batch", batch.len());
|
||||
|
||||
let status = Command::new("nix")
|
||||
.args(&["--extra-experimental-features", "nix-command"])
|
||||
.args(&["copy", "--to", store_uri])
|
||||
.args(["--extra-experimental-features", "nix-command"])
|
||||
.args(["copy", "--to", store_uri])
|
||||
.args(&batch)
|
||||
.env("PATH", &env_path)
|
||||
.status()
|
||||
|
|
Loading…
Reference in a new issue