This is an automated email from the ASF dual-hosted git repository.

yihua pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git


The following commit(s) were added to refs/heads/master by this push:
     new 6f74c7f6ec6 [HUDI-7438] Add GitHub action to check Azure CI report 
(#10731)
6f74c7f6ec6 is described below

commit 6f74c7f6ec6f50547f0472841db05d6943eb07be
Author: Y Ethan Guo <ethan.guoyi...@gmail.com>
AuthorDate: Thu Feb 22 21:44:14 2024 -0800

    [HUDI-7438] Add GitHub action to check Azure CI report (#10731)
---
 .github/workflows/azure_ci_check.yml | 92 ++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)

diff --git a/.github/workflows/azure_ci_check.yml 
b/.github/workflows/azure_ci_check.yml
new file mode 100644
index 00000000000..347d9c2959f
--- /dev/null
+++ b/.github/workflows/azure_ci_check.yml
@@ -0,0 +1,92 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Azure CI
+
+on:
+  issue_comment:
+    types: [ created, edited, deleted ]
+
+permissions:
+  pull-requests: read
+  issues: read
+
+jobs:
+  check-azure-ci-report:
+    if: "!contains(github.event.pull_request.body, 'HOTFIX: SKIP AZURE CI')"
+    runs-on: ubuntu-latest
+    steps:
+      - name: Get last commit hash
+        id: last_commit
+        uses: actions/github-script@v7
+        with:
+          github-token: ${{secrets.GITHUB_TOKEN}}
+          script: |
+            const pr = context.payload.pull_request;
+            const lastCommitHash = pr.head.sha;
+            console.log(`Last commit hash: ${lastCommitHash}`);
+            // Set the output variable to be used in subsequent step
+            core.setOutput("last_commit_hash", lastCommitHash);
+
+      - name: Check Azure CI report in PR comment
+        uses: actions/github-script@v7
+        with:
+          github-token: ${{secrets.GITHUB_TOKEN}}
+          script: |
+            const lastCommitHash = '${{ 
steps.last_commit.outputs.last_commit_hash }}'
+            const botUsername = 'hudi-bot';
+            
+            const issueNumber = context.payload.pull_request.number;
+            const comments = await github.rest.issues.listComments({
+              owner: context.repo.owner,
+              repo: context.repo.repo,
+              issue_number: issueNumber,
+            });
+            
+            // Find the last comment from hudi-bot containing the Azure CI 
report
+            const botComments = comments.data.filter(comment => 
comment.user.login === botUsername);
+            const lastComment = botComments.pop();
+            
+            if (lastComment) {
+              const reportPrefix = '${lastCommitHash} Azure: '
+              const successReportString = '${reportPrefix}[SUCCESS]'
+              const failureReportString = '${reportPrefix}[FAILURE]'
+              if (lastComment.body.includes(reportPrefix)) {
+                if (lastComment.body.includes(successReportString)) {
+                  console.log(`Azure CI succeeded on the latest commit of the 
PR.`);
+                  return true;
+                } else if (lastComment.body.includes(failureReportString)) {
+                  console.log(`Azure CI failed on the latest commit of the 
PR.`);
+                  core.setFailed("Azure CI failed on the latest commit of the 
PR.");
+                  return false;
+                } else {
+                  console.log(`Azure CI is in progress on the latest commit of 
the PR.`);
+                  core.setFailed("Azure CI is in progress on the latest commit 
of the PR.");
+                  return false;
+                }
+              } else {
+                console.log(`No Azure CI report on the latest commit of the 
PR.`);
+                core.setFailed("No Azure CI report on the latest commit of the 
PR.");
+                return false;
+              }
+            } else {
+              console.log(`Azure CI report does not seem to be ready yet.`);
+              core.setFailed("Azure CI report does not seem to be ready yet.");
+              return false;
+            }
+        env:
+          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

Reply via email to