From e9cff2ea4400bd0bfad08de1adeec7775712d99e Mon Sep 17 00:00:00 2001 From: lidongyang Date: Fri, 15 May 2026 19:56:07 +0800 Subject: [PATCH] [fix](pipeline) fix comment-trigger workflow crash when GitHub API rate limit causes missing all_files Two issues fixed: 1. `_get_pr_changed_files_count` and `_get_pr_changed_files` in github-utils.sh made unauthenticated curl requests, hitting GitHub's 60 req/h anonymous rate limit on shared Actions runner IPs. Added `${GITHUB_TOKEN:+-H "Authorization: Bearer ${GITHUB_TOKEN}"}` so requests use the 5000 req/h authenticated limit when GITHUB_TOKEN is available (no-op when unset, preserving local usage). 2. When `_get_pr_changed_files` fails, step 4 falls back to trigger-all but does NOT create the `all_files` file. Step 5 then crashes with "No such file or directory" on `< all_files`, causing conclusion=failure and skipping all TeamCity trigger steps. Added an early-exit guard in step 5 to handle this gracefully. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/comment-to-trigger-teamcity.yml | 6 ++++++ regression-test/pipeline/common/github-utils.sh | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/comment-to-trigger-teamcity.yml b/.github/workflows/comment-to-trigger-teamcity.yml index 92336f430f5fe1..5e40d1c0cfcece 100644 --- a/.github/workflows/comment-to-trigger-teamcity.yml +++ b/.github/workflows/comment-to-trigger-teamcity.yml @@ -230,6 +230,12 @@ jobs: # Matches .sh files under regression-test/pipeline/ but excludes files under conf/ subdirectories. source regression-test/pipeline/common/github-utils.sh + if [[ ! -f all_files ]]; then + echo "WARNING: all_files not found (GitHub API call likely failed in previous step)." + echo "Skipping sensitive check — previous step already defaulted to trigger-all." + exit 0 + fi + changed_sensitive=false while IFS= read -r f; do if [[ "${f}" == regression-test/pipeline/*.sh || diff --git a/regression-test/pipeline/common/github-utils.sh b/regression-test/pipeline/common/github-utils.sh index ca3977bfc4c835..048b282701ecf0 100644 --- a/regression-test/pipeline/common/github-utils.sh +++ b/regression-test/pipeline/common/github-utils.sh @@ -131,7 +131,9 @@ _get_pr_changed_files_count() { while [[ ${try_times} -gt 0 ]]; do set -x if ret=$( - curl -s -H "Accept: application/vnd.github+json" \ + curl -s \ + -H "Accept: application/vnd.github+json" \ + ${GITHUB_TOKEN:+-H "Authorization: Bearer ${GITHUB_TOKEN}"} \ https://api.github.com/repos/"${OWNER}"/"${REPO}"/pulls/"${PULL_NUMBER}" | jq -e '.changed_files' ); then set +x @@ -169,6 +171,7 @@ _get_pr_changed_files() { set -x if curl -s \ -H "Accept: application/vnd.github+json" \ + ${GITHUB_TOKEN:+-H "Authorization: Bearer ${GITHUB_TOKEN}"} \ https://api.github.com/repos/"${OWNER}"/"${REPO}"/pulls/"${PULL_NUMBER}"/files?page="${page}"\&per_page="${per_page}" \ >>"${file_name}"; then set +x