fix: require opt-in for destructive smoke cleanup

This commit is contained in:
Mirtle
2026-03-26 13:56:56 +08:00
parent fbcd597726
commit dd67c351d0
3 changed files with 31 additions and 0 deletions

View File

@@ -21,6 +21,20 @@ This directory contains the shell-based smoke test framework for the current rep
- `RIME_CLI_URL`: optional public CLI bundle URL
- `RIME_CONFIG_ROOT`: optional repository root override
- `SMOKE_ALLOW_DESTRUCTIVE=1`: required for local runs because the smoke suite removes `${RIME_CONFIG_ROOT:-repo}/build` and `${RIME_CONFIG_ROOT:-repo}/*.userdb`
## Destructive Cleanup
The smoke suite removes the following paths under `RIME_CONFIG_ROOT` before deployment:
- `build/`
- `*.userdb/`
This cleanup is allowed automatically in CI. Local runs must opt in explicitly:
```bash
SMOKE_ALLOW_DESTRUCTIVE=1 ./others/script/smoke/run.sh
```
## Extending

View File

@@ -69,6 +69,22 @@ ensure_clean_dir() {
mkdir -p "${dir_path}"
}
require_destructive_cleanup_approval() {
local config_root="$1"
local build_dir="${config_root}/build"
if [[ "${CI:-}" == "true" || "${GITHUB_ACTIONS:-}" == "true" ]]; then
return 0
fi
if [[ "${SMOKE_ALLOW_DESTRUCTIVE:-}" == "1" ]]; then
log_warn "destructive cleanup approved by SMOKE_ALLOW_DESTRUCTIVE=1"
return 0
fi
fail "smoke test will remove ${build_dir} and ${config_root}/*.userdb; rerun with SMOKE_ALLOW_DESTRUCTIVE=1 for local execution, or run in CI"
}
clean_config_artifacts() {
local config_root="$1"
local build_dir="${config_root}/build"

View File

@@ -22,6 +22,7 @@ run_config_repo_suite() {
assert_file_exists "${config_root}/default.yaml"
assert_file_exists "${config_root}/${suite_name}.schema.yaml"
require_destructive_cleanup_approval "${config_root}"
clean_config_artifacts "${config_root}"
resolve_cli_commands "${cli_url}" "${work_root}" >"${cli_paths_file}"