diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..b97929f --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,71 @@ +name: CI +permissions: + contents: write + id-token: write +on: + push: + branches: + - main + tags-ignore: + - '**' + paths-ignore: + - '**/*.md' + - LICENSE + - '**/*.gitignore' + pull_request: null +env: + CARGO_TERM_COLOR: always +jobs: + build: + strategy: + fail-fast: false + matrix: + settings: + - host: macos-latest + target: x86_64-apple-darwin + - host: macos-latest + target: aarch64-apple-darwin + - host: windows-latest + target: x86_64-pc-windows-msvc + - host: windows-latest + target: i686-pc-windows-msvc + - host: windows-latest + target: aarch64-pc-windows-msvc + - host: ubuntu-latest + target: x86_64-unknown-linux-gnu + - host: ubuntu-latest + target: x86_64-unknown-linux-musl + - host: ubuntu-latest + target: aarch64-unknown-linux-gnu + - host: ubuntu-latest + target: armv7-unknown-linux-gnueabihf + - host: ubuntu-latest + target: armv7-unknown-linux-musleabihf + - host: ubuntu-latest + target: aarch64-linux-android + - host: ubuntu-latest + target: armv7-linux-androideabi + - host: ubuntu-latest + target: aarch64-unknown-linux-musl + - host: ubuntu-latest + target: riscv64gc-unknown-linux-gnu + name: ${{ matrix.settings.target }} + runs-on: ${{ matrix.settings.host }} + steps: + - uses: actions/checkout@v4 + - name: Install + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + targets: ${{ matrix.settings.target }} + - name: Cache cargo + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + .cargo-cache + target/ + key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }} + - run: cargo test --all-features \ No newline at end of file diff --git a/src/fsutil/default.rs b/src/fsutil/default.rs index 1923adc..9cf4618 100644 --- a/src/fsutil/default.rs +++ b/src/fsutil/default.rs @@ -1,7 +1,7 @@ +use crate::fsutil::FSUtil; +use path_clean::PathClean; use std::fs; use std::path::{Path, PathBuf}; -use path_clean::PathClean; -use crate::fsutil::FSUtil; fn read_file(file_path: &str) -> Option { match fs::read_to_string(Path::new(file_path)) { @@ -25,7 +25,12 @@ fn path_is_absolute(path: &str) -> bool { } fn path_join(base: &str, path: &str) -> String { - Path::new(base).join(Path::new(path)).clean().to_str().unwrap().to_string() + Path::new(base) + .join(Path::new(path)) + .clean() + .to_str() + .unwrap() + .to_string() } fn file_is_directory(file_path: &str) -> bool { @@ -168,7 +173,8 @@ mod tests { } #[test] - fn test_parent_directory_returns_empty_string_if_path_is_single_component_with_trailing_slash() { + fn test_parent_directory_returns_empty_string_if_path_is_single_component_with_trailing_slash() + { let path = "src/"; let parent = parent_directory(path); assert_eq!(parent, ""); @@ -189,35 +195,40 @@ mod tests { } #[test] - fn test_parent_directory_returns_parent_directory_of_path_with_multiple_components_and_trailing_slash() { + fn test_parent_directory_returns_parent_directory_of_path_with_multiple_components_and_trailing_slash( + ) { let path = "src/fsutil/default.rs/"; let parent = parent_directory(path); assert_eq!(parent, "src/fsutil"); } #[test] - fn test_parent_directory_returns_parent_directory_of_path_with_multiple_components_and_multiple_trailing_slashes() { + fn test_parent_directory_returns_parent_directory_of_path_with_multiple_components_and_multiple_trailing_slashes( + ) { let path = "src/fsutil/default.rs///"; let parent = parent_directory(path); assert_eq!(parent, "src/fsutil"); } #[test] - fn test_parent_directory_returns_parent_directory_of_path_with_multiple_components_and_multiple_trailing_slashes_and_root() { + fn test_parent_directory_returns_parent_directory_of_path_with_multiple_components_and_multiple_trailing_slashes_and_root( + ) { let path = "/src/fsutil/default.rs///"; let parent = parent_directory(path); assert_eq!(parent, "/src/fsutil"); } #[test] - fn test_parent_directory_returns_parent_directory_of_path_with_multiple_components_and_multiple_trailing_slashes_and_root_and_trailing_slash() { + fn test_parent_directory_returns_parent_directory_of_path_with_multiple_components_and_multiple_trailing_slashes_and_root_and_trailing_slash( + ) { let path = "/src/fsutil/default.rs///"; let parent = parent_directory(path); assert_eq!(parent, "/src/fsutil"); } #[test] - fn test_parent_directory_returns_parent_directory_of_path_with_multiple_components_and_multiple_trailing_slashes_and_root_and_trailing_slash_and_root() { + fn test_parent_directory_returns_parent_directory_of_path_with_multiple_components_and_multiple_trailing_slashes_and_root_and_trailing_slash_and_root( + ) { let path = "/src/fsutil/default.rs///"; let parent = parent_directory(path); assert_eq!(parent, "/src/fsutil"); diff --git a/src/fsutil/mod.rs b/src/fsutil/mod.rs index a180ede..c33fb86 100644 --- a/src/fsutil/mod.rs +++ b/src/fsutil/mod.rs @@ -24,7 +24,6 @@ pub struct FSUtil { } impl FSUtil { - /// Create a new instance of file system utility. /// /// # Arguments diff --git a/src/lexer.rs b/src/lexer.rs index e69de29..8b13789 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -0,0 +1 @@ + diff --git a/src/lib.rs b/src/lib.rs index 3a285ee..f6ced37 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,2 +1,2 @@ -pub mod lexer; pub mod fsutil; +pub mod lexer;