diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d43eaf69..7b7ba0a29 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest] + os: [ubuntu-latest, windows-latest, macOS-latest] # Test against the oldest supported version. # Test against beta Rust to get early warning of any problems that might occur with the upcoming Rust release. @@ -51,13 +51,31 @@ jobs: # Test with no features and all features. args: ["--no-default-features", "--all-features"] steps: + - if: runner.os == 'Windows' + name: Set git to use LF + run: | + git config --global core.autocrlf false + git config --global core.eol lf - name: Checkout repository uses: actions/checkout@v4 - name: Install Rust uses: hecrj/setup-rust-action@v2 with: rust-version: ${{ matrix.rust }} - - if: matrix.rust == 'stable' && matrix.args == '--all-features' + - if: runner.os == 'Windows' + name: Set VCPKG root + run: echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append + - if: runner.os == 'Windows' + name: Cache vcpkg + id: cache-vckpg + uses: actions/cache@v4 + with: + path: C:/vcpkg + key: ${{ runner.os }}-vcpkg + - if: runner.os == 'Windows' && steps.cache-vckpg.outputs.cache-hit != 'true' + name: Install OpenSSL for Windows + run: vcpkg install openssl:x64-windows-static-md + - if: matrix.rust == 'stable' && matrix.args == '--all-features' && matrix.os == 'ubuntu-latest' run: cargo clippy ${{ matrix.args }} -- -D warnings - run: cargo build ${{ matrix.args }} --locked - run: cargo test ${{ matrix.args }} -- --test-threads=1 2>&1 diff --git a/src/commons/ext_serde.rs b/src/commons/ext_serde.rs index fafa4cc95..abc15195b 100644 --- a/src/commons/ext_serde.rs +++ b/src/commons/ext_serde.rs @@ -8,6 +8,7 @@ use bytes::Bytes; use log::LevelFilter; use rpki::repository::resources::{AsBlocks, IpBlocks}; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; +#[cfg(unix)] use syslog::Facility; @@ -182,6 +183,7 @@ where //------------ Facility ------------------------------------------------------ +#[cfg(unix)] pub fn de_facility<'de, D>(d: D) -> Result where D: Deserializer<'de>, diff --git a/src/commons/file.rs b/src/commons/file.rs index 3181257c0..a6252fd49 100644 --- a/src/commons/file.rs +++ b/src/commons/file.rs @@ -317,6 +317,9 @@ fn derive_uri( None => format!("rsync://{rel_string}"), }; + #[cfg(not(unix))] + let uri_string = uri_string.replace("\\", "/"); + let uri = uri::Rsync::from_str(&uri_string) .map_err(|_| Error::UnsupportedFileName(uri_string))?; Ok(uri) @@ -568,19 +571,19 @@ mod tests { fn should_scan_disk() { test::test_under_tmp(|base_dir| { let file_1 = CurrentFile::new( - test::rsync("rsync://host:10873/module/alice/file1.txt"), + test::rsync("rsync://host/module/alice/file1.txt"), &Bytes::from("content 1"), ); let file_2 = CurrentFile::new( - test::rsync("rsync://host:10873/module/alice/file2.txt"), + test::rsync("rsync://host/module/alice/file2.txt"), &Bytes::from("content 2"), ); let file_3 = CurrentFile::new( - test::rsync("rsync://host:10873/module/alice/sub/file1.txt"), + test::rsync("rsync://host/module/alice/sub/file1.txt"), &Bytes::from("content sub file"), ); let file_4 = CurrentFile::new( - test::rsync("rsync://host:10873/module/bob/file.txt"), + test::rsync("rsync://host/module/bob/file.txt"), &Bytes::from("content"), ); diff --git a/src/commons/storage/backends/disk.rs b/src/commons/storage/backends/disk.rs index 0aef11788..2cbd51ee9 100644 --- a/src/commons/storage/backends/disk.rs +++ b/src/commons/storage/backends/disk.rs @@ -85,6 +85,13 @@ impl Store { let path = PathBuf::from(format!( "{}{}", uri.host_str().unwrap_or_default(), uri.path() )); + + #[cfg(windows)] + let path = path.to_string_lossy() + .strip_prefix('/') + .map(|s| PathBuf::from(s)) + .unwrap_or(path); + let root = path.join(namespace.as_str()); let tmp = path.join(TMP_FILE_DIR); let mut locks = path.join(LOCK_FILE_DIR); diff --git a/src/config.rs b/src/config.rs index a6c599963..0b627b84c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1740,13 +1740,17 @@ impl Config { match self.log_type { LogType::File => self.file_logger(), LogType::Stderr => self.stderr_logger(), + #[cfg(unix)] LogType::Syslog => { let facility = Facility::from_str(&self.syslog_facility) .map_err(|_| { ConfigError::other("Invalid syslog_facility") })?; self.syslog_logger(facility) - } + }, + #[cfg(not(unix))] + LogType::Syslog => + Err(ConfigError::other("syslog not support on non-unix")), } } diff --git a/src/upgrades/mod.rs b/src/upgrades/mod.rs index ec198b813..06f8eba9d 100644 --- a/src/upgrades/mod.rs +++ b/src/upgrades/mod.rs @@ -1554,8 +1554,9 @@ mod tests { "test-resources/status_store/migration-0.9.5/"; let temp_dir = tempdir().unwrap(); copy_folder(source_dir_path_str, &temp_dir); + let temp_dir_str = &temp_dir.path().display(); let source_dir_url = Url::parse( - &format!("local://{}", &temp_dir.path().to_str().unwrap())) + &format!("local://{}", temp_dir_str)) .unwrap(); let source_store = diff --git a/tests/common.rs b/tests/common.rs index 9b054b137..d2990738b 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -63,9 +63,14 @@ impl TestConfig { pub fn file_storage() -> Self { let data_dir = TempDir::new().unwrap(); + let uri = data_dir.path().to_string_lossy(); + + #[cfg(windows)] + let uri = format!("/{}", uri.replace("\\", "/")); + Self::new( Url::parse( - &format!("local://{}/data/", data_dir.path().display()) + &format!("local://{}/data/", uri) ).unwrap() , data_dir, ) diff --git a/tests/functional_old_data.rs b/tests/functional_old_data.rs index 76f91dbf9..f0e8ab0c3 100644 --- a/tests/functional_old_data.rs +++ b/tests/functional_old_data.rs @@ -38,8 +38,9 @@ async fn functional_old_data() { let signer_config = include_str!("../test-resources/migrations/v0_14_5_signer/ta.conf"); + let path = tempdir.path().join("ta").to_str().unwrap().replace("\\", "/"); let signer_config = signer_config.replace("%TEMPDIR%", - tempdir.path().join("ta").to_str().unwrap()); + &format!("local:///{}", path.strip_prefix('/').unwrap_or(&path))); let signer_config = krill::tasigner::Config::parse_str( &signer_config ).unwrap();