This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/dev/pr-11594-bbde250914346068f50131e7907bef2c9ecbc448 in repository https://gitbox.apache.org/repos/asf/seatunnel.git
commit 05620d8b6341665a33ab426a0271f5b8169ddcee Author: Daniel <[email protected]> AuthorDate: Fri Sep 11 08:46:05 2026 +0000 [Improve][CI] Stabilize workflow run detection (#11594) Co-authored-by: davidzollo <[email protected]> --- .github/workflows/notify_test_workflow.yml | 153 ++++++++++++++--------------- mvnw | 22 ++++- 2 files changed, 94 insertions(+), 81 deletions(-) diff --git a/.github/workflows/notify_test_workflow.yml b/.github/workflows/notify_test_workflow.yml index 4563787e83..5f56774664 100644 --- a/.github/workflows/notify_test_workflow.yml +++ b/.github/workflows/notify_test_workflow.yml @@ -48,6 +48,7 @@ jobs: // TODO: Should use pull_request.user and pull_request.user.repos_url? // If a different person creates a commit to another forked repo, // it wouldn't be able to detect. + const head_sha = context.payload.pull_request.head.sha const params = { owner: context.payload.pull_request.head.repo.owner.login, repo: context.payload.pull_request.head.repo.name, @@ -66,8 +67,36 @@ jobs: console.log('SHA: ' + context.payload.pull_request.head.sha) const name = 'Build' - const head_sha = context.payload.pull_request.head.sha - let status = 'queued' + const createDetectionFailedCheck = async () => { + await github.rest.checks.create({ + owner: context.repo.owner, + repo: context.repo.repo, + name: name, + head_sha: head_sha, + status: 'completed', + conclusion: 'action_required', + output: { + title: 'Workflow run detection failed', + summary: ` + Unable to detect the workflow run for testing the changes in your PR. + + 1. If you did not enable GitHub Actions in your forked repository, please enable it by clicking the button as shown in the image below. See also [Disabling or limiting GitHub Actions for a repository](https://docs.github.com/en/github/administering-a-repository/disabling-or-limiting-github-actions-for-a-repository) for more details. + 2. Create and push an empty commit to trigger the workflow. + 3. It is possible your branch is based on the old \`dev\` branch in Apache SeaTunnel, please sync your branch to the latest dev branch. For example as below: + \`\`\`bash + git fetch upstream + git rebase upstream/dev + git push origin YOUR_BRANCH --force + \`\`\``, + images: [ + { + alt: 'enabling workflows button', + image_url: 'https://raw.githubusercontent.com/apache/spark/master/.github/workflows/images/workflow-enable-button.png' + } + ] + } + }) + } async function findBuildWorkflowRun() { const lookupDeadline = Date.now() + MAX_LOOKUP_DURATION_MS @@ -76,9 +105,8 @@ jobs: while (true) { try { const runs = await github.request(endpoint, params) - const buildRun = runs.data.workflow_runs.find( - (run) => run.head_sha === head_sha - ) + const workflowRuns = runs && runs.data ? runs.data.workflow_runs : [] + const buildRun = workflowRuns.find((run) => run.head_sha === head_sha) console.log('runs: ' + JSON.stringify(runs)) if (buildRun) { @@ -102,76 +130,47 @@ jobs: const build_run = await findBuildWorkflowRun() if (!build_run) { - status = 'completed' - const conclusion = 'action_required' - - await github.rest.checks.create({ - owner: context.repo.owner, - repo: context.repo.repo, - name: name, - head_sha: head_sha, - status: status, - conclusion: conclusion, - output: { - title: 'Workflow run detection failed', - summary: ` - Unable to detect the workflow run for testing the changes in your PR. - - 1. If you did not enable GitHub Actions in your forked repository, please enable it by clicking the button as shown in the image below. See also [Disabling or limiting GitHub Actions for a repository](https://docs.github.com/en/github/administering-a-repository/disabling-or-limiting-github-actions-for-a-repository) for more details. - 2. Create and push an empty commit to trigger the workflow. - 3. It is possible your branch is based on the old \`dev\` branch in Apache SeaTunnel, please sync your branch to the latest dev branch. For example as below: - \`\`\`bash - git fetch upstream - git rebase upstream/dev - git push origin YOUR_BRANCH --force - \`\`\``, - images: [ - { - alt: 'enabling workflows button', - image_url: 'https://raw.githubusercontent.com/apache/spark/master/.github/workflows/images/workflow-enable-button.png' - } - ] - } - }) - } else { - const run_id = build_run.id - - // Here we get check run ID to provide Check run view instead of Actions view, see also SPARK-37879. - const check_runs = await github.request(check_run_endpoint, check_run_params) - console.log('check_runs: ' + JSON.stringify(check_runs)) - const actions_url = 'https://github.com/' - + context.payload.pull_request.head.repo.full_name - + '/actions/runs/' - + run_id - const run_url_part = '/actions/runs/' + run_id - const check_run_head = check_runs.data.check_runs.find(r => - r.head_sha === build_run.head_sha - && ( - (r.details_url && r.details_url.includes(run_url_part)) - || (r.html_url && r.html_url.includes(run_url_part)) - ) - ) - - console.log('check_run_head: ' + JSON.stringify(check_run_head)) - const check_run_url = check_run_head - ? (check_run_head.html_url || check_run_head.details_url || actions_url) - : actions_url - - await github.rest.checks.create({ - owner: context.repo.owner, - repo: context.repo.repo, - name: name, - head_sha: head_sha, - status: status, - output: { - title: 'Test results', - summary: '[See test results](' + check_run_url + ')', - text: JSON.stringify({ - owner: context.payload.pull_request.head.repo.owner.login, - repo: context.payload.pull_request.head.repo.name, - run_id: run_id - }) - }, - details_url: actions_url, - }) + await createDetectionFailedCheck() + return } + + const run_id = build_run.id + + // Here we get check run ID to provide Check run view instead of Actions view, see also SPARK-37879. + const check_runs = await github.request(check_run_endpoint, check_run_params) + console.log('check_runs: ' + JSON.stringify(check_runs)) + const actions_url = 'https://github.com/' + + context.payload.pull_request.head.repo.full_name + + '/actions/runs/' + + run_id + const run_url_part = '/actions/runs/' + run_id + const check_run_head = check_runs.data.check_runs.find(r => + r.head_sha === build_run.head_sha + && ( + (r.details_url && r.details_url.includes(run_url_part)) + || (r.html_url && r.html_url.includes(run_url_part)) + ) + ) + + console.log('check_run_head: ' + JSON.stringify(check_run_head)) + const check_run_url = check_run_head + ? (check_run_head.html_url || check_run_head.details_url || actions_url) + : actions_url + + await github.rest.checks.create({ + owner: context.repo.owner, + repo: context.repo.repo, + name: name, + head_sha: head_sha, + status: 'queued', + output: { + title: 'Test results', + summary: '[See test results](' + check_run_url + ')', + text: JSON.stringify({ + owner: context.payload.pull_request.head.repo.owner.login, + repo: context.payload.pull_request.head.repo.name, + run_id: run_id + }) + }, + details_url: actions_url, + }) diff --git a/mvnw b/mvnw index 5643201c7d..486313a937 100755 --- a/mvnw +++ b/mvnw @@ -232,23 +232,37 @@ else wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` fi + download_with_retries() { + attempts=1 + while [ "$attempts" -le 5 ]; do + "$@" && return 0 + rm -f "$wrapperJarPath" + if [ "$attempts" -lt 5 ]; then + echo "Maven wrapper download failed, retrying in 5 seconds ..." >&2 + sleep 5 + fi + attempts=`expr "$attempts" + 1` + done + return 1 + } + if command -v wget > /dev/null; then if [ "$MVNW_VERBOSE" = true ]; then echo "Found wget ... using wget" fi if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + download_with_retries wget "$jarUrl" -O "$wrapperJarPath" else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + download_with_retries wget --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$jarUrl" -O "$wrapperJarPath" fi elif command -v curl > /dev/null; then if [ "$MVNW_VERBOSE" = true ]; then echo "Found curl ... using curl" fi if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f + download_with_retries curl -o "$wrapperJarPath" "$jarUrl" -f else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + download_with_retries curl --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$jarUrl" -f fi else
