diff --git a/others/script/smoke/README.md b/others/script/smoke/README.md index 3d2d3c0..53f8647 100644 --- a/others/script/smoke/README.md +++ b/others/script/smoke/README.md @@ -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 diff --git a/others/script/smoke/lib/common.sh b/others/script/smoke/lib/common.sh index a3f528a..6dca03d 100644 --- a/others/script/smoke/lib/common.sh +++ b/others/script/smoke/lib/common.sh @@ -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" diff --git a/others/script/smoke/suites/config_repo.sh b/others/script/smoke/suites/config_repo.sh index 570e373..b51902a 100644 --- a/others/script/smoke/suites/config_repo.sh +++ b/others/script/smoke/suites/config_repo.sh @@ -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}"