Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
88b870ef
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
694
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
88b870ef
编写于
2月 21, 2018
作者:
X
Xin Pan
提交者:
GitHub
2月 21, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #8442 from panyx0718/develop
Add a script to bisect to a culprit commit.
上级
3c2cafbe
501f4bd2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
141 addition
and
0 deletion
+141
-0
tools/continuous_integration/bisect.py
tools/continuous_integration/bisect.py
+141
-0
未找到文件。
tools/continuous_integration/bisect.py
0 → 100644
浏览文件 @
88b870ef
# 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.
# A script to bisect the mainline commits and find the culprit commit.
# The default 'git bisect' checks feature branches, which is not desired
# because commits in feature branch might not pass tests or compile.
#
# Example:
# python ../bisect.py --git_dir=$PWD/../Paddle --build_dir=$PWD \
# --good_commit=3647ed6 --bad_commit=279aa6 \
# --test_target=test_rnn_encoder_decoder
import
argparse
import
os
import
subprocess
import
sys
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
parser
.
add_argument
(
'--git_dir'
,
type
=
str
,
default
=
''
,
help
=
'git repo root directory.'
)
parser
.
add_argument
(
'--build_dir'
,
type
=
str
,
default
=
''
,
help
=
'build directory.'
)
parser
.
add_argument
(
'--good_commit'
,
type
=
str
,
default
=
''
,
help
=
'The old commit known to be good.'
)
parser
.
add_argument
(
'--bad_commit'
,
type
=
str
,
default
=
''
,
help
=
'The new commit known to be bad.'
)
parser
.
add_argument
(
'--test_target'
,
type
=
str
,
default
=
''
,
help
=
'The test target to evaluate.'
)
parser
.
add_argument
(
'--bisect_branch'
,
type
=
str
,
default
=
'develop'
,
help
=
'The mainline branch to bisect (feature branch ignored.'
)
parser
.
add_argument
(
'--log_file'
,
type
=
str
,
default
=
''
,
help
=
'The file use to log outputs.'
)
parser
.
add_argument
(
'--test_times'
,
type
=
int
,
default
=
10
,
help
=
"Number of times to run the test target."
)
parser
.
add_argument
(
'--build_parallel'
,
type
=
int
,
default
=
32
,
help
=
"make parallelism."
)
args
=
parser
.
parse_args
()
if
not
args
.
log_file
:
args
.
log_file
=
'/tmp/%s...%s.log'
%
(
args
.
good_commit
,
args
.
bad_commit
)
def
print_arguments
():
print
(
'----------- Configuration Arguments -----------'
)
for
arg
,
value
in
sorted
(
vars
(
args
).
iteritems
()):
print
(
'%s: %s'
%
(
arg
,
value
))
print
(
'------------------------------------------------'
)
print_arguments
()
# List the commits in mainline branch.
os
.
chdir
(
args
.
git_dir
)
ret
=
subprocess
.
check_output
(
[
'git rev-list --first-parent %s...%s'
%
(
args
.
good_commit
,
args
.
bad_commit
)
],
shell
=
True
)
sys
.
stdout
.
write
(
'commits found:
\n
%s
\n
'
%
ret
)
commits
=
ret
.
strip
().
split
(
'
\n
'
)
os
.
chdir
(
args
.
build_dir
)
# Clean up previous logs.
subprocess
.
check_output
([
'echo "" > %s'
%
args
.
log_file
],
shell
=
True
)
last_culprit
=
''
while
True
:
# Get to the mainline branch and clean up
os
.
chdir
(
args
.
git_dir
)
subprocess
.
check_output
(
[
'git checkout %s && git clean -fd && git checkout .'
%
args
.
bisect_branch
],
shell
=
True
)
if
not
commits
:
sys
.
stdout
.
write
(
'no commits to bisect
\n
'
)
exit
()
# checkout the picked branch.
pick_idx
=
len
(
commits
)
/
2
pick
=
commits
[
pick_idx
]
os
.
chdir
(
args
.
git_dir
)
subprocess
.
check_output
([
'git checkout %s'
%
pick
],
shell
=
True
)
# Clean builds and compile.
# We assume mainline commits should always compile.
os
.
chdir
(
args
.
build_dir
)
sys
.
stdout
.
write
(
'eval commit %d/%d: %s
\n
'
%
(
pick_idx
,
len
(
commits
),
pick
))
# Link error can happen without complete clean up.
cmd
=
(
'rm -rf * && '
'cmake -DWITH_TESTING=ON %s >> %s && make -j%s >> %s'
%
(
args
.
git_dir
,
args
.
log_file
,
args
.
build_parallel
,
args
.
log_file
))
sys
.
stdout
.
write
(
'cmd: %s
\n
'
%
cmd
)
try
:
subprocess
.
check_output
([
cmd
],
shell
=
True
)
except
subprocess
.
CalledProcessError
as
e
:
sys
.
stderr
.
write
(
'failed to build commit: %s
\n
%s
\n
'
%
(
pick
,
e
))
exit
()
# test the selected branch.
passed
=
True
try
:
cmd
=
(
'ctest --repeat-until-fail %s -R %s >> %s'
%
(
args
.
test_times
,
args
.
test_target
,
args
.
log_file
))
sys
.
stdout
.
write
(
'cmd: %s
\n
'
%
cmd
)
subprocess
.
check_output
([
cmd
],
shell
=
True
)
except
subprocess
.
CalledProcessError
as
e
:
passed
=
False
last_culprit
=
pick
sys
.
stdout
.
write
(
'eval %s passed: %s
\n
'
%
(
pick
,
passed
))
if
passed
:
if
pick_idx
==
0
:
break
commits
=
commits
[:
pick_idx
]
else
:
if
pick_idx
+
1
>=
len
(
commits
):
break
commits
=
commits
[
pick_idx
+
1
:]
sys
.
stdout
.
write
(
'Culprit commit: %s
\n
'
%
last_culprit
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录