From 6ddf191494ef1217ec4ce3de43994275a42ce9b8 Mon Sep 17 00:00:00 2001 From: Sebastian Galkin Date: Mon, 3 Feb 2025 15:45:20 -0300 Subject: [PATCH] Windows test --- .github/workflows/windows-check.yml | 54 ++++++++++++++++++++++++++++ icechunk/src/storage/mod.rs | 19 +++++++++- icechunk/src/storage/object_store.rs | 4 ++- 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/windows-check.yml diff --git a/.github/workflows/windows-check.yml b/.github/workflows/windows-check.yml new file mode 100644 index 00000000..130a35a9 --- /dev/null +++ b/.github/workflows/windows-check.yml @@ -0,0 +1,54 @@ +name: Windows tests +on: + pull_request: + types: [opened, reopened, synchronize, labeled] + push: + branches: + - main + +env: + CARGO_INCREMENTAL: 0 + CARGO_NET_RETRY: 10 + CI: 1 + RUST_BACKTRACE: short + RUSTFLAGS: "-D warnings -W unreachable-pub -W bare-trait-objects" + RUSTUP_MAX_RETRIES: 10 + +jobs: + rust: + name: Run rust tests in windows + timeout-minutes: 20 + runs-on: windows-latest + #defaults: + # run: + # working-directory: ./ + #permissions: + #contents: read + #actions: read + #pull-requests: read + env: + #CC: deny_c + RUST_CHANNEL: 'stable' + + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Install Rust toolchain + run: | + rustup update --no-self-update ${{ env.RUST_CHANNEL }} + rustup component add --toolchain ${{ env.RUST_CHANNEL }} rustfmt rust-src clippy + rustup default ${{ env.RUST_CHANNEL }} + + - name: Cache Dependencies + uses: Swatinem/rust-cache@v2 + with: + # workspaces: "rust -> target" + key: windows-${{ env.RUST_CHANNEL }} + + - name: Check + run: | + cargo test --lib diff --git a/icechunk/src/storage/mod.rs b/icechunk/src/storage/mod.rs index eecd8a10..67cbb6e6 100644 --- a/icechunk/src/storage/mod.rs +++ b/icechunk/src/storage/mod.rs @@ -669,10 +669,27 @@ pub fn new_gcs_storage( #[allow(clippy::unwrap_used)] mod tests { - use std::collections::HashSet; + use std::{collections::HashSet, fs::File, io::Write, path::PathBuf}; use super::*; use proptest::prelude::*; + use tempfile::TempDir; + + #[tokio::test] + async fn test_is_clean() { + let repo_dir = TempDir::new().unwrap(); + let s = new_local_filesystem_storage(repo_dir.path()).unwrap(); + assert!(s.root_is_clean().await.unwrap()); + + let mut file = File::create(repo_dir.path().join("foo.txt")).unwrap(); + write!(file, "hello").unwrap(); + assert!(!s.root_is_clean().await.unwrap()); + + let inside_existing = + PathBuf::from_iter([repo_dir.path().as_os_str().to_str().unwrap(), "foo"]); + let s = new_local_filesystem_storage(&inside_existing).unwrap(); + assert!(s.root_is_clean().await.unwrap()); + } proptest! { #![proptest_config(ProptestConfig { diff --git a/icechunk/src/storage/object_store.rs b/icechunk/src/storage/object_store.rs index 217cefdd..75705565 100644 --- a/icechunk/src/storage/object_store.rs +++ b/icechunk/src/storage/object_store.rs @@ -71,7 +71,9 @@ impl ObjectStorage { .map_err(|e| StorageError::Other(e.to_string()))?; let prefix = prefix.into_os_string().into_string().map_err(StorageError::BadPrefix)?; - let url = format!("file://{prefix}"); + dbg!(&prefix); + let url = format!("file:///{prefix}"); + dbg!(&url); let config = ObjectStorageConfig { url, prefix, options: vec![] }; Self::from_config(config) }