diff --git a/.github/workflows/clitest.yml b/.github/workflows/clitest.yml new file mode 100644 index 000000000000..750ad0a6867e --- /dev/null +++ b/.github/workflows/clitest.yml @@ -0,0 +1,39 @@ +# Copyright 2019-2024 Tauri Programme within The Commons Conservancy +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +name: cli test + +on: + push: + +jobs: + run-cli-tests: + runs-on: ${{ matrix.platform }} + + strategy: + fail-fast: false + matrix: + platform: [windows-latest] + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: install stable + uses: dtolnay/rust-toolchain@stable + + - uses: Swatinem/rust-cache@v2 + with: + workspaces: | + core -> ../target + tooling/cli + + - name: run CLI tests + timeout-minutes: 30 + run: | + cd ./tooling/cli/node + yarn + yarn build + yarn test diff --git a/tooling/bundler/src/bundle/windows/nsis.rs b/tooling/bundler/src/bundle/windows/nsis.rs index c8a21acfa4ba..6c92557744a6 100644 --- a/tooling/bundler/src/bundle/windows/nsis.rs +++ b/tooling/bundler/src/bundle/windows/nsis.rs @@ -97,15 +97,17 @@ pub fn bundle_project(settings: &Settings, updater: bool) -> crate::Result crate::Result<()> { +fn get_and_extract_nsis(nsis_toolset_path: &Path, _tauri_tools_path: &Path) -> anyhow::Result<()> { log::info!("Verifying NSIS package"); #[cfg(target_os = "windows")] { let data = download_and_verify(NSIS_URL, NSIS_SHA1, HashAlgorithm::Sha1)?; log::info!("extracting NSIS"); - crate::bundle::windows::util::extract_zip(&data, _tauri_tools_path)?; - fs::rename(_tauri_tools_path.join("nsis-3.08"), nsis_toolset_path)?; + crate::bundle::windows::util::extract_zip(&data, _tauri_tools_path) + .context("failed to extract")?; + fs::rename(_tauri_tools_path.join("nsis-3.08"), nsis_toolset_path) + .context("failed to rename")?; } let nsis_plugins = nsis_toolset_path.join("Plugins"); @@ -114,7 +116,8 @@ fn get_and_extract_nsis(nsis_toolset_path: &Path, _tauri_tools_path: &Path) -> c NSIS_TAURI_UTILS_URL, NSIS_TAURI_UTILS_SHA1, HashAlgorithm::Sha1, - )?; + ) + .context("failed to download")?; let target_folder = nsis_plugins.join("x86-unicode"); fs::create_dir_all(&target_folder)?; diff --git a/tooling/bundler/src/bundle/windows/util.rs b/tooling/bundler/src/bundle/windows/util.rs index 80c3f64bae0a..109f40c0cc20 100644 --- a/tooling/bundler/src/bundle/windows/util.rs +++ b/tooling/bundler/src/bundle/windows/util.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +use anyhow::Context; use std::{ fs::{create_dir_all, File}, io::{Cursor, Read, Write}, @@ -133,10 +134,10 @@ pub fn verify_file_hash>( /// Extracts the zips from memory into a usable path. #[allow(dead_code)] -pub fn extract_zip(data: &[u8], path: &Path) -> crate::Result<()> { +pub fn extract_zip(data: &[u8], path: &Path) -> anyhow::Result<()> { let cursor = Cursor::new(data); - let mut zipa = ZipArchive::new(cursor)?; + let mut zipa = ZipArchive::new(cursor).context("ziparchive")?; for i in 0..zipa.len() { let mut file = zipa.by_index(i)?; @@ -144,21 +145,23 @@ pub fn extract_zip(data: &[u8], path: &Path) -> crate::Result<()> { if let Some(name) = file.enclosed_name() { let dest_path = path.join(name); if file.is_dir() { - create_dir_all(&dest_path)?; + println!("{:?}", dest_path); + create_dir_all(&dest_path).context("failed to create")?; continue; } let parent = dest_path.parent().expect("Failed to get parent"); if !parent.exists() { - create_dir_all(parent)?; + println!("parent {:?}", parent); + create_dir_all(parent).context("failed to create parent")?; } let mut buff: Vec = Vec::new(); - file.read_to_end(&mut buff)?; + file.read_to_end(&mut buff).context("failed to read")?; let mut fileout = File::create(dest_path).expect("Failed to open file"); - fileout.write_all(&buff)?; + fileout.write_all(&buff).context("failed to write")?; } }