[DEV] something better
This commit is contained in:
parent
e72567dd41
commit
3cf3cb731f
11
bdd.sql
11
bdd.sql
@ -21,8 +21,8 @@ CREATE TABLE IF NOT EXISTS `BUILD_list` (
|
|||||||
`id-group` int(32) NOT NULL,
|
`id-group` int(32) NOT NULL,
|
||||||
`sha1` varchar(512) NOT NULL,
|
`sha1` varchar(512) NOT NULL,
|
||||||
`tag` varchar(512) NOT NULL,
|
`tag` varchar(512) NOT NULL,
|
||||||
`status` enum('UNKNOW','START','ERROR','OK') NOT NULL DEFAULT 'UNKNOW',
|
`status` enum('UNKNOW','START','ERROR','OK') NOT NULL DEFAULT 'UNKNOW'
|
||||||
`build-id` int(32) NOT NULL
|
`stage` enum('INIT', 'DOWNLOAD', 'CONFIGURE', 'BUILD', 'INSTALL', 'TEST', 'COVERAGE', 'PACKAGE', 'NONE') NOT NULL DEFAULT 'NONE'
|
||||||
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
|
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
@ -33,12 +33,7 @@ CREATE TABLE IF NOT EXISTS `BUILD_list` (
|
|||||||
CREATE TABLE IF NOT EXISTS `BUILD_snapshot` (
|
CREATE TABLE IF NOT EXISTS `BUILD_snapshot` (
|
||||||
`id-build` varchar(256) NOT NULL,
|
`id-build` varchar(256) NOT NULL,
|
||||||
`id-group` int(11) NOT NULL DEFAULT '0',
|
`id-group` int(11) NOT NULL DEFAULT '0',
|
||||||
`Linux` enum('UNKNOW','START','ERROR','OK') NOT NULL DEFAULT 'UNKNOW',
|
`json` text NOT NULL
|
||||||
`Windows` enum('UNKNOW','START','ERROR','OK') NOT NULL DEFAULT 'UNKNOW',
|
|
||||||
`Mingw` enum('UNKNOW','START','ERROR','OK') NOT NULL DEFAULT 'UNKNOW',
|
|
||||||
`MacOs` enum('UNKNOW','START','ERROR','OK') NOT NULL DEFAULT 'UNKNOW',
|
|
||||||
`IOs` enum('UNKNOW','START','ERROR','OK') NOT NULL DEFAULT 'UNKNOW',
|
|
||||||
`Android` enum('UNKNOW','START','ERROR','OK') NOT NULL DEFAULT 'UNKNOW'
|
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,19 +83,20 @@ if ($exist == FALSE) {
|
|||||||
if ($idGroup <= -1) {
|
if ($idGroup <= -1) {
|
||||||
echo("[ERROR] can not create or find group");
|
echo("[ERROR] can not create or find group");
|
||||||
} else {
|
} else {
|
||||||
$sql = " INSERT INTO `BUILD_list` (`time`, `id-group`, `sha1`, `tag`, `status`, `build-id`)"
|
$sql = " INSERT INTO `BUILD_list` (`time`, `id-group`, `sha1`, `tag`, `status`, `stage`)"
|
||||||
." VALUES ('".time()."',"
|
." VALUES ('".time()."',"
|
||||||
." '".$idGroup."',"
|
." '".$idGroup."',"
|
||||||
." '".$_POST['SHA1']."',"
|
." '".$_POST['SHA1']."',"
|
||||||
." '".$_POST['TAG']."',"
|
." '".$_POST['TAG']."',"
|
||||||
." '".$_POST['STATUS']."',"
|
." '".$_POST['STATUS']."',"
|
||||||
." '".$_POST['ID']."')";
|
." '".$_POST['STAGE']."')";
|
||||||
//echo $sql;
|
//echo $sql;
|
||||||
$result = $COVERAGE_bdd->query($sql);
|
$result = $COVERAGE_bdd->query($sql);
|
||||||
if ($result == FALSE) {
|
if ($result == FALSE) {
|
||||||
echo("[ERROR] Can not register in db ... (LIST)");
|
echo("[ERROR] Can not register in db ... (LIST)");
|
||||||
}
|
}
|
||||||
$sql = "SELECT `BUILD_snapshot`.`id` "
|
$sql = "SELECT `BUILD_snapshot`.`id` "
|
||||||
|
." AND `BUILD_snapshot`.`json` "
|
||||||
." FROM `BUILD_snapshot`"
|
." FROM `BUILD_snapshot`"
|
||||||
." , `CI_group`"
|
." , `CI_group`"
|
||||||
." WHERE `CI_group`.`user-name` = '".$userName."'"
|
." WHERE `CI_group`.`user-name` = '".$userName."'"
|
||||||
@ -108,10 +109,10 @@ if ($idGroup <= -1) {
|
|||||||
if ( $result == NULL
|
if ( $result == NULL
|
||||||
|| $result->num_rows == 0) {
|
|| $result->num_rows == 0) {
|
||||||
// simply insert:
|
// simply insert:
|
||||||
$sql = " INSERT INTO `BUILD_snapshot` (`id-build`, `id-group`, `".$_POST['TAG']."`)"
|
$sql = " INSERT INTO `BUILD_snapshot` (`id-build`, `id-group`, `json`)"
|
||||||
." VALUES ('".$_POST['ID']."',"
|
." VALUES ('".$_POST['ID']."',"
|
||||||
." '".$idGroup."',"
|
." '".$idGroup."',"
|
||||||
." '".$_POST['STATUS']."')";
|
." '{\"".$_POST['TAG']."\":\"".$_POST['STATUS']."\"')";
|
||||||
$result = $COVERAGE_bdd->query($sql);
|
$result = $COVERAGE_bdd->query($sql);
|
||||||
if ($result == TRUE) {
|
if ($result == TRUE) {
|
||||||
echo("[OK] registered done (new entry)");
|
echo("[OK] registered done (new entry)");
|
||||||
@ -119,9 +120,19 @@ if ($idGroup <= -1) {
|
|||||||
echo("[ERROR] Can not register in db ... (snapshot 1)");
|
echo("[ERROR] Can not register in db ... (snapshot 1)");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// update the entry:
|
||||||
|
if ( $result->num_rows == 1) {
|
||||||
|
$row = $result->fetch_assoc();
|
||||||
|
$jsonRaw = $row["json"];
|
||||||
|
} else {
|
||||||
|
die ("error occured ...");
|
||||||
|
}
|
||||||
|
$data = json_decode($jsonRaw);
|
||||||
|
$data[$_POST['TAG']] = $_POST['STATUS'];
|
||||||
|
$jsonRaw = json_encode($data)
|
||||||
// try to update the curent values:
|
// try to update the curent values:
|
||||||
$sql = " UPDATE `BUILD_snapshot`"
|
$sql = " UPDATE `BUILD_snapshot`"
|
||||||
." SET `BUILD_snapshot`.`".$_POST['TAG']."` = '".$_POST['STATUS']."'"
|
." SET `BUILD_snapshot`.`json` = '".$jsonRaw."'"
|
||||||
." WHERE `BUILD_snapshot`.`id-group` = '".$idGroup."'";
|
." WHERE `BUILD_snapshot`.`id-group` = '".$idGroup."'";
|
||||||
$result = $COVERAGE_bdd->query($sql);
|
$result = $COVERAGE_bdd->query($sql);
|
||||||
if ($result == TRUE) {
|
if ($result == TRUE) {
|
||||||
|
@ -26,6 +26,8 @@ parser.add_argument("-t", "--tag", help="Tag to register the system 'Linux',
|
|||||||
default="")
|
default="")
|
||||||
parser.add_argument("-S", "--status", help="Build status 'START', 'OK', 'ERROR' or $?",
|
parser.add_argument("-S", "--status", help="Build status 'START', 'OK', 'ERROR' or $?",
|
||||||
default="")
|
default="")
|
||||||
|
parser.add_argument("-G", "--stage", help="Stage of the BUILD: 'INIT', 'DOWNLOAD', 'CONFIGURE', 'BUILD', 'INSTALL', 'TEST', 'COVERAGE' or 'PACKAGE'",
|
||||||
|
default="")
|
||||||
parser.add_argument("-i", "--id", help="build ID (auto get env variable TRAVIS_BUILD_NUMBER)",
|
parser.add_argument("-i", "--id", help="build ID (auto get env variable TRAVIS_BUILD_NUMBER)",
|
||||||
default="")
|
default="")
|
||||||
###################
|
###################
|
||||||
@ -35,6 +37,7 @@ parser.add_argument("--test", help="test value (local server ...)",
|
|||||||
action="store_true")
|
action="store_true")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
if args.status not in ['START', 'OK', 'ERROR']:
|
if args.status not in ['START', 'OK', 'ERROR']:
|
||||||
#print("ploppp : '" + str(args.status) + "'")
|
#print("ploppp : '" + str(args.status) + "'")
|
||||||
if args.status == "0":
|
if args.status == "0":
|
||||||
@ -42,6 +45,9 @@ if args.status not in ['START', 'OK', 'ERROR']:
|
|||||||
else:
|
else:
|
||||||
args.status = 'ERROR'
|
args.status = 'ERROR'
|
||||||
|
|
||||||
|
if args.stage not in ['INIT', 'DOWNLOAD', 'CONFIGURE', 'BUILD', 'INSTALL', 'TEST', 'COVERAGE', 'PACKAGE']:
|
||||||
|
args.stage = 'NONE'
|
||||||
|
|
||||||
if args.test == True:
|
if args.test == True:
|
||||||
args.url = 'http://atria-soft.com/ci/build/inject'
|
args.url = 'http://atria-soft.com/ci/build/inject'
|
||||||
args.repo = 'HeeroYui/test'
|
args.repo = 'HeeroYui/test'
|
||||||
@ -49,6 +55,7 @@ if args.test == True:
|
|||||||
args.branch = 'master'
|
args.branch = 'master'
|
||||||
args.tag = 'Windows'
|
args.tag = 'Windows'
|
||||||
args.status = 'START'
|
args.status = 'START'
|
||||||
|
args.stage = 'NONE'
|
||||||
else:
|
else:
|
||||||
if len(args.tag) >= len("build:") \
|
if len(args.tag) >= len("build:") \
|
||||||
and args.tag[:6] == "build:":
|
and args.tag[:6] == "build:":
|
||||||
@ -59,6 +66,7 @@ else:
|
|||||||
print("[NOTE] build error, stop CI ...")
|
print("[NOTE] build error, stop CI ...")
|
||||||
exit(-3)
|
exit(-3)
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
if args.tag == "linux":
|
if args.tag == "linux":
|
||||||
args.tag = 'Linux';
|
args.tag = 'Linux';
|
||||||
if args.tag == "windows":
|
if args.tag == "windows":
|
||||||
@ -69,6 +77,9 @@ else:
|
|||||||
if args.tag not in list_tag:
|
if args.tag not in list_tag:
|
||||||
print("[ERROR] (local) set '--tag' parameter: " + str(list_tag))
|
print("[ERROR] (local) set '--tag' parameter: " + str(list_tag))
|
||||||
exit(-2)
|
exit(-2)
|
||||||
|
|
||||||
|
# no more limit in build type name ==> TODO: add regex to filter on string only
|
||||||
|
|
||||||
if args.status == "":
|
if args.status == "":
|
||||||
print("[ERROR] (local) set '--status' parameter")
|
print("[ERROR] (local) set '--status' parameter")
|
||||||
exit(-2)
|
exit(-2)
|
||||||
@ -110,13 +121,15 @@ print(" branch = " + args.branch)
|
|||||||
print(" tag = " + args.tag)
|
print(" tag = " + args.tag)
|
||||||
print(" status = " + args.status)
|
print(" status = " + args.status)
|
||||||
print(" build id = " + args.id)
|
print(" build id = " + args.id)
|
||||||
|
print(" STAGE = " + args.stage)
|
||||||
|
|
||||||
data = urllib.urlencode({'REPO':args.repo,
|
data = urllib.urlencode({'REPO':args.repo,
|
||||||
'SHA1':args.sha1,
|
'SHA1':args.sha1,
|
||||||
'LIB_BRANCH':args.branch,
|
'LIB_BRANCH':args.branch,
|
||||||
'TAG':args.tag,
|
'TAG':args.tag,
|
||||||
'STATUS':args.status,
|
'STATUS':args.status,
|
||||||
'ID':args.id})
|
'ID':args.id,
|
||||||
|
'STAGE':args.stage})
|
||||||
# I do this because my server is sometime down and need time to restart (return 408)
|
# I do this because my server is sometime down and need time to restart (return 408)
|
||||||
send_done = 5
|
send_done = 5
|
||||||
while send_done >= 0:
|
while send_done >= 0:
|
||||||
@ -138,7 +151,7 @@ if return_data[:7] == "[ERROR]":
|
|||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
if args.status == 'ERROR':
|
if args.status == 'ERROR':
|
||||||
print("[NOTE] build error, stop travis ...")
|
print("[NOTE] build error, stop travis/GITLAB-CI ...")
|
||||||
exit(-3)
|
exit(-3)
|
||||||
|
|
||||||
exit(0)
|
exit(0)
|
||||||
|
@ -77,12 +77,14 @@ if ($result->num_rows > 0) {
|
|||||||
errorSVG("To much value");
|
errorSVG("To much value");
|
||||||
}
|
}
|
||||||
$row = $result->fetch_assoc();
|
$row = $result->fetch_assoc();
|
||||||
$status = $row[$tag];
|
$jsonRaw = $row["json"];
|
||||||
} else {
|
} else {
|
||||||
$status = "---";
|
$jsonRaw = "{}";
|
||||||
//errorSVG("No Value");
|
//errorSVG("No Value");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data = json_decode($jsonRaw);
|
||||||
|
$status = $data[$tag];
|
||||||
|
|
||||||
//some coverage value :
|
//some coverage value :
|
||||||
if ($status == "UNKNOW") {
|
if ($status == "UNKNOW") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user