handle build version for ci builds

This commit is contained in:
andreas 2023-10-06 19:57:32 +02:00
parent 1da9fea9a4
commit 10058cfeec
5 changed files with 58 additions and 17 deletions

12
post.py
View File

@ -63,17 +63,17 @@ def post(source,target,env):
for f in glob.glob(os.path.join(outdir,base+"*.bin")): for f in glob.glob(os.path.join(outdir,base+"*.bin")):
print("removing old file %s"%f) print("removing old file %s"%f)
os.unlink(f) os.unlink(f)
ofversion='' outfile=os.path.join(outdir,"%s-all.bin"%(base))
if not version.startswith('dev'):
ofversion="-"+version
versionedFile=os.path.join(outdir,"%s%s-update.bin"%(base,ofversion))
shutil.copyfile(firmware,versionedFile)
outfile=os.path.join(outdir,"%s%s-all.bin"%(base,ofversion))
cmd=[python,esptool,"--chip",chip,"merge_bin","--target-offset",offset,"-o",outfile] cmd=[python,esptool,"--chip",chip,"merge_bin","--target-offset",offset,"-o",outfile]
cmd+=uploadfiles cmd+=uploadfiles
cmd+=[appoffset,firmware] cmd+=[appoffset,firmware]
print("running %s"%" ".join(cmd)) print("running %s"%" ".join(cmd))
env.Execute(" ".join(cmd),"#testpost") env.Execute(" ".join(cmd),"#testpost")
ofversion="-"+version
versionedFile=os.path.join(outdir,"%s%s-update.bin"%(base,ofversion))
shutil.copyfile(firmware,versionedFile)
versioneOutFile=os.path.join(outdir,"%s%s-all.bin"%(base,ofversion))
shutil.copyfile(outfile,versioneOutFile)
env.AddPostAction( env.AddPostAction(
"$BUILD_DIR/${PROGNAME}.bin", "$BUILD_DIR/${PROGNAME}.bin",
post post

View File

@ -35,6 +35,10 @@
width: 10em; width: 10em;
opacity: 0.6; opacity: 0.6;
padding: 0; padding: 0;
flex-shrink: 0;
}
.configui .row .value{
padding-left: 0;
} }
.configui .since { .configui .since {
display: block; display: block;

View File

@ -18,6 +18,10 @@
<span class="label" >GitSha</span> <span class="label" >GitSha</span>
<span class="value" id="gitSha">---</span> <span class="value" id="gitSha">---</span>
</div> </div>
<div class="row">
<span class="label" >Version</span>
<span class="value" id="buildVersion"></span>
</div>
<div class="row"> <div class="row">
<button id="downloadConfig">SaveCfg</button> <button id="downloadConfig">SaveCfg</button>
<button id="uploadConfig">LoadCfg</button> <button id="uploadConfig">LoadCfg</button>
@ -27,11 +31,11 @@
</div> </div>
<div class="row"> <div class="row">
<span class="label">Board type</span> <span class="label">Board type</span>
<input type="text" id="environment" disabled/> <div class="value" id="environment" ></div>
</div> </div>
<div class="row"> <div class="row">
<span class="label">Build Flags</span> <span class="label">Build Flags</span>
<input type="text" id="buildflags" disabled> <div class="value" id="buildflags"></div>
</div> </div>
<div class="row hidden error"> <div class="row hidden error">
<span class="label">Error</span> <span class="label">Error</span>

View File

@ -51,6 +51,7 @@ class PipelineInfo{
let displayMode='last'; let displayMode='last';
let delayedSearch=undefined; let delayedSearch=undefined;
let gitSha=undefined; let gitSha=undefined;
let buildVersion=undefined;
const modeStrings={ const modeStrings={
last: 'Last Build', last: 'Last Build',
existing: 'Existing Build', existing: 'Existing Build',
@ -73,15 +74,20 @@ class PipelineInfo{
setVisible('download',currentPipeline.valid() && currentPipeline.downloadUrl!==undefined,true); setVisible('download',currentPipeline.valid() && currentPipeline.downloadUrl!==undefined,true);
setVisible('status_url',currentPipeline.valid() && currentPipeline.status_url!==undefined,true); setVisible('status_url',currentPipeline.valid() && currentPipeline.status_url!==undefined,true);
setVisible('error',currentPipeline.error!==undefined,true); setVisible('error',currentPipeline.error!==undefined,true);
let e=document.getElementById('configError'); let values={};
if (e.textContent) { fillValues(values,['configError','environment']);
if (values.textContent) {
enableEl('start',false);
return;
}
if (!values.environment){
enableEl('start',false); enableEl('start',false);
return; return;
} }
if (displayMode != 'existing'){ if (displayMode != 'existing'){
if (currentPipeline.valid()){ if (currentPipeline.valid()){
//check pipeline state //check pipeline state
if (['error','success','canceled'].indexOf(currentPipeline.status) >= 0){ if (['error','success','canceled','failed'].indexOf(currentPipeline.status) >= 0){
enableEl('start',true); enableEl('start',true);
return; return;
} }
@ -91,8 +97,9 @@ class PipelineInfo{
enableEl('start',true); enableEl('start',true);
return; return;
} }
//display node existing //display mode existing
enableEl('start',!currentPipeline.valid()); //allow start if either no pipeline or not running and status != success
enableEl('start',!currentPipeline.valid() || (!currentPipeline.isRunning() && currentPipeline.status != "success"));
} }
const isRunning=()=>{ const isRunning=()=>{
return currentPipeline.isRunning(); return currentPipeline.isRunning();
@ -154,10 +161,13 @@ class PipelineInfo{
updateStatus(); updateStatus();
if (gitSha !== undefined) param.tag=gitSha; if (gitSha !== undefined) param.tag=gitSha;
param.config=JSON.stringify(config); param.config=JSON.stringify(config);
if (buildVersion !== undefined){
param.suffix="-"+buildVersion;
}
fetchJson(API,Object.assign({ fetchJson(API,Object.assign({
api:'start'},param)) api:'start'},param))
.then((json)=>{ .then((json)=>{
let status=json.status || 'error'; let status=json.status || json.state|| 'error';
if (status === 'error'){ if (status === 'error'){
currentPipeline.update({status:status,error:json.error}) currentPipeline.update({status:status,error:json.error})
updateStatus(); updateStatus();
@ -367,8 +377,10 @@ class PipelineInfo{
} }
} }
} }
document.getElementById('environment').value=environment; if (buildVersion !== undefined){
document.getElementById('buildflags').value=flags; flags+=" -DGWRELEASEVERSION="+buildVersion;
}
setValues({environment:environment,buildflags:flags});
//check resources //check resources
for (let k in currentResources){ for (let k in currentResources){
let resList=currentResources[k]; let resList=currentResources[k];
@ -484,6 +496,26 @@ class PipelineInfo{
else{ else{
setValue('gitSha',gitSha); setValue('gitSha',gitSha);
} }
let bot=document.getElementById('branchOrTag');
let botv=document.getElementById('branchOrTagValue');
if (bot && botv){
let type=bot.textContent;
let val=botv.textContent;
if (type && val){
if (type != 'release' && type != 'tag'){
val=type+val;
}
val=val.replace(/[:.]/g,'_');
val=val.replace(/[^a-zA-Z0-9_]*/g,'');
if (val.length > 32){
val=val.substring(val.length-32)
}
if (val.length > 0){
buildVersion=val;
setValue('buildVersion',buildVersion);
}
}
}
if (gitSha !== undefined){ if (gitSha !== undefined){
let url=buildUrl(GITAPI,Object.assign({},gitParam,{sha:gitSha,proxy:'webinstall/build.yaml'})); let url=buildUrl(GITAPI,Object.assign({},gitParam,{sha:gitSha,proxy:'webinstall/build.yaml'}));
try{ try{

View File

@ -50,7 +50,8 @@ const fillValues=(values,items)=>{
items.forEach((it)=>{ items.forEach((it)=>{
let e=document.getElementById(it); let e=document.getElementById(it);
if (e){ if (e){
values[it]=e.value; //TODO: type of el if (e.tagName == 'INPUT') values[it]=e.value;
if (e.tagName == 'DIV' || e.tagName == 'SPAN') values [it]=e.textContent;
} }
}) })
}; };