mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-22 03:32:04 +00:00
TravisCI wording and JSON format check
This commit is contained in:
parent
9874c11063
commit
f4f173f9ab
99
travis.pl
99
travis.pl
@ -27,8 +27,8 @@ my $last_func_start = timelocal(localtime());
|
||||
#--------------------------------------------------------
|
||||
# Fuction name: runcmd
|
||||
# Description: run a command after 'cmd' label in one case
|
||||
# Atrributes:
|
||||
# Retrun code:
|
||||
# Attributes:
|
||||
# Return code:
|
||||
# $::RUNCMD_RC : the return code of command
|
||||
# @$outref : the output of command
|
||||
#--------------------------------------------------------
|
||||
@ -53,12 +53,12 @@ sub runcmd
|
||||
#--------------------------------------------------------
|
||||
# Fuction name: get_files_recursive
|
||||
# Description: Search all file in one directory recursively
|
||||
# Atrributes:
|
||||
# Attributes:
|
||||
# $dir (input attribute)
|
||||
# The target scan directory
|
||||
# $files_path_ref (output attribute)
|
||||
# the reference of array where save all vaild files under $dir
|
||||
# Retrun code:
|
||||
# Return code:
|
||||
#--------------------------------------------------------
|
||||
sub get_files_recursive
|
||||
{
|
||||
@ -91,13 +91,17 @@ sub get_files_recursive
|
||||
#--------------------------------------------------------
|
||||
# Fuction name: check_pr_format
|
||||
# Description:
|
||||
# Atrributes:
|
||||
# Retrun code:
|
||||
# Attributes:
|
||||
# Return code:
|
||||
#--------------------------------------------------------
|
||||
sub check_pr_format{
|
||||
if($ENV{'TRAVIS_EVENT_TYPE'} eq "pull_request"){
|
||||
my $pr_url = "https://api.github.com/repos/$ENV{'TRAVIS_REPO_SLUG'}/pulls/$ENV{'TRAVIS_PULL_REQUEST'}";
|
||||
my $pr_url_resp = get($pr_url);
|
||||
unless ($pr_url_resp) {
|
||||
print "[check_pr_format] Not able to get response from $pr_url \n";
|
||||
return 1;
|
||||
}
|
||||
my $pr_content = decode_json($pr_url_resp);
|
||||
my $pr_title = $pr_content->{title};
|
||||
my $pr_body = $pr_content->{body};
|
||||
@ -111,18 +115,18 @@ sub check_pr_format{
|
||||
|
||||
my $checkrst="";
|
||||
if(! $pr_title){
|
||||
$checkrst.="Miss title.";
|
||||
$checkrst.="Missing title.";
|
||||
}
|
||||
if(! $pr_body){
|
||||
$checkrst.="Miss description.";
|
||||
$checkrst.="Missing description.";
|
||||
}
|
||||
|
||||
if(! $pr_milestone){
|
||||
$checkrst.="Miss milestone.";
|
||||
$checkrst.="Missing milestone.";
|
||||
}
|
||||
|
||||
if(! $pr_labels_len){
|
||||
$checkrst.="Miss labels.";
|
||||
$checkrst.="Missing labels.";
|
||||
}
|
||||
|
||||
if(length($checkrst) == 0){
|
||||
@ -143,10 +147,10 @@ sub check_pr_format{
|
||||
}
|
||||
|
||||
#--------------------------------------------------------
|
||||
# Fuction name: check_pr_format
|
||||
# Fuction name: send_back_comment
|
||||
# Description:
|
||||
# Atrributes:
|
||||
# Retrun code:
|
||||
# Attributes:
|
||||
# Return code:
|
||||
#--------------------------------------------------------
|
||||
sub send_back_comment{
|
||||
my $message = shift;
|
||||
@ -154,8 +158,17 @@ sub send_back_comment{
|
||||
my $comment_url = "https://api.github.com/repos/$ENV{'TRAVIS_REPO_SLUG'}/issues/$ENV{'TRAVIS_PULL_REQUEST'}/comments";
|
||||
my $comment_url_resp = get($comment_url);
|
||||
my $json = new JSON;
|
||||
my $comment_content = $json->decode($comment_url_resp);
|
||||
my $comment_len = @$comment_content;
|
||||
my $comment_len = 0;
|
||||
my $comment_content;
|
||||
if ($comment_url_resp) {
|
||||
print "\n\n>>>>>Dumper comment_url_resp:\n";
|
||||
print Dumper $comment_url_resp;
|
||||
|
||||
$comment_content = $json->decode($comment_url_resp);
|
||||
$comment_len = @$comment_content;
|
||||
} else {
|
||||
print "[send_back_comment] Not able to get response from $comment_url \n";
|
||||
}
|
||||
|
||||
#print "\n\n>>>>>Dumper comment_content: $comment_len\n";
|
||||
#print Dumper $comment_content;
|
||||
@ -178,15 +191,15 @@ sub send_back_comment{
|
||||
#--------------------------------------------------------
|
||||
# Fuction name: build_xcat_core
|
||||
# Description:
|
||||
# Atrributes:
|
||||
# Retrun code:
|
||||
# Attributes:
|
||||
# Return code:
|
||||
#--------------------------------------------------------
|
||||
sub build_xcat_core{
|
||||
my @output;
|
||||
my @cmds = ("gpg --list-keys",
|
||||
"sed -i '/SignWith: yes/d' $ENV{'PWD'}/build-ubunturepo");
|
||||
foreach my $cmd (@cmds){
|
||||
print "[build_xcat_core] to run $cmd\n";
|
||||
print "[build_xcat_core] running $cmd\n";
|
||||
@output = runcmd("$cmd");
|
||||
if($::RUNCMD_RC){
|
||||
print "[build_xcat_core] $cmd ....[Failed]\n";
|
||||
@ -226,8 +239,8 @@ sub build_xcat_core{
|
||||
#--------------------------------------------------------
|
||||
# Fuction name: install_xcat
|
||||
# Description:
|
||||
# Atrributes:
|
||||
# Retrun code:
|
||||
# Attributes:
|
||||
# Return code:
|
||||
#--------------------------------------------------------
|
||||
sub install_xcat{
|
||||
|
||||
@ -239,7 +252,7 @@ sub install_xcat{
|
||||
"sudo apt-get -qq update");
|
||||
my @output;
|
||||
foreach my $cmd (@cmds){
|
||||
print "[install_xcat] to run $cmd\n";
|
||||
print "[install_xcat] running $cmd\n";
|
||||
@output = runcmd("$cmd");
|
||||
if($::RUNCMD_RC){
|
||||
print RED "[install_xcat] $cmd. ...[Failed]\n";
|
||||
@ -267,7 +280,7 @@ sub install_xcat{
|
||||
}else{
|
||||
print "[install_xcat] $cmd ....[Pass]\n";
|
||||
|
||||
print "\n------To config xcat and check if xcat work correctly-----\n";
|
||||
print "\n------Config xcat and verify xcat is working correctly-----\n";
|
||||
@cmds = ("sudo -s /opt/xcat/share/xcat/scripts/setup-local-client.sh -f travis",
|
||||
"sudo -s /opt/xcat/sbin/chtab priority=1.1 policy.name=travis policy.rule=allow",
|
||||
". /etc/profile.d/xcat.sh && tabdump policy",
|
||||
@ -277,7 +290,7 @@ sub install_xcat{
|
||||
"service xcatd status");
|
||||
my $ret = 0;
|
||||
foreach my $cmd (@cmds){
|
||||
print "\n[install_xcat] To run $cmd.....\n";
|
||||
print "\n[install_xcat] running $cmd.....\n";
|
||||
@output = runcmd("$cmd");
|
||||
print Dumper \@output;
|
||||
if($::RUNCMD_RC){
|
||||
@ -303,8 +316,8 @@ sub install_xcat{
|
||||
#--------------------------------------------------------
|
||||
# Fuction name: check_syntax
|
||||
# Description:
|
||||
# Atrributes:
|
||||
# Retrun code:
|
||||
# Attributes:
|
||||
# Return code:
|
||||
#--------------------------------------------------------
|
||||
sub check_syntax{
|
||||
my @output;
|
||||
@ -356,8 +369,8 @@ sub check_syntax{
|
||||
#--------------------------------------------------------
|
||||
# Fuction name: run_fast_regression_test
|
||||
# Description:
|
||||
# Atrributes:
|
||||
# Retrun code:
|
||||
# Attributes:
|
||||
# Return code:
|
||||
#--------------------------------------------------------
|
||||
sub run_fast_regression_test{
|
||||
my $cmd = "sudo apt-get install xcat-test --force-yes";
|
||||
@ -428,11 +441,11 @@ sub run_fast_regression_test{
|
||||
|
||||
if($failnum){
|
||||
my $log_str = join (",", @failcase );
|
||||
$check_result_str .= "> **FAST REGRESSION TEST Failed**: Totalcase $casenum Pass $passnum failed $failnum FailedCases: $log_str. Please click ``Details`` label in ``Merge pull request`` box for detailed information";
|
||||
$check_result_str .= "> **FAST REGRESSION TEST Failed**: Totalcase $casenum Passed $passnum Failed $failnum FailedCases: $log_str. Please click ``Details`` label in ``Merge pull request`` box for detailed information";
|
||||
send_back_comment("$check_result_str");
|
||||
return 1;
|
||||
}else{
|
||||
$check_result_str .= "> **FAST REGRESSION TEST Successful**: Totalcase $casenum Pass $passnum failed $failnum";
|
||||
$check_result_str .= "> **FAST REGRESSION TEST Successful**: Totalcase $casenum Passed $passnum Failed $failnum";
|
||||
send_back_comment("$check_result_str");
|
||||
}
|
||||
|
||||
@ -440,10 +453,10 @@ sub run_fast_regression_test{
|
||||
}
|
||||
|
||||
#--------------------------------------------------------
|
||||
# Fuction name: run_fast_regression_test
|
||||
# Fuction name: mark_time
|
||||
# Description:
|
||||
# Atrributes:
|
||||
# Retrun code:
|
||||
# Attributes:
|
||||
# Return code:
|
||||
#--------------------------------------------------------
|
||||
sub mark_time{
|
||||
my $func_name=shift;
|
||||
@ -457,7 +470,7 @@ sub mark_time{
|
||||
#===============Main Process=============================
|
||||
|
||||
#Dumper Travis Environment Attribute
|
||||
print GREEN "\n------Dumper Travis Environment Attribute------\n";
|
||||
print GREEN "\n------ Travis Environment Attributes ------\n";
|
||||
my @travis_env_attr = ("TRAVIS_REPO_SLUG",
|
||||
"TRAVIS_BRANCH",
|
||||
"TRAVIS_EVENT_TYPE",
|
||||
@ -492,47 +505,47 @@ print Dumper \@disk;
|
||||
|
||||
#Start to check the format of pull request
|
||||
$last_func_start = timelocal(localtime());
|
||||
print GREEN "\n------To Check Pull Request Format------\n";
|
||||
print GREEN "\n------ Checking Pull Request Format ------\n";
|
||||
$rst = check_pr_format();
|
||||
if($rst){
|
||||
print RED "Check pull request format failed\n";
|
||||
print RED "Check of pull request format failed\n";
|
||||
exit $rst;
|
||||
}
|
||||
mark_time("check_pr_format");
|
||||
|
||||
#Start to build xcat core
|
||||
|
||||
print GREEN "\n------To Build xCAT core package------\n";
|
||||
print GREEN "\n------ Building xCAT core package ------\n";
|
||||
$rst = build_xcat_core();
|
||||
if($rst){
|
||||
print RED "Build xCAT core package failed\n";
|
||||
print RED "Build of xCAT core package failed\n";
|
||||
exit $rst;
|
||||
}
|
||||
mark_time("build_xcat_core");
|
||||
|
||||
#Start to install xcat
|
||||
print GREEN "\n------To install xcat------\n";
|
||||
print GREEN "\n------Installing xCAT ------\n";
|
||||
$rst = install_xcat();
|
||||
if($rst){
|
||||
print RED "Install xcat failed\n";
|
||||
print RED "Install of xCAT failed\n";
|
||||
exit $rst;
|
||||
}
|
||||
mark_time("install_xcat");
|
||||
|
||||
#Check the syntax of changing code
|
||||
print GREEN "\n------To check the syntax of changing code------\n";
|
||||
print GREEN "\n------ Checking the syntax of changed code------\n";
|
||||
$rst = check_syntax();
|
||||
if($rst){
|
||||
print RED "check the syntax of changing code failed\n";
|
||||
print RED "Check syntax of changed code failed\n";
|
||||
exit $rst;
|
||||
}
|
||||
mark_time("check_syntax");
|
||||
|
||||
#run fast regression
|
||||
print GREEN "\n------To run fast regression test------\n";
|
||||
print GREEN "\n------Running fast regression test ------\n";
|
||||
$rst = run_fast_regression_test();
|
||||
if($rst){
|
||||
print RED "Run fast regression test failed\n";
|
||||
print RED "Run of fast regression test failed\n";
|
||||
exit $rst;
|
||||
}
|
||||
mark_time("run_fast_regression_test");
|
||||
|
Loading…
x
Reference in New Issue
Block a user