summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Fankhauser hiddenalpha.ch2024-04-30 15:40:45 +0200
committerAndreas Fankhauser hiddenalpha.ch2024-04-30 15:40:45 +0200
commite6cfa987f8b946c0ad1998e3561115f138aef54e (patch)
tree9894b3ce19d6c50e8c36ed79e938c2c0b72b125f
parent37d0a8ba8bb4cee538b5cf7ff2c7686d203f7a02 (diff)
downloadUnspecifiedGarbage-e6cfa987f8b946c0ad1998e3561115f138aef54e.zip
UnspecifiedGarbage-e6cfa987f8b946c0ad1998e3561115f138aef54e.tar.gz
Doc how to get mvn version. Make noslim helper print isaVersion.
-rw-r--r--doc/note/links/links.txt4
-rw-r--r--doc/note/maven/maven.txt2
-rw-r--r--src/main/nodejs/paisa-nonslim/foo.js97
3 files changed, 100 insertions, 3 deletions
diff --git a/doc/note/links/links.txt b/doc/note/links/links.txt
index 838cc1d..25dedde 100644
--- a/doc/note/links/links.txt
+++ b/doc/note/links/links.txt
@@ -590,3 +590,7 @@ Links (Aka argument amplifiers)
## (TODO put to a better place in here)
- [how to handle vertx promise fail/errors properly](https://github.com/swisspost/vertx-redisques/pull/164#discussion_r1562105007)
+- [null VS empty](https://jira.post.ch/browse/SDCISA-14534)
+
+
+
diff --git a/doc/note/maven/maven.txt b/doc/note/maven/maven.txt
index 4349551..a9fd248 100644
--- a/doc/note/maven/maven.txt
+++ b/doc/note/maven/maven.txt
@@ -14,6 +14,8 @@ mvn versions:set-property -DgenerateBackupPoms=false -DallowSnapshots=true -Dpro
export MAVEN_OPTS="..."
+## Get project version without any other bullshit
+mvn help:evaluate -o -q -DforceStdout -Dexpression=project.version && echo
## Deploy paisa snapshot
mvn deploy -DaltDeploymentRepository=artifactory-snapshots::default::https://artifactory.tools.pnet.ch/artifactory/libs-snapshot-local
diff --git a/src/main/nodejs/paisa-nonslim/foo.js b/src/main/nodejs/paisa-nonslim/foo.js
index 8408497..3d4f3e8 100644
--- a/src/main/nodejs/paisa-nonslim/foo.js
+++ b/src/main/nodejs/paisa-nonslim/foo.js
@@ -12,6 +12,7 @@ Related:
const zlib = require("zlib");
const noop = function(){};
const log = process.stderr;
+ const out = process.stdout;
const logAsString = function( buf ){ log.write(buf.toString()); };
setImmediate(main);
@@ -45,6 +46,9 @@ Related:
+" remote git repo). The force variant will replace existing branches\n"
+" on the remnote. If given multiple times, less-invasive wins.\n"
+" \n"
+ +" --print-isa-version\n"
+ +" Prints an isaVersion JSON that can be fed to preflux.\n"
+ +" \n"
// not impl yet
//+" --max-parallel <int>\n"
//+" How many tasks to run concurrently. Defaults to 1. Which means to\n"
@@ -79,8 +83,8 @@ Related:
}else if( arg == "--push-force" ){
if( app.isPush ){ log.write("EINVAL: only one of push and push-force allowed\n"); return-1; }
app.isPushForce = true;
- }else if( arg == "--reset-hard-to-develop" ){
- app.isResetHardToDevelop = true;
+ }else if( arg == "--print-isa-version" ){
+ app.isPrintIsaVersion = true;
//}else if( arg == "--max-parallel" ){
// arg = argv[++iA];
// if( !/^[0-9]+$/.test(arg) ){ log.write("EINVAL: --max-parallel "+ arg +"\n"); return -1; }
@@ -204,6 +208,90 @@ Related:
}
+ function getVersionByServiceName(app, svcName, onDone){
+ /* if we did patch services, we already know the version without
+ * lookup. This is a performance optimization, because maven performs
+ * absolutely terrible. Performance DOES matter! */
+ //if( app.isPatchServices ){
+ setImmediate(onDone, null, app.jenkinsSnapVersion);
+ //}else{
+ // wasteOurTimeBecausePerformanceDoesNotMatter();
+ //}
+ //function wasteOurTimeBecausePerformanceDoesNotMatter( ex ){
+ // if( ex ) throw ex;
+ // var stdoutBufs = [];
+ // /* SHOULD start maven with low prio to not kill windoof. But I
+ // * guess spawning a process with other prio is YAGNI, and so we're
+ // * now fucked. Therefore I wish you happy time-wasting, as the only
+ // * option left is to NOT start too many maven childs
+ // * simultaneously. */
+ // var child = child_process.spawn(
+ // "mvn", ["help:evaluate", "-o", "-q", "-DforceStdout", "-Dexpression=project.version"],
+ // { cwd:workdirOfSync(app, svcName) }
+ // );
+ // child.on("error", console.error.bind(console));
+ // child.stderr.on("data", logAsString);
+ // child.stdout.on("data", stdoutBufs.push.bind(stdoutBufs));
+ // child.on("close", function( code, signal ){
+ // if( code !== 0 || signal !== null ){
+ // endFn(Error("code="+ code +", signal="+ signal +""));
+ // return;
+ // }
+ // if( stdoutBufs.length <= 0 ) throw Error("maven has failed");
+ // var version = stdoutBufs.join().trim();
+ // onDone(null, version);
+ // });
+ //}
+ }
+
+
+ function printIsaVersion( app, onDone ){
+ var iSvcQuery = 0, iSvcPrinted = 0;
+ printIntro();
+ function printIntro( ex ){
+ if( ex ) throw ex;
+ var epochMs = Date.now();
+ out.write('{\n');
+ out.write(' "timestamp": "'+ new Date().toISOString() +'",\n');
+ out.write(' "isaVersionId": "SDCISA-15648-'+ epochMs +'",\n');
+ out.write(' "isaVersionName": "SDCISA-15648-'+ epochMs +'",\n');
+ out.write(' "trial": true,\n');
+ out.write(' "services": [\n');
+ out.write(' { "name": "eagle", "version": "02.23.01.00" },\n');
+ out.write(' { "name": "storage", "version": "00.25.00.02" },\n');
+ out.write(' { "name": "platform", "version": "'+ app.platformJenkinsVersion +'" }');
+ /* maven performance is an absolute terrible monster.
+ * Problem 1: Doing this sequentially takes forever.
+ * Problem 2: Doing this parallel for all makes windoof freeze.
+ * Workaround: Do at most a few of them in parallel. */
+ for( var i = 3 ; i ; --i ) nextService();
+ }
+ function nextService( ex ){
+ if( ex ) throw ex;
+ if( iSvcQuery >= app.services.length ){ /*printTail();*/ return; }
+ var svcName = app.services[iSvcQuery++];
+ getVersionByServiceName(app, svcName, function(e,r){ printService(e,r,svcName); });
+ }
+ function printService( ex, svcVersion, svcName ){
+ if( ex ) throw ex;
+ if( typeof svcVersion != "string") throw Error(svcVersion);
+ iSvcPrinted += 1;
+ out.write(",\n ");
+ out.write('{ "name": "'+ svcName +'", "version": "'+ svcVersion +'" }');
+ if( iSvcPrinted >= app.services.length ){ printTail(); }else{ nextService(); }
+ }
+ function printTail( ex ){
+ if( ex ) throw ex;
+ out.write('\n');
+ out.write(' ],\n');
+ out.write(' "featureSwitches": [],\n');
+ out.write(' "mergedBundles": []\n');
+ out.write('}\n');
+ onDone(/*ex*/null, /*ret*/null);
+ }
+ }
+
+
function pushService( app, thingyName, onDone ){
if( typeof onDone != "function" ){ throw TypeError("onDone"); }
var iRemoteNameToTry = 0;
@@ -757,6 +845,7 @@ Related:
forEachJettyService(app, pushService, onDone);
});
}
+ if( app.isPrintIsaVersion ){ actions.push(printIsaVersion); }
actions.push(function( app, onDone ){
log.write("[INFO ] App done\n");
});
@@ -780,7 +869,7 @@ Related:
iscommit: false,
isPush: false,
isPushForce: false,
- isResetHardToDevelop: false,
+ isPrintIsaVersion: false,
remoteNamesToTry: ["origin"],
workdir: "C:/work/tmp/git-scripted",
maxParallel: 1,
@@ -790,6 +879,8 @@ Related:
commitMsg: "[SDCISA-15648] Remove slim packaging",
platformSnapVersion: "0.0.0-SNAPSHOT",
serviceSnapVersion: "0.0.0-SNAPSHOT",
+ platformJenkinsVersion: "0.0.0-SDCISA-15648-RemoveSlimPackaging-n1-SNAPSHOT",
+ jenkinsSnapVersion: "0.0.0-SDCISA-15648-RemoveSlimPackaging-n1-SNAPSHOT",
parentVersion: null,
};
app.parentVersion = "0.0.0-"+ app.branchName +"-SNAPSHOT";