Skip to content

Commit

Permalink
fix: test ci
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed May 29, 2024
1 parent 265c238 commit f1b9cd2
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 10 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/clitest.yml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 7 additions & 4 deletions tooling/bundler/src/bundle/windows/nsis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,17 @@ pub fn bundle_project(settings: &Settings, updater: bool) -> crate::Result<Vec<P
}

// Gets NSIS and verifies the download via Sha1
fn get_and_extract_nsis(nsis_toolset_path: &Path, _tauri_tools_path: &Path) -> 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");
Expand All @@ -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)?;
Expand Down
15 changes: 9 additions & 6 deletions tooling/bundler/src/bundle/windows/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -133,32 +134,34 @@ pub fn verify_file_hash<P: AsRef<Path>>(

/// 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)?;

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<u8> = 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")?;
}
}

Expand Down

0 comments on commit f1b9cd2

Please sign in to comment.