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