-
Notifications
You must be signed in to change notification settings - Fork 1.2k
116 lines (113 loc) · 4.11 KB
/
ProcessCodeReview.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Auto Review PR
on:
pull_request_target:
types: [opened, synchronize]
branches:
- main
permissions: {}
jobs:
pr-code-review:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-code-review') }}
runs-on: ubuntu-latest
permissions:
pull-requests: read
contents: read
steps:
- name: Check Init Event
env:
action: ${{ toJSON(github.event.action) }}
label: ${{ toJSON(github.event.label) }}
run: |
echo start review module changed
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Checkout CLI extension repo
uses: actions/checkout@master
with:
fetch-depth: 0 # checkout all branches
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }} # checkout pull request branch
- name: Show workdirectory after site cloned
run: |
pwd
ls
- name: Get Diff Modules
env:
bash_sha: ${{ github.event.pull_request.base.sha }}
base_branch: ${{ github.event.pull_request.base.ref }}
base_repo: ${{ github.event.pull_request.base.repo.clone_url }}
base_branch_pre: "upstream"
diff_sha: ${{ github.event.pull_request.head.sha }}
diff_branch: ${{ github.event.pull_request.head.ref }}
repo_full_name: ${{ github.event.pull_request.head.repo.full_name }}
run: |
set -x
git --version
git log --oneline | head -n 10
git branch -a
git fetch "$base_repo" "$base_branch":"$base_branch_pre"/"$base_branch"
git checkout "$base_branch_pre"/"$base_branch"
git log --oneline | head -n 10
git checkout "$diff_branch"
git log --oneline | head -n 10
git --no-pager diff --name-only --diff-filter=ACMRT "$base_branch_pre"/"$base_branch"..."$diff_branch" > changed_files
cat changed_files
echo "changed_module_list=$(cat changed_files | grep src/ | awk -F"src/" '{print $2}'| grep / | awk -F"/" '{print $1}' | sort | uniq | xargs)" >> $GITHUB_ENV
- name: Display Diff Modules
run: |
for mod in ${changed_module_list[@]}
do
echo changed module: "${mod}"
done
- name: Check whether aaz-related Module
id: check_if_aaz_used
env:
pr_label_list: ${{ toJson(github.event.pull_request.labels.*.name) }}
result_path: "./review_result"
output_file: "is_aaz_check.txt"
survey_comment_file: "aaz_survey_comment.txt"
base_branch: ${{ github.event.pull_request.base.ref }}
base_branch_pre: "upstream"
run: |
set -ev
mkdir ${result_path}
git checkout "$base_branch_pre"/"$base_branch" -- scripts
python scripts/ci/codegen_cal.py --job check
ls ${result_path}
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: review-code-output
path: |
review_result
retention-days: 1
action-on-output:
needs: pr-code-review
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
steps:
- name: Download code review result
uses: actions/download-artifact@v4
with:
name: review-code-output
- name: Show workdirectory after result downloaded
run: |
pwd
ls
- name: Check comment file existence
id: check_survey_comment_file
uses: andstor/file-existence-action@v3
with:
files: "./aaz_survey_comment.txt"
- name: Comment survey on the pull request
if: steps.check_survey_comment_file.outputs.files_exists == 'true'
uses: mshick/add-pr-comment@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
message-id: aazSurveyCommentBot
message-path: |
aaz_survey_comment.txt