-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CI] add ci approval pipelines #7859
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. | ||
# | ||
# Licensed 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. | ||
|
||
import json | ||
import sys | ||
|
||
|
||
def check_approval(count, required_reviewers): | ||
json_buff = "" | ||
for line in sys.stdin: | ||
json_buff = "".join([json_buff, line]) | ||
json_resp = json.loads(json_buff) | ||
approves = 0 | ||
approved_user_ids = [] | ||
approved_user_logins = set() | ||
for review in json_resp: | ||
if review["state"] == "APPROVED": | ||
approves += 1 | ||
approved_user_ids.append(review["user"]["id"]) | ||
approved_user_logins.add(review["user"]["login"]) | ||
|
||
# convert to int | ||
required_reviewers_int = set() | ||
required_reviewers_login = set() | ||
for rr in required_reviewers: | ||
if rr.isdigit(): | ||
required_reviewers_int.add(int(rr)) | ||
else: | ||
required_reviewers_login.add(rr) | ||
|
||
if ( | ||
len(set(approved_user_ids) & required_reviewers_int) + len(approved_user_logins & required_reviewers_login) | ||
>= count | ||
): | ||
print("TRUE") | ||
else: | ||
print("FALSE") | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) > 1 and sys.argv[1].isdigit(): | ||
check_approval(int(sys.argv[1]), sys.argv[2:]) | ||
else: | ||
print("Usage: python check_pr_approval.py [count] [required reviewer id] ...") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. | ||
# | ||
# Licensed 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. | ||
|
||
failed_num=0 | ||
echo_list=() | ||
approval_line=`curl -H "Authorization: token ${GITHUB_API_TOKEN}" https://api.github.com/repos/PaddlePaddle/PaddleNLP/pulls/${GIT_PR_ID}/reviews?per_page=10000` | ||
|
||
function add_failed(){ | ||
failed_num=`expr $failed_num + 1` | ||
echo_list="${echo_list[@]}$1" | ||
} | ||
|
||
function check_approval(){ | ||
person_num=`echo $@|awk '{for (i=2;i<=NF;i++)print $i}'` | ||
echo ${person_num} | ||
APPROVALS=`echo ${approval_line}|python check_pr_approval.py $1 $person_num` | ||
echo ${APPROVALS} | ||
if [[ "${APPROVALS}" == "FALSE" && "${echo_line}" != "" ]]; then | ||
add_failed "${failed_num}. ${echo_line}" | ||
fi | ||
} | ||
|
||
for file_name in `git diff --numstat upstream/${AGILE_COMPILE_BRANCH} |awk '{print $NF}'`;do | ||
arr_file_name=(${file_name//// }) | ||
dir1=${arr_file_name[0]} | ||
dir2=${arr_file_name[1]} | ||
dir3=${arr_file_name[2]} | ||
dir4=${arr_file_name[3]} | ||
echo "file_name:"${file_name}, "dir1:"${dir1}, "dir2:"${dir2},"dir3:"${dir3},".xx:" ${file_name##*.} | ||
if [[ ${file_name} =~ "paddlenlp/trainer/training_args.py" ]] || [[ ${file_name} =~ "paddlenlp/trainer/trainer.py" ]] || [[ ${file_name} =~ "llm/run_pretrain.py" ]] || [[ ${file_name} =~ "llm/finetune_generation.py" ]];then | ||
echo_line="You must have two RD: one from(ZHUI, wawltor),one from(ForFishes,sneaxiy,zhiqiu) approval for the changes of training_args.py/trainer.py/run_pretrain.py " | ||
check_approval 2 ZHUI wawltor ForFishes sneaxiy zhiqiu | ||
elif [[ ${dir1} =~ "paddlenlp" ]];then | ||
if [[ ${dir2} =~ "transformers" ]];then | ||
echo_line="You must have one RD (wawltor) approval for the changes of transformers " | ||
check_approval 1 wawltor | ||
elif [[ ${dir2} =~ "taskflow" ]];then | ||
echo_line="You must have one RD (w5688414(Recommend),DesmonDay,wawltor) approval for the changes of taskflow" | ||
check_approval 1 w5688414 DesmonDay wawltor | ||
elif [[ ${dir3} =~ "trainer" ]];then | ||
echo_line="You must have one RD (ZHUI(Recommend), wawltor) approval for the changes of trainer" | ||
check_approval 1 ZHUI wawltor | ||
elif [[ ${dir3} =~ "fast_transformer" ]] || [[ ${dir4} =~ "FasterTransformer" ]] ;then | ||
echo_line="You must have one RD (guoshengCS(Recommend), wawltor) approval for the changes of FT or FG" | ||
check_approval 1 guoshengCS wawltor | ||
elif [[ ${dir3} =~ "llama" ]] || [[ ${dir3} =~ "gpt" ]];then | ||
echo_line="You must have two RD: one from(ZHUI, wawltor),one from(ForFishes,sneaxiy,zhiqiu) approval for the changes of llm/llama/auto_parallel/ " | ||
check_approval 2 ZHUI wawltor ForFishes sneaxiy zhiqiu | ||
fi | ||
elif [[ ${dir1} =~ "model_zoo" ]];then # | ||
if [[ ${dir2} =~ "gpt-3" ]] ;then | ||
echo_line="You must have two RD: one from(ZHUI, wawltor),one from(ForFishes,sneaxiy,zhiqiu) approval for the changes of model_zoo/gpt-3 " | ||
check_approval 2 ZHUI wawltor ForFishes sneaxiy zhiqiu | ||
fi | ||
elif [[ ${dir1} =~ "llm" ]];then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. llm 目录下其他模块有多个人同时在调整,你就设置: wj-Mcat/lugimzzz/DesmonDay/wawltor |
||
if [[ ${dir3} =~ "auto_parallel" ]] ;then | ||
echo_line="You must have two RD: one from(ZHUI, wawltor),one from(ForFishes,sneaxiy,zhiqiu) approval for the changes of llm/llama/auto_parallel/ " | ||
check_approval 2 ZHUI wawltor ForFishes sneaxiy zhiqiu | ||
else | ||
echo_line="You must have one RD (wj-Mcat(Recommend), wawltor) approval for the changes of llm" | ||
check_approval 1 wj-Mcat lugimzzz DesmonDay wawltor | ||
fi | ||
elif [[ ${dir1} =~ "tests" ]];then | ||
if [[ ${dir2} =~ "transformers" ]] ;then | ||
echo_line="You must have one RD (wawltor) approval for the changes of transformers " | ||
check_approval 1 wawltor | ||
elif [[ ${dir2} =~ "taskflow" ]] || [[ ${dir2} =~ "prompt" ]];then | ||
echo_line="You must have one RD (w5688414(Recommend),, wawltor) approval for the changes of taskflow" | ||
check_approval 1 w5688414 wawltor | ||
elif [[ ${dir2} =~ "llm" ]] ;then | ||
echo_line="You must have one RD (wj-Mcat(Recommend), wawltor) approval for the changes of tests/llm/" | ||
check_approval 1 wj-Mcat lugimzzz gongel wtmlon wawltor | ||
elif [[ ${dir2} =~ "trainer" ]] ;then | ||
echo_line="You must have one RD (ZHUI(Recommend), wawltor) approval for the changes of trainer" | ||
check_approval 1 ZHUI wawltor | ||
elif [[ ${dir2} =~ "ops" ]] || [[ ${dir2} =~ "embedding" ]];then | ||
echo_line="You must have one RD (guoshengCS(Recommend),, wawltor) approval for the changes of ops or embedding" | ||
check_approval 1 guoshengCS wawltor | ||
elif [[ ${dir2} =~ "model_zoo" ]] ;then | ||
echo_line="You must have one RD (wawltor(Recommend)) approval for the changes of model_zoo" | ||
check_approval 1 wawltor | ||
elif [[ ${dir2} =~ "cli" ]] || [[ ${dir2} =~ "generation" ]];then | ||
echo_line="You must have one RD (wj-Mcat(Recommend), wawltor) approval for the changes of llm/generation" | ||
check_approval 1 wj-Mcat wawltor | ||
elif [[ ${dir2} =~ "test_tipc" ]];then | ||
echo_line="You must have one RD (wj-Mcat(Recommend),lugimzzz, wawltor) approval for the changes of test_tipc" | ||
check_approval 1 wj-Mcat lugimzzz wawltor | ||
elif [[ ${dir2} =~ "dataaug" ]]|| [[ ${dir2} =~ "peft" ]];then | ||
echo_line="You must have one RD (lugimzzz(Recommend), wawltor) approval for the changes of dataaug/peft" | ||
check_approval 1 lugimzzz wawltor | ||
elif [[ ${dir2} =~ "data" ]]|| [[ ${dir2} =~ "dataset" ]];then | ||
echo_line="You must have one RD (KB-Ding(Recommend), wawltor) approval for the changes of data/dataset" | ||
check_approval 1 KB-Ding wawltor | ||
elif [[ ${dir2} =~ "layers" ]] || [[ ${dir2} =~ "metrics" ]] || [[ ${file_name} =~ "tests/llm/test_pretrain.py" ]];then | ||
echo_line="You must have one RD (ZHUI(Recommend),DesmonDay,wawltor) approval for the changes of layers/metrics/tests/llm/test_pretrain.py" | ||
check_approval 1 ZHUI DesmonDay wawltor | ||
elif [[ ${dir2} =~ "utils" ]] ;then | ||
echo_line="You must have one RD (wawltor(Recommend)) approval for the changes of tests/utils" | ||
check_approval 1 wawltor | ||
fi | ||
elif [[ ${dir1} =~ "pipelines" ]];then | ||
echo_line="You must have one RD (w5688414(Recommend), wawltor) approval for the changes of pipelines" | ||
check_approval 1 w5688414 junnyu wawltor | ||
elif [[ ${dir1} =~ "ppdiffusers" ]];then | ||
echo_line="You must have one RD (junnyu(Recommend), wawltor) approval for the changes of pipelines" | ||
check_approval 1 w5688414 junnyu wawltor | ||
else | ||
continue | ||
fi | ||
done | ||
|
||
if [ -n "${echo_list}" ];then | ||
echo "**************************************************************" | ||
echo "Please find RD for approval." | ||
echo -e "${echo_list[@]}" | ||
echo "There are ${failed_num} approved errors." | ||
echo "**************************************************************" | ||
exit 1 | ||
else | ||
echo "**************************************************************" | ||
echo "CI APPROVAL PASSED." | ||
echo "**************************************************************" | ||
exit 0 | ||
fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 脚本搞得 太复杂了,用python 对写的配置文件判断好了。
后面大家只要删减配置文件里面的东西。程序和内容分离。
现在修改改起来也特别麻烦
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
收到,我看看