[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,
|
||||
`sha1` varchar(512) NOT NULL,
|
||||
`tag` varchar(512) NOT NULL,
|
||||
`status` enum('UNKNOW','START','ERROR','OK') NOT NULL DEFAULT 'UNKNOW',
|
||||
`build-id` int(32) NOT NULL
|
||||
`status` enum('UNKNOW','START','ERROR','OK') NOT NULL DEFAULT 'UNKNOW'
|
||||
`stage` enum('INIT', 'DOWNLOAD', 'CONFIGURE', 'BUILD', 'INSTALL', 'TEST', 'COVERAGE', 'PACKAGE', 'NONE') NOT NULL DEFAULT 'NONE'
|
||||
) 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` (
|
||||
`id-build` varchar(256) NOT NULL,
|
||||
`id-group` int(11) NOT NULL DEFAULT '0',
|
||||
`Linux` enum('UNKNOW','START','ERROR','OK') NOT NULL DEFAULT 'UNKNOW',
|
||||
`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'
|
||||
`json` text NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
@ -83,19 +83,20 @@ if ($exist == FALSE) {
|
||||
if ($idGroup <= -1) {
|
||||
echo("[ERROR] can not create or find group");
|
||||
} 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()."',"
|
||||
." '".$idGroup."',"
|
||||
." '".$_POST['SHA1']."',"
|
||||
." '".$_POST['TAG']."',"
|
||||
." '".$_POST['STATUS']."',"
|
||||
." '".$_POST['ID']."')";
|
||||
." '".$_POST['STAGE']."')";
|
||||
//echo $sql;
|
||||
$result = $COVERAGE_bdd->query($sql);
|
||||
if ($result == FALSE) {
|
||||
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`"
|
||||
." , `CI_group`"
|
||||
." WHERE `CI_group`.`user-name` = '".$userName."'"
|
||||
@ -108,10 +109,10 @@ if ($idGroup <= -1) {
|
||||
if ( $result == NULL
|
||||
|| $result->num_rows == 0) {
|
||||
// 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']."',"
|
||||
." '".$idGroup."',"
|
||||
." '".$_POST['STATUS']."')";
|
||||
." '{\"".$_POST['TAG']."\":\"".$_POST['STATUS']."\"')";
|
||||
$result = $COVERAGE_bdd->query($sql);
|
||||
if ($result == TRUE) {
|
||||
echo("[OK] registered done (new entry)");
|
||||
@ -119,9 +120,19 @@ if ($idGroup <= -1) {
|
||||
echo("[ERROR] Can not register in db ... (snapshot 1)");
|
||||
}
|
||||
} 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:
|
||||
$sql = " UPDATE `BUILD_snapshot`"
|
||||
." SET `BUILD_snapshot`.`".$_POST['TAG']."` = '".$_POST['STATUS']."'"
|
||||
." SET `BUILD_snapshot`.`json` = '".$jsonRaw."'"
|
||||
." WHERE `BUILD_snapshot`.`id-group` = '".$idGroup."'";
|
||||
$result = $COVERAGE_bdd->query($sql);
|
||||
if ($result == TRUE) {
|
||||
|
@ -26,6 +26,8 @@ parser.add_argument("-t", "--tag", help="Tag to register the system 'Linux',
|
||||
default="")
|
||||
parser.add_argument("-S", "--status", help="Build status 'START', 'OK', 'ERROR' or $?",
|
||||
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)",
|
||||
default="")
|
||||
###################
|
||||
@ -35,6 +37,7 @@ parser.add_argument("--test", help="test value (local server ...)",
|
||||
action="store_true")
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
if args.status not in ['START', 'OK', 'ERROR']:
|
||||
#print("ploppp : '" + str(args.status) + "'")
|
||||
if args.status == "0":
|
||||
@ -42,6 +45,9 @@ if args.status not in ['START', 'OK', 'ERROR']:
|
||||
else:
|
||||
args.status = 'ERROR'
|
||||
|
||||
if args.stage not in ['INIT', 'DOWNLOAD', 'CONFIGURE', 'BUILD', 'INSTALL', 'TEST', 'COVERAGE', 'PACKAGE']:
|
||||
args.stage = 'NONE'
|
||||
|
||||
if args.test == True:
|
||||
args.url = 'http://atria-soft.com/ci/build/inject'
|
||||
args.repo = 'HeeroYui/test'
|
||||
@ -49,6 +55,7 @@ if args.test == True:
|
||||
args.branch = 'master'
|
||||
args.tag = 'Windows'
|
||||
args.status = 'START'
|
||||
args.stage = 'NONE'
|
||||
else:
|
||||
if len(args.tag) >= len("build:") \
|
||||
and args.tag[:6] == "build:":
|
||||
@ -59,6 +66,7 @@ else:
|
||||
print("[NOTE] build error, stop CI ...")
|
||||
exit(-3)
|
||||
exit(0)
|
||||
|
||||
if args.tag == "linux":
|
||||
args.tag = 'Linux';
|
||||
if args.tag == "windows":
|
||||
@ -69,6 +77,9 @@ else:
|
||||
if args.tag not in list_tag:
|
||||
print("[ERROR] (local) set '--tag' parameter: " + str(list_tag))
|
||||
exit(-2)
|
||||
|
||||
# no more limit in build type name ==> TODO: add regex to filter on string only
|
||||
|
||||
if args.status == "":
|
||||
print("[ERROR] (local) set '--status' parameter")
|
||||
exit(-2)
|
||||
@ -110,13 +121,15 @@ print(" branch = " + args.branch)
|
||||
print(" tag = " + args.tag)
|
||||
print(" status = " + args.status)
|
||||
print(" build id = " + args.id)
|
||||
print(" STAGE = " + args.stage)
|
||||
|
||||
data = urllib.urlencode({'REPO':args.repo,
|
||||
'SHA1':args.sha1,
|
||||
'LIB_BRANCH':args.branch,
|
||||
'TAG':args.tag,
|
||||
'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)
|
||||
send_done = 5
|
||||
while send_done >= 0:
|
||||
@ -138,7 +151,7 @@ if return_data[:7] == "[ERROR]":
|
||||
exit(-1)
|
||||
|
||||
if args.status == 'ERROR':
|
||||
print("[NOTE] build error, stop travis ...")
|
||||
print("[NOTE] build error, stop travis/GITLAB-CI ...")
|
||||
exit(-3)
|
||||
|
||||
exit(0)
|
||||
|
@ -77,12 +77,14 @@ if ($result->num_rows > 0) {
|
||||
errorSVG("To much value");
|
||||
}
|
||||
$row = $result->fetch_assoc();
|
||||
$status = $row[$tag];
|
||||
$jsonRaw = $row["json"];
|
||||
} else {
|
||||
$status = "---";
|
||||
$jsonRaw = "{}";
|
||||
//errorSVG("No Value");
|
||||
}
|
||||
|
||||
$data = json_decode($jsonRaw);
|
||||
$status = $data[$tag];
|
||||
|
||||
//some coverage value :
|
||||
if ($status == "UNKNOW") {
|
||||
|
Loading…
x
Reference in New Issue
Block a user