Improve deployment after game update #92

Merged
lucas merged 2 commits from feat/deployment-improvements into master 2023-03-28 20:50:29 +02:00
2 changed files with 13 additions and 7 deletions
Showing only changes of commit 597bc77464 - Show all commits

View file

@ -8,7 +8,7 @@ use tokio::fs;
use tokio_stream::wrappers::ReadDirStream; use tokio_stream::wrappers::ReadDirStream;
#[tracing::instrument] #[tracing::instrument]
pub async fn foo<P>(path: P) -> Vec<PathBuf> pub async fn process_path<P>(path: P) -> Vec<PathBuf>
where where
P: AsRef<Path> + std::fmt::Debug, P: AsRef<Path> + std::fmt::Debug,
{ {
@ -98,7 +98,10 @@ where
I: Iterator<Item = PathBuf> + std::fmt::Debug, I: Iterator<Item = PathBuf> + std::fmt::Debug,
{ {
let tasks = paths.map(|p| async move { let tasks = paths.map(|p| async move {
match tokio::spawn(async move { foo(&p).await }).await { // Clippy doesn't understand that the block here is required to `move` in the reference.
// The task is spawned to make sure tokio can distribute these over threads.
#[allow(clippy::redundant_async_block)]
match tokio::spawn(async move { process_path(&p).await }).await {
Ok(paths) => paths, Ok(paths) => paths,
Err(err) => { Err(err) => {
tracing::error!(%err, "failed to spawn task to resolve bundle paths"); tracing::error!(%err, "failed to spawn task to resolve bundle paths");
@ -111,6 +114,9 @@ where
results.into_iter().flatten().collect() results.into_iter().flatten().collect()
} }
// `tracing::instrument` generates code that triggers this warning.
// Not much we can do to prevent that.
#[allow(clippy::let_with_type_underscore)]
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
pub fn resolve_bundle_paths<I>(paths: I) -> impl Stream<Item = PathBuf> pub fn resolve_bundle_paths<I>(paths: I) -> impl Stream<Item = PathBuf>
where where
@ -129,12 +135,12 @@ mod tests {
use tempfile::tempdir; use tempfile::tempdir;
use tokio::process::Command; use tokio::process::Command;
use super::foo; use super::process_path;
#[tokio::test] #[tokio::test]
async fn resolve_single_file() { async fn resolve_single_file() {
let path = PathBuf::from("foo"); let path = PathBuf::from("foo");
let paths = foo(&path).await; let paths = process_path(&path).await;
assert_eq!(paths.len(), 1); assert_eq!(paths.len(), 1);
assert_eq!(paths[0], path); assert_eq!(paths[0], path);
} }
@ -142,7 +148,7 @@ mod tests {
#[tokio::test] #[tokio::test]
async fn resolve_empty_directory() { async fn resolve_empty_directory() {
let dir = tempdir().expect("failed to create temporary directory"); let dir = tempdir().expect("failed to create temporary directory");
let paths = foo(dir).await; let paths = process_path(dir).await;
assert!(paths.is_empty()); assert!(paths.is_empty());
} }
@ -170,7 +176,7 @@ mod tests {
.await .await
.expect("failed to create temporary files"); .expect("failed to create temporary files");
let paths = foo(dir).await; let paths = process_path(dir).await;
assert_eq!(bundle_names.len(), paths.len()); assert_eq!(bundle_names.len(), paths.len());

@ -1 +1 @@
Subproject commit 18797c4d2a53834210fd096dd39195ce7f2bce21 Subproject commit 11c4eddaa4667ea7fffad40b034cf3fcb19fbdd3