Update alpha workflow to trigger on src directory changes

This commit is contained in:
Tunglies 2025-03-29 12:35:49 +08:00
parent a9cccc7b97
commit 9ebde802d4
5 changed files with 32 additions and 21 deletions

View File

@ -25,7 +25,7 @@ jobs:
with: with:
fetch-depth: 2 fetch-depth: 2
- name: Check if version changed - name: Check if version changed or src changed
id: check id: check
run: | run: |
# For manual workflow_dispatch, always run # For manual workflow_dispatch, always run
@ -50,8 +50,25 @@ jobs:
if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then
echo "Version changed from $PREVIOUS_VERSION to $CURRENT_VERSION" echo "Version changed from $PREVIOUS_VERSION to $CURRENT_VERSION"
echo "should_run=true" >> $GITHUB_OUTPUT echo "should_run=true" >> $GITHUB_OUTPUT
exit 0
fi
# Check if src or src-tauri directories changed
CURRENT_SRC_HASH=$(git rev-parse HEAD:src)
PREVIOUS_SRC_HASH=$(git rev-parse HEAD~1:src 2>/dev/null || echo "")
CURRENT_TAURI_HASH=$(git rev-parse HEAD:src-tauri 2>/dev/null || echo "")
PREVIOUS_TAURI_HASH=$(git rev-parse HEAD~1:src-tauri 2>/dev/null || echo "")
echo "Current src hash: $CURRENT_SRC_HASH"
echo "Previous src hash: $PREVIOUS_SRC_HASH"
echo "Current tauri hash: $CURRENT_TAURI_HASH"
echo "Previous tauri hash: $PREVIOUS_TAURI_HASH"
if [ "$CURRENT_SRC_HASH" != "$PREVIOUS_SRC_HASH" ] || [ "$CURRENT_TAURI_HASH" != "$PREVIOUS_TAURI_HASH" ]; then
echo "Source directories changed"
echo "should_run=true" >> $GITHUB_OUTPUT
else else
echo "Version unchanged: $CURRENT_VERSION" echo "Version and source directories unchanged"
echo "should_run=false" >> $GITHUB_OUTPUT echo "should_run=false" >> $GITHUB_OUTPUT
fi fi

View File

@ -85,7 +85,8 @@ pub async fn patch_profiles_config(profiles: IProfiles) -> CmdResult<bool> {
// 更新profiles配置 // 更新profiles配置
logging!(info, Type::Cmd, true, "正在更新配置草稿"); logging!(info, Type::Cmd, true, "正在更新配置草稿");
wrap_err!({ Config::profiles().draft().patch_config(profiles) })?; let _ = Config::profiles().draft().patch_config(profiles);
// 更新配置并进行验证 // 更新配置并进行验证
match CoreManager::global().update_config().await { match CoreManager::global().update_config().await {
Ok((true, _)) => { Ok((true, _)) => {

View File

@ -154,6 +154,8 @@ impl Config {
chain_logs: logs, chain_logs: logs,
}; };
println!("generate runtime draft");
Ok(()) Ok(())
} }
} }

View File

@ -1,10 +1,11 @@
use super::{prfitem::PrfItem, PrfOption}; use super::{prfitem::PrfItem, PrfOption};
use crate::utils::{dirs, help}; use crate::{
use crate::{logging, utils::logging::Type}; logging,
utils::{dirs, help, logging::Type},
};
use anyhow::{bail, Context, Result}; use anyhow::{bail, Context, Result};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_yaml::Mapping; use serde_yaml::{Mapping, Value};
use serde_yaml::Value;
use std::{fs, io::Write}; use std::{fs, io::Write};
/// Define the `profiles.yaml` schema /// Define the `profiles.yaml` schema
#[derive(Default, Debug, Clone, Deserialize, Serialize)] #[derive(Default, Debug, Clone, Deserialize, Serialize)]

View File

@ -148,8 +148,10 @@ impl CoreManager {
} }
/// 验证运行时配置 /// 验证运行时配置
pub async fn validate_config(&self) -> Result<(bool, String)> { pub async fn validate_config(&self) -> Result<(bool, String)> {
logging!(info, Type::Config, true, "生成临时配置文件用于验证");
let config_path = Config::generate_file(ConfigType::Check)?; let config_path = Config::generate_file(ConfigType::Check)?;
let config_path = dirs::path_to_str(&config_path)?; let config_path = dirs::path_to_str(&config_path)?;
println!("{}", config_path);
self.validate_config_internal(config_path).await self.validate_config_internal(config_path).await
} }
/// 验证指定的配置文件 /// 验证指定的配置文件
@ -377,20 +379,8 @@ impl CoreManager {
logging!(info, Type::Config, true, "开始更新配置"); logging!(info, Type::Config, true, "开始更新配置");
// 1. 先生成新的配置内容 // 1. 先生成新的配置内容
logging!(info, Type::Config, true, "生成新的配置内容"); // logging!(info, Type::Config, true, "生成新的配置内容");
Config::generate().await?; // Config::generate().await?;
// 2. 生成临时文件并进行验证
logging!(info, Type::Config, true, "生成临时配置文件用于验证");
let temp_config = Config::generate_file(ConfigType::Check)?;
let temp_config = dirs::path_to_str(&temp_config)?;
logging!(
info,
Type::Config,
true,
"临时配置文件路径: {}",
temp_config
);
// 3. 验证配置 // 3. 验证配置
match self.validate_config().await { match self.validate_config().await {