From 57a4ff286a707ec9c4d7f7814ebd1ea70ed6bd96 Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Fri, 24 May 2024 14:56:51 -0300 Subject: [PATCH 1/2] randomize node and java versions --- test-integration/scripts/99-write-matrix.js | 58 +++++++++++-------- .../workflow-samples/angular.json | 41 ++++--------- test-integration/workflow-samples/react.json | 13 ++--- test-integration/workflow-samples/vue.json | 14 ++--- 4 files changed, 54 insertions(+), 72 deletions(-) diff --git a/test-integration/scripts/99-write-matrix.js b/test-integration/scripts/99-write-matrix.js index 4d4d6b36097b..2583741e289c 100755 --- a/test-integration/scripts/99-write-matrix.js +++ b/test-integration/scripts/99-write-matrix.js @@ -1,6 +1,7 @@ #!/usr/bin/env node -import { writeFileSync, readFileSync } from 'fs'; -import { join } from 'path'; +import { createHash } from 'node:crypto'; +import { writeFileSync, readFileSync } from 'node:fs'; +import { join } from 'node:path'; import { packageRoot, JAVA_VERSION, @@ -21,6 +22,10 @@ try { existing = { include: [] }; } +const randomReproducibleValue = (str, choices) => { + return choices[createHash('shake256', { outputLength: 1 }).update(str, 'utf8').digest('binary').charCodeAt(0) % choices.length]; +}; + writeFileSync( MATRIX_FILE, JSON.stringify( @@ -34,28 +39,33 @@ writeFileSync( try { return JSON.parse(readFileSync(file).toString()) .include.filter(sample => !sample.disabled) - .map(({ generatorOptions, ...sample }) => ({ - workspaces: generatorOptions?.workspaces ? 'true' : undefined, - 'extra-args': `${generatorOptions?.workspaces ? ' --workspaces' : ''}${generatorOptions?.monorepository ? ' --monorepository' : ''}`, - 'setup-application-sample': sample['jhi-app-sample'] || sample['app-sample'] || 'jdl', - 'setup-application-environment': generatorOptions?.defaultEnvironment ?? 'prod', - 'setup-application-packaging': generatorOptions?.defaultPackaging ?? 'jar', - 'setup-entities-sample': sample.entity ?? 'none', - 'setup-jdl-entities-sample': sample['jdl-entity'] ?? '', - 'setup-jdl-sample': sample['jdl-samples'] ?? '', - java: sample['java-version'] ?? JAVA_VERSION, - node: sample['node-version'] ?? NODE_VERSION, - 'java-version': JAVA_VERSION, - 'node-version': NODE_VERSION, - 'npm-version': generatorOptions?.workspaces ? NPM_VERSION : undefined, - 'build-jhipster-bom': BUILD_JHIPSTER_BOM, - 'jhipster-bom-branch': BUILD_JHIPSTER_BOM ? JHIPSTER_BOM_BRANCH : undefined, - 'jhipster-bom-cicd-version': BUILD_JHIPSTER_BOM ? JHIPSTER_BOM_CICD_VERSION : undefined, - 'gradle-cache': generatorOptions?.workspaces || sample.name.includes('gradle') ? true : undefined, - ...sample, - 'skip-backend-tests': sample['skip-backend-tests'] ? 'true' : 'false', - 'skip-frontend-tests': sample['skip-frontend-tests'] ? 'true' : 'false', - })); + .map(({ generatorOptions, name, ...sample }) => { + const javaVersion = randomReproducibleValue(name, [JAVA_VERSION, '17', '21']); + const nodeVersion = randomReproducibleValue(name, [NODE_VERSION, '18', '20']); + return { + name, + workspaces: generatorOptions?.workspaces ? 'true' : undefined, + 'extra-args': `${generatorOptions?.workspaces ? ' --workspaces' : ''}${generatorOptions?.monorepository ? ' --monorepository' : ''}`, + 'setup-application-sample': sample['jhi-app-sample'] || sample['app-sample'] || 'jdl', + 'setup-application-environment': generatorOptions?.defaultEnvironment ?? 'prod', + 'setup-application-packaging': generatorOptions?.defaultPackaging ?? 'jar', + 'setup-entities-sample': sample.entity ?? 'none', + 'setup-jdl-entities-sample': sample['jdl-entity'] ?? '', + 'setup-jdl-sample': sample['jdl-samples'] ?? '', + java: javaVersion, + node: nodeVersion, + 'java-version': javaVersion, + 'node-version': nodeVersion, + 'npm-version': generatorOptions?.workspaces ? NPM_VERSION : undefined, + 'build-jhipster-bom': BUILD_JHIPSTER_BOM, + 'jhipster-bom-branch': BUILD_JHIPSTER_BOM ? JHIPSTER_BOM_BRANCH : undefined, + 'jhipster-bom-cicd-version': BUILD_JHIPSTER_BOM ? JHIPSTER_BOM_CICD_VERSION : undefined, + 'gradle-cache': generatorOptions?.workspaces || name.includes('gradle') ? true : undefined, + ...sample, + 'skip-backend-tests': sample['skip-backend-tests'] ? 'true' : 'false', + 'skip-frontend-tests': sample['skip-frontend-tests'] ? 'true' : 'false', + }; + }); } catch (error) { console.log(`File ${file} not found`, error); return []; diff --git a/test-integration/workflow-samples/angular.json b/test-integration/workflow-samples/angular.json index db88570715b8..3020f73455d7 100644 --- a/test-integration/workflow-samples/angular.json +++ b/test-integration/workflow-samples/angular.json @@ -10,15 +10,12 @@ "name": "ng-default-additional", "entity": "none", "app-sample": "ng-default", - "jdl-entity": "*", - "node-version": "20", - "java-version": "21" + "jdl-entity": "*" }, { "name": "ng-mysql-es-noi18n-mapsid", "app-sample": "ng-mysql-es-noi18n-mapsid", - "entity": "sql", - "node-version": "20" + "entity": "sql" }, { "name": "ng-mongodb-kafka-cucumber", @@ -26,8 +23,7 @@ "entity": "mongodb", "generatorOptions": { "defaultEnvironment": "dev" - }, - "java-version": "21" + } }, { "name": "ng-h2mem-ws-nol2", @@ -52,9 +48,7 @@ { "name": "ng-gradle-fr", "app-sample": "ng-gradle-fr", - "entity": "sql", - "node-version": "20", - "java-version": "21" + "entity": "sql" }, { "name": "ng-gradle-mariadb-oauth2-infinispan", @@ -62,8 +56,7 @@ "entity": "sql", "generatorOptions": { "defaultEnvironment": "dev" - }, - "node-version": "20" + } }, { "name": "ng-gradle-h2disk-ws-nocache", @@ -72,8 +65,7 @@ "generatorOptions": { "defaultEnvironment": "dev", "defaultPackaging": "war" - }, - "java-version": "21" + } }, { "name": "ng-webflux-mongodb", @@ -83,9 +75,7 @@ { "name": "ng-webflux-gradle-mongodb-oauth2", "app-sample": "webflux-mongodb-oauth2", - "entity": "mongodb", - "node-version": "20", - "java-version": "21" + "entity": "mongodb" }, { "name": "ng-webflux-psql-default", @@ -94,9 +84,7 @@ }, { "name": "ng-webflux-psql-additional", - "jdl-samples": "webflux-psql,custom-domain", - "node-version": "20", - "java-version": "21" + "jdl-samples": "webflux-psql,custom-domain" }, { "name": "ng-webflux-gradle-session-h2mem-es", @@ -104,15 +92,13 @@ "generatorOptions": { "defaultEnvironment": "dev" }, - "entity": "sqllight", - "node-version": "20" + "entity": "sqllight" }, { "name": "ng-webflux-couchbase", "disabled": "needs adjusts for sb3", "app-sample": "webflux-couchbase", - "entity": "couchbase", - "java-version": "21" + "entity": "couchbase" }, { "name": "ms-ng-oauth2-mongodb-caffeine", @@ -129,9 +115,7 @@ "generatorOptions": { "workspaces": true, "monorepository": true - }, - "node-version": "20", - "java-version": "21" + } }, { "name": "ms-mf-ng-consul-oauth2-neo4j", @@ -139,8 +123,7 @@ "generatorOptions": { "workspaces": true, "monorepository": true - }, - "node-version": "20" + } } ] } diff --git a/test-integration/workflow-samples/react.json b/test-integration/workflow-samples/react.json index 8cfbe63861f3..3215d7a93645 100644 --- a/test-integration/workflow-samples/react.json +++ b/test-integration/workflow-samples/react.json @@ -11,21 +11,17 @@ "entity": "sql", "generatorOptions": { "defaultEnvironment": "dev" - }, - "node-version": "20", - "java-version": "21" + } }, { "name": "react-gradle-mysql-es-noi18n-mapsid", "app-sample": "react-gradle-mysql-es-noi18n-mapsid", - "entity": "sql", - "node-version": "20" + "entity": "sql" }, { "name": "react-gradle-cassandra-session-redis", "app-sample": "react-gradle-cassandra-session-redis", - "entity": "cassandra", - "java-version": "21" + "entity": "cassandra" }, { "name": "ms-react-consul-jwt-cassandra-redis", @@ -33,8 +29,7 @@ "generatorOptions": { "workspaces": true, "monorepository": true - }, - "java-version": "21" + } }, { "name": "ms-mf-react-eureka-oauth2-mariadb-infinispan", diff --git a/test-integration/workflow-samples/vue.json b/test-integration/workflow-samples/vue.json index 6b8cfc7cf055..cc1eea870319 100644 --- a/test-integration/workflow-samples/vue.json +++ b/test-integration/workflow-samples/vue.json @@ -9,22 +9,17 @@ "name": "vue-default-additional", "app-sample": "vue-default", "entity": "none", - "jdl-entity": "custom-id", - "node-version": "20", - "java-version": "21" + "jdl-entity": "custom-id" }, { "name": "vue-noi18n-mysql-ws-oauth2", "app-sample": "vue-noi18n-ws-oauth2", - "entity": "sqlfull", - "node-version": "20", - "java-version": "21" + "entity": "sqlfull" }, { "name": "vue-fulli18n-mysql-es", "app-sample": "vue-fulli18n-es", - "entity": "sql", - "node-version": "20" + "entity": "sql" }, { "name": "vue-gradle-h2mem-ws-session", @@ -32,8 +27,7 @@ "entity": "sql", "generatorOptions": { "defaultEnvironment": "dev" - }, - "java-version": "21" + } }, { "name": "vue-h2disk-ws-theme", From 12992f417c438b4b50894390429fbee70c14b9ad Mon Sep 17 00:00:00 2001 From: Marcelo Boveto Shima Date: Fri, 24 May 2024 15:50:21 -0300 Subject: [PATCH 2/2] change seed for node and java --- test-integration/scripts/99-write-matrix.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test-integration/scripts/99-write-matrix.js b/test-integration/scripts/99-write-matrix.js index 2583741e289c..082215ef0510 100755 --- a/test-integration/scripts/99-write-matrix.js +++ b/test-integration/scripts/99-write-matrix.js @@ -22,8 +22,8 @@ try { existing = { include: [] }; } -const randomReproducibleValue = (str, choices) => { - return choices[createHash('shake256', { outputLength: 1 }).update(str, 'utf8').digest('binary').charCodeAt(0) % choices.length]; +const randomReproducibleValue = (seed, choices) => { + return choices[createHash('shake256', { outputLength: 1 }).update(seed, 'utf8').digest('binary').charCodeAt(0) % choices.length]; }; writeFileSync( @@ -40,8 +40,8 @@ writeFileSync( return JSON.parse(readFileSync(file).toString()) .include.filter(sample => !sample.disabled) .map(({ generatorOptions, name, ...sample }) => { - const javaVersion = randomReproducibleValue(name, [JAVA_VERSION, '17', '21']); - const nodeVersion = randomReproducibleValue(name, [NODE_VERSION, '18', '20']); + const javaVersion = randomReproducibleValue(`java-${name}`, [JAVA_VERSION, '17', '21']); + const nodeVersion = randomReproducibleValue(`node-${name}`, [NODE_VERSION, '18', '20']); return { name, workspaces: generatorOptions?.workspaces ? 'true' : undefined,