forked from sonic-net/sonic-tsc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dump_data.yml
184 lines (169 loc) · 7.01 KB
/
dump_data.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
trigger: none
pr: none
schedules:
- cron: '0 0 1 * *'
always: true
branches:
include:
- master
pool: sonicbld
jobs:
- job: update
timeoutInMinutes: 600
variables:
- group: SONICBLD
steps:
- checkout: self
clean: true
path: s
- bash: |
set -x
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh jq -y
echo $TOKEN | gh auth login --with-token
git remote remove sonicbld || true
git remote add sonicbld https://mssonicbld:[email protected]/mssonicbld/sonic-tsc/
git fetch sonicbld
git config user.email '[email protected]'
git config user.name 'Sonic Automation'
env:
TOKEN: $(GH_TOKEN)
displayName: setup env
- bash: |
set -ex
git reset origin/master --hard
cd sii_hld
./dump_hld_data.sh
git add dash_hld.csv sai_hld.csv sonic_hld.csv
git commit -m "[data] Update HLD related data." || exit 0
git push sonicbld HEAD:refs/heads/data/hld -f
re=$(gh pr create -R sonic-net/sonic-tsc -H mssonicbld:data/hld -B master -b '' -t "[data] Update HLD related data." 2>&1 || true)
add=$(git show HEAD --stat | grep '[0-9]* *insertion' -Eo | grep '[0-9]*' -Eo || true)
del=$(git show HEAD --stat | grep '[0-9]* *deletion' -Eo | grep '[0-9]*' -Eo || true)
if [ -z "$del" ]; then
sleep 60
gh pr merge --auto $(echo $re | grep -Eo 'https://github.com/sonic-net/sonic-tsc/pull/[0-9]*') -s
fi
git reset origin/master --hard
cd ..
displayName: dump hld
condition: ne(variables['SKIP_HLD'], 'y')
- bash: |
set -ex
git reset origin/master --hard
cd sii_issue
./issues_dump.sh
git add issues.json
git commit -m "[data] Update issue related data." || exit 0
git push sonicbld HEAD:refs/heads/data/issue -f
re=$(gh pr create -R sonic-net/sonic-tsc -H mssonicbld:data/issue -B master -b '' -t "[data] Update issue related data." 2>&1 || true)
add=$(git show HEAD --stat | grep '[0-9]* *insertion' -Eo | grep '[0-9]*' -Eo || true)
del=$(git show HEAD --stat | grep '[0-9]* *deletion' -Eo | grep '[0-9]*' -Eo || true)
if [ -z "$del" ]; then
sleep 60
gh pr merge --auto $(echo $re | grep -Eo 'https://github.com/sonic-net/sonic-tsc/pull/[0-9]*') -s
elif (( add/del >= 1 )) && (( del < 30 )); then
sleep 60
gh pr merge --auto $(echo $re | grep -Eo 'https://github.com/sonic-net/sonic-tsc/pull/[0-9]*') -s
else
echo "Don't auto merge"
fi
git reset origin/master --hard
cd ..
displayName: dump issue
condition: ne(variables['SKIP_ISSUE'], 'y')
- bash: |
set -ex
git reset origin/master --hard
cd sii_testplan_hld
./generate_testplan_hld_data.sh
git add sonic-mgmt_hld.csv
git commit -m "[data] Update testplan HLD related data." || exit 0
git push sonicbld HEAD:refs/heads/data/testplan-hld -f
re=$(gh pr create -R sonic-net/sonic-tsc -H mssonicbld:data/testplan-hld -B master -b '' -t "[data] Update testplan HLD related data." 2>&1 || true)
add=$(git show HEAD --stat | grep '[0-9]* *insertion' -Eo | grep '[0-9]*' -Eo || true)
del=$(git show HEAD --stat | grep '[0-9]* *deletion' -Eo | grep '[0-9]*' -Eo || true)
if [ -z "$del" ]; then
sleep 60
gh pr merge --auto $(echo $re | grep -Eo 'https://github.com/sonic-net/sonic-tsc/pull/[0-9]*') -s
fi
git reset origin/master --hard
cd ..
displayName: dump test hld
condition: ne(variables['SKIP_TESTHLD'], 'y')
- bash: |
set -ex
git reset origin/master --hard
cd sii_pr_review
for repo in $(cat repos)
do
current=$(date -I)
year=${current:0:4}
month=${current:5:2}
(( month <=2 )) && year1=$(( $year -1 ))
./pr_dump.sh -y "$year1 $year" -r $repo
./pr_dump.sh -y "$year1 $year" -t reviews -r $repo
repo_name=$(echo $repo | awk -F/ '{print$2}')
ls $year1/$repo_name.*reviews.json &>/dev/null && ./parse_reviews.py $year1/$repo_name.*reviews.json
ls $year/$repo_name.*reviews.json &>/dev/null && ./parse_reviews.py $year/$repo_name.*reviews.json
done
rm -rf $(find . -size -10c)
git add $year1 $year
git commit -m "[data] Update pr&review related data." || exit 0
git push sonicbld HEAD:refs/heads/data/pr -f
re=$(gh pr create -R sonic-net/sonic-tsc -H mssonicbld:data/pr -B master -b '' -t "[data] Update pr&review related data." 2>&1 || true)
add=$(git show HEAD --stat | grep '[0-9]* *insertion' -Eo | grep '[0-9]*' -Eo || true)
del=$(git show HEAD --stat | grep '[0-9]* *deletion' -Eo | grep '[0-9]*' -Eo || true)
if [ -z "$del" ]; then
sleep 60
gh pr merge --auto $(echo $re | grep -Eo 'https://github.com/sonic-net/sonic-tsc/pull/[0-9]*') -s
elif (( add/del >= 15 )) && (( del < 200 )); then
sleep 60
gh pr merge --auto $(echo $re | grep -Eo 'https://github.com/sonic-net/sonic-tsc/pull/[0-9]*') -s
else
echo "Don't auto merge"
fi
git reset origin/master --hard
cd ..
displayName: dump pr
condition: ne(variables['SKIP_PR'], 'y')
- bash: |
set -ex
git reset origin/master --hard
cd sii_test_pr_review
current=$(date -I)
year=${current:0:4}
month=${current:5:2}
(( month <=2 )) && year1=$(( $year -1 ))
./pr_dump.sh -y "$year1 $year"
for file in $(find $year1 $year -name *.prs.json)
do
./parse_prs.py $file
done
for file in $(find $year1 $year -name *.reviews.json)
do
./parse_reviews.py $file
done
rm -rf $(find . -size -10c)
git add $year1 $year
git commit -m "[data] Update test pr&review related data." || exit 0
git push sonicbld HEAD:refs/heads/data/testpr -f
re=$(gh pr create -R sonic-net/sonic-tsc -H mssonicbld:data/testpr -B master -b '' -t "[data] Update test pr&review related data." 2>&1 || true)
add=$(git show HEAD --stat | grep '[0-9]* *insertion' -Eo | grep '[0-9]*' -Eo || true)
del=$(git show HEAD --stat | grep '[0-9]* *deletion' -Eo | grep '[0-9]*' -Eo || true)
if [ -z "$del" ]; then
sleep 60
gh pr merge --auto $(echo $re | grep -Eo 'https://github.com/sonic-net/sonic-tsc/pull/[0-9]*') -s
elif (( add/del >= 20 )) ; then
sleep 60
gh pr merge --auto $(echo $re | grep -Eo 'https://github.com/sonic-net/sonic-tsc/pull/[0-9]*') -s
else
echo "Don't auto merge"
fi
git reset origin/master --hard
cd ..
displayName: dump test pr
condition: ne(variables['SKIP_TESTPR'], 'y')