shuke987 commented on code in PR #27257: URL: https://github.com/apache/doris/pull/27257#discussion_r1398627253
########## .github/workflows/comment-to-trigger-teamcity.yml: ########## @@ -0,0 +1,243 @@ +# 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: Comment to trigger teamcity + +on: + issue_comment: + types: [created, edited] + +jobs: + check-comment-if-need-to-trigger-teamcity: + + # This job only runs for pull request comments, and comment body contains 'run' + # if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, 'run') && ( contains(github.event.comment.body, 'buildall') || contains(github.event.comment.body, 'compile') || contains(github.event.comment.body, 'beut') || contains(github.event.comment.body, 'feut') || contains(github.event.comment.body, 'p0') || contains(github.event.comment.body, 'p1') || contains(github.event.comment.body, 'external') || contains(github.event.comment.body, 'pipelinex_p0') || contains(github.event.comment.body, 'clickbench') || contains(github.event.comment.body, 'arm') || contains(github.event.comment.body, 'tpch') ) }} + if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, 'run') }} + + runs-on: ubuntu-latest + env: + COMMENT_BODY: ${{ github.event.comment.body }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + steps: + - name: "Parse PR comment" + id: parse + run: | + if [[ "${COMMENT_BODY}" == *'run buildall'* || + "${COMMENT_BODY}" == *'run compile'* || + "${COMMENT_BODY}" == *'run beut'* || + "${COMMENT_BODY}" == *'run feut'* || + "${COMMENT_BODY}" == *'run p0'* || + "${COMMENT_BODY}" == *'run p1'* || + "${COMMENT_BODY}" == *'run external'* || + "${COMMENT_BODY}" == *'run pipelinex_p0'* || + "${COMMENT_BODY}" == *'run clickbench'* || + "${COMMENT_BODY}" == *'run arm'* || + "${COMMENT_BODY}" == *'run tpch'* ]]; then Review Comment: run tpch is not ready ########## regression-test/pipeline/common/github-utils.sh: ########## @@ -63,3 +63,190 @@ ${COMMENT_BODY} " create_an_issue_comment "${ISSUE_NUMBER}" "${COMMENT_BODY}" } + +_get_pr_changed_files_count() { + PULL_NUMBER="${PULL_NUMBER:-$1}" + if [[ -z "${PULL_NUMBER}" ]]; then + echo "Usage: _get_pr_changed_files_count PULL_NUMBER" + return 1 + fi + + OWNER="${OWNER:=apache}" + REPO="${REPO:=doris}" + if ret=$( + curl -s -H "Accept: application/vnd.github+json" \ + https://api.github.com/repos/"${OWNER}"/"${REPO}"/pulls/"${PULL_NUMBER}" | jq -e '.changed_files' + ); then + echo "${ret}" + else + return 1 + fi +} + +_get_pr_changed_files() { + usage_str="Usage: + _get_pr_changed_files <PULL_NUMBER> [OPTIONS] + note: https://github.com/apache/doris/pull/13259, PULL_NUMBER is 13259 + OPTIONS can be one of [all|added|modified|removed], default is all + " + if [[ -z "$1" ]]; then echo -e "${usage_str}" && return 1; fi + if ! curl --version >/dev/null; then echo 'error: curl required...' && return 1; fi + if ! command -v jq >/dev/null; then sudo yum install jq -y || sudo apt install -y jq; fi + + PULL_NUMBER="$1" + which_file="$2" + pr_url="https://github.com/${OWNER:=apache}/${REPO:=doris}/pull/${PULL_NUMBER}" + # The number of results per page (max 100), Default 30. + per_page=100 + file_name='pr_changed_files' + rm -f "${file_name}" + page=1 + changed_files_count="$(_get_pr_changed_files_count "${PULL_NUMBER}")" + while [[ ${changed_files_count} -gt 0 ]]; do + try_times=10 + while [[ ${try_times} -gt 0 ]]; do + # TODO: 修改文件多于100个的情况未处理 Review Comment: delete ########## regression-test/pipeline/common/github-utils.sh: ########## @@ -63,3 +63,190 @@ ${COMMENT_BODY} " create_an_issue_comment "${ISSUE_NUMBER}" "${COMMENT_BODY}" } + +_get_pr_changed_files_count() { + PULL_NUMBER="${PULL_NUMBER:-$1}" + if [[ -z "${PULL_NUMBER}" ]]; then + echo "Usage: _get_pr_changed_files_count PULL_NUMBER" + return 1 + fi + + OWNER="${OWNER:=apache}" + REPO="${REPO:=doris}" + if ret=$( + curl -s -H "Accept: application/vnd.github+json" \ + https://api.github.com/repos/"${OWNER}"/"${REPO}"/pulls/"${PULL_NUMBER}" | jq -e '.changed_files' + ); then + echo "${ret}" + else + return 1 + fi +} + +_get_pr_changed_files() { + usage_str="Usage: + _get_pr_changed_files <PULL_NUMBER> [OPTIONS] + note: https://github.com/apache/doris/pull/13259, PULL_NUMBER is 13259 + OPTIONS can be one of [all|added|modified|removed], default is all + " + if [[ -z "$1" ]]; then echo -e "${usage_str}" && return 1; fi + if ! curl --version >/dev/null; then echo 'error: curl required...' && return 1; fi + if ! command -v jq >/dev/null; then sudo yum install jq -y || sudo apt install -y jq; fi + + PULL_NUMBER="$1" + which_file="$2" + pr_url="https://github.com/${OWNER:=apache}/${REPO:=doris}/pull/${PULL_NUMBER}" + # The number of results per page (max 100), Default 30. + per_page=100 + file_name='pr_changed_files' + rm -f "${file_name}" + page=1 + changed_files_count="$(_get_pr_changed_files_count "${PULL_NUMBER}")" + while [[ ${changed_files_count} -gt 0 ]]; do Review Comment: failed when every retry, abort this running. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org