From de80e8a673b89b8c9a9065e8cb89bb9ad142af78 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 26 Sep 2026 10:55:06 +0800 Subject: [PATCH] fix(ci): make shared checks portable across runners (#8124) * fix(ci): isolate monitor argument checks from runner tools * fix(ci): install the Typos action download dependency * fix(ci): make release policy matching portable across awk variants --- .config/make/tests.mak | 1 + .github/workflows/ci.yml | 4 ++ scripts/monitor_manual_transition_ci.sh | 10 ++--- .../check_preview_release_workflow.sh | 2 +- scripts/test_manual_transition_runbooks.sh | 41 +++++++++++++------ 5 files changed, 40 insertions(+), 18 deletions(-) diff --git a/.config/make/tests.mak b/.config/make/tests.mak index ef288b904..2788c0f2a 100644 --- a/.config/make/tests.mak +++ b/.config/make/tests.mak @@ -24,6 +24,7 @@ TEST_THREADS ?= 1 .PHONY: script-tests script-tests: ## Run shell script tests @echo "Running script tests..." + trap 'status=$$?; printf "ERROR: script-tests failed (exit %s): %s\n" "$$status" "$$BASH_COMMAND" >&2; exit "$$status"' ERR ./scripts/test_build_rustfs_options.sh ./scripts/test_docker_runtime_timezone.sh ./scripts/test_entrypoint_credentials.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dbc2b7dd5..2eae1ef5c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,6 +104,10 @@ jobs: - uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7 with: persist-credentials: false + - name: Install typos download dependency + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends wget - name: Typos check with custom config file uses: crate-ci/typos@512fc24f32f44ab01972217aaaf3dc86ec234d53 # v1.50.2 diff --git a/scripts/monitor_manual_transition_ci.sh b/scripts/monitor_manual_transition_ci.sh index 86d0d2ae7..86beabf6f 100755 --- a/scripts/monitor_manual_transition_ci.sh +++ b/scripts/monitor_manual_transition_ci.sh @@ -129,15 +129,15 @@ while [[ $# -gt 0 ]]; do esac done -require_cmd gh -require_cmd jq -require_cmd date - -if ! [[ "${RUNS}" =~ ^[0-9]+$ ]] || (( RUNS == 0 )); then +if ! [[ "${RUNS}" =~ ^[0-9]+$ && "${RUNS}" =~ [1-9] ]]; then echo "ERROR: --runs must be a positive integer" >&2 exit 1 fi +require_cmd gh +require_cmd jq +require_cmd date + run_failed=0 active_found=0 diff --git a/scripts/security/check_preview_release_workflow.sh b/scripts/security/check_preview_release_workflow.sh index c13bdc5f7..77818ef75 100755 --- a/scripts/security/check_preview_release_workflow.sh +++ b/scripts/security/check_preview_release_workflow.sh @@ -161,7 +161,7 @@ require_line "$release_script" " gh api --method POST \"repos/\${GITHUB_REPOSIT require_line "$release_script" " local create_args=(release create \"\$tag\" --title \"\$title\" --notes-file \"\$notes_file\" --latest=false --draft)" "draft release creation with a notes file" release_channel_block=$(awk ' - $0 == " if [[ \"\$BUILD_TYPE\" == \"release\" ]]; then" { in_block = 1 } + $0 == " if [[ \"$BUILD_TYPE\" == \"release\" ]]; then" { in_block = 1 } in_block { print } in_block && $0 == " fi" { exit } ' "$build_workflow") diff --git a/scripts/test_manual_transition_runbooks.sh b/scripts/test_manual_transition_runbooks.sh index 9ad09909a..cf7855c0e 100755 --- a/scripts/test_manual_transition_runbooks.sh +++ b/scripts/test_manual_transition_runbooks.sh @@ -182,25 +182,42 @@ if ! rg -q "ERROR: --admin-token cannot be combined with --access-key/--secret-k exit 1 fi -bash scripts/monitor_manual_transition_ci.sh --help >/tmp/monitor_manual_transition_ci.help -rg -q "Usage:" /tmp/monitor_manual_transition_ci.help -if bash scripts/monitor_manual_transition_ci.sh --issues >/tmp/monitor_manual_transition_ci.err 2>&1; then +bash scripts/monitor_manual_transition_ci.sh --help >"$TMP_DIR/monitor.help" +rg -q "Usage:" "$TMP_DIR/monitor.help" +mkdir -p "$TMP_DIR/no-monitor-tools" +if PATH="$TMP_DIR/no-monitor-tools" "$BASH" scripts/monitor_manual_transition_ci.sh --issues >"$TMP_DIR/monitor.err" 2>&1; then echo "monitor script should fail when --issues has no value" >&2 exit 1 fi -if ! rg -q "ERROR: missing value for --issues" /tmp/monitor_manual_transition_ci.err; then +if ! rg -qx "ERROR: missing value for --issues" "$TMP_DIR/monitor.err"; then echo "monitor script missing missing-value guard for --issues" >&2 + cat "$TMP_DIR/monitor.err" >&2 exit 1 fi -if bash scripts/monitor_manual_transition_ci.sh --runs 0 >/tmp/monitor_manual_transition_ci.err 2>&1; then - echo "monitor script should fail on invalid --runs" >&2 - exit 1 -fi -if ! rg -q "ERROR: --runs must be a positive integer" /tmp/monitor_manual_transition_ci.err; then - echo "monitor script missing invalid --runs guard output" >&2 - exit 1 -fi +for runs in 0 00 -1 abc; do + if PATH="$TMP_DIR/no-monitor-tools" "$BASH" scripts/monitor_manual_transition_ci.sh --runs "$runs" >"$TMP_DIR/monitor.err" 2>&1; then + echo "monitor script should fail on invalid --runs: $runs" >&2 + exit 1 + fi + if [[ "$(cat "$TMP_DIR/monitor.err")" != "ERROR: --runs must be a positive integer" ]]; then + echo "monitor script missing invalid --runs guard output for: $runs" >&2 + cat "$TMP_DIR/monitor.err" >&2 + exit 1 + fi +done + +for runs in 1 8 100; do + if PATH="$TMP_DIR/no-monitor-tools" "$BASH" scripts/monitor_manual_transition_ci.sh --runs "$runs" >"$TMP_DIR/monitor.err" 2>&1; then + echo "monitor script should still require its tools for valid --runs: $runs" >&2 + exit 1 + fi + if [[ "$(cat "$TMP_DIR/monitor.err")" != "ERROR: required command not found: gh" ]]; then + echo "monitor script missing dependency guard for valid --runs: $runs" >&2 + cat "$TMP_DIR/monitor.err" >&2 + exit 1 + fi +done bash "$FAILURE_SAMPLES" --help >/tmp/manual_transition_failure_samples.help rg -q "Usage:" /tmp/manual_transition_failure_samples.help