build: refs #6706 Migration to pnpm #1990

Merged
juan merged 12 commits from 6706-optimizeHooks into dev 2024-02-05 10:29:48 +00:00
5 changed files with 111 additions and 79 deletions
Showing only changes of commit f2071d39ec - Show all commits

4
Jenkinsfile vendored
View File

@ -53,7 +53,7 @@ pipeline {
TZ = 'Europe/Madrid' TZ = 'Europe/Madrid'
} }
parallel { parallel {
stage('Backend') { stage('Back') {
stages { stages {
stage('Install') { stage('Install') {
environment { environment {
@ -97,7 +97,7 @@ pipeline {
} }
} }
} }
stage('Frontend') { stage('Front') {
when { when {
expression { FROM_GIT } expression { FROM_GIT }
} }

34
back/tests-helper.js Normal file
View File

@ -0,0 +1,34 @@
/* eslint-disable no-console */
const app = require('vn-loopback/server/server');
let dataSources = require('../loopback/server/datasources.json');
async function init() {
console.log('Initializing backend.');
dataSources = JSON.parse(JSON.stringify(dataSources));
Object.assign(dataSources.vn, {
host: process.env.DB_HOST,
port: process.env.DB_PORT
});
const bootOptions = {dataSources};
await new Promise((resolve, reject) => {
app.boot(bootOptions,
err => err ? reject(err) : resolve());
});
// FIXME: Workaround to wait for loopback to be ready
await app.models.Application.status();
}
async function deinit() {
console.log('Stopping backend.');
await app.disconnect();
}
module.exports = {
init,
deinit
};
if (require.main === module)
init();

View File

@ -2,30 +2,21 @@
const path = require('path'); const path = require('path');
const Myt = require('@verdnatura/myt/myt'); const Myt = require('@verdnatura/myt/myt');
const Run = require('@verdnatura/myt/myt-run'); const Run = require('@verdnatura/myt/myt-run');
let dataSources = require('../loopback/server/datasources.json'); const helper = require('./tests-helper');
let server; let server;
const isCI = process.argv[2] === 'ci';
const PARALLEL = false;
const TIMEOUT = 900000;
process.on('warning', warning => { process.on('SIGINT', teardown);
console.log(warning.name); process.on('exit', teardown);
console.log(warning.message); process.on('uncaughtException', onError);
console.log(warning.stack); process.on('unhandledRejection', onError);
});
process.on('SIGUSR2', rmServer); async function setup() {
process.on('exit', rmServer);
async function rmServer() {
if (!server) return;
await server.rm();
server = null;
}
async function test() {
console.log('Building and running DB container.'); console.log('Building and running DB container.');
const isCI = process.argv[2] === 'ci';
const myt = new Myt(); const myt = new Myt();
await myt.init({ await myt.init({
workspace: path.join(__dirname, '..'), workspace: path.join(__dirname, '..'),
@ -36,69 +27,76 @@ async function test() {
}); });
server = await myt.run(Run); server = await myt.run(Run);
await myt.deinit(); await myt.deinit();
const {dbConfig} = server; const {dbConfig} = server;
process.env.DB_HOST = dbConfig.host;
process.env.DB_PORT = dbConfig.port;
console.log('Initializing backend.'); if (!PARALLEL)
await helper.init();
}
dataSources = JSON.parse(JSON.stringify(dataSources)); async function teardown() {
Object.assign(dataSources.vn, { if (!server) return;
host: dbConfig.host,
port: dbConfig.port
});
const bootOptions = {dataSources}; if (!PARALLEL)
const app = require('vn-loopback/server/server'); await helper.deinit();
await new Promise((resolve, reject) => {
app.boot(bootOptions,
err => err ? reject(err) : resolve());
});
// FIXME: Workaround to wait for loopback to be ready
await app.models.Application.status();
console.log('Running tests.'); console.log('Stopping and removing DB container.');
await server.rm();
server = null;
}
const Jasmine = require('jasmine'); async function onError(err) {
const jasmine = new Jasmine(); await teardown();
console.error(err);
}
const SpecReporter = require('jasmine-spec-reporter').SpecReporter; async function test() {
jasmine.addReporter(new SpecReporter({ let runner;
spec: { const config = {
displaySuccessful: isCI, globalSetup: setup,
displayPending: isCI globalSetupTimeout: TIMEOUT,
}, globalTeardown: teardown,
summary: { globalTeardownTimeout: TIMEOUT,
displayPending: false, spec_dir: '.',
} spec_files: [
})); 'back/**/*[sS]pec.js',
'loopback/**/*[sS]pec.js',
'modules/*/back/**/*.[sS]pec.js'
],
helpers: []
};
if (PARALLEL) {
const ParallelRunner = require('jasmine/parallel');
runner = new ParallelRunner({numWorkers: 1});
config.helpers.push(`back/tests-helper.js`);
} else {
const Jasmine = require('jasmine');
runner = new Jasmine();
const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
runner.addReporter(new SpecReporter({
spec: {
displaySuccessful: isCI,
displayPending: isCI
},
summary: {
displayPending: false,
}
}));
}
if (isCI) { if (isCI) {
const JunitReporter = require('jasmine-reporters'); const JunitReporter = require('jasmine-reporters');
jasmine.addReporter(new JunitReporter.JUnitXmlReporter()); runner.addReporter(new JunitReporter.JUnitXmlReporter());
runner.jasmine.DEFAULT_TIMEOUT_INTERVAL = TIMEOUT;
jasmine.exitOnCompletion = true;
jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 900000;
} }
const backSpecs = [ // runner.loadConfigFile('back/jasmine.json');
'./back/**/*[sS]pec.js', runner.loadConfig(config);
'./loopback/**/*[sS]pec.js', await runner.execute();
'./modules/*/back/**/*.[sS]pec.js'
];
jasmine.loadConfig({
spec_dir: '.',
spec_files: backSpecs,
helpers: [],
});
await jasmine.execute();
console.log('Stopping.');
if (app) await app.disconnect();
await rmServer();
console.log('Tests ended.\n');
} }
test(); test();

View File

@ -81,7 +81,7 @@
"html-loader-jest": "^0.2.1", "html-loader-jest": "^0.2.1",
"html-webpack-plugin": "^5.5.1", "html-webpack-plugin": "^5.5.1",
"identity-obj-proxy": "^3.0.0", "identity-obj-proxy": "^3.0.0",
"jasmine": "^5.0.0", "jasmine": "^5.0.2",
"jasmine-reporters": "^2.4.0", "jasmine-reporters": "^2.4.0",
"jasmine-spec-reporter": "^7.0.0", "jasmine-spec-reporter": "^7.0.0",
"jest": "^26.0.1", "jest": "^26.0.1",

View File

@ -206,8 +206,8 @@ devDependencies:
specifier: ^3.0.0 specifier: ^3.0.0
version: 3.0.0 version: 3.0.0
jasmine: jasmine:
specifier: ^5.0.0 specifier: ^5.0.2
version: 5.1.0 version: 5.0.2
jasmine-reporters: jasmine-reporters:
specifier: ^2.4.0 specifier: ^2.4.0
version: 2.5.2 version: 2.5.2
@ -8020,8 +8020,8 @@ packages:
filelist: 1.0.4 filelist: 1.0.4
minimatch: 3.1.2 minimatch: 3.1.2
/jasmine-core@5.1.1: /jasmine-core@5.0.1:
resolution: {integrity: sha512-UrzO3fL7nnxlQXlvTynNAenL+21oUQRlzqQFsA2U11ryb4+NLOCOePZ70PTojEaUKhiFugh7dG0Q+I58xlPdWg==} resolution: {integrity: sha512-D4bRej8CplwNtNGyTPD++cafJlZUphzZNV+MSAnbD3er4D0NjL4x9V+mu/SI+5129utnCBen23JwEuBZA9vlpQ==}
dev: true dev: true
/jasmine-reporters@2.5.2: /jasmine-reporters@2.5.2:
@ -8037,12 +8037,12 @@ packages:
colors: 1.4.0 colors: 1.4.0
dev: true dev: true
/jasmine@5.1.0: /jasmine@5.0.2:
resolution: {integrity: sha512-prmJlC1dbLhti4nE4XAPDWmfJesYO15sjGXVp7Cs7Ym5I9Xtwa/hUHxxJXjnpfLO72+ySttA0Ztf8g/RiVnUKw==} resolution: {integrity: sha512-fXgPcWfDhENJJVktFZc/JJ+TpdOQIMJTbn6BgSOIneBagrHtKvnyA8Ag6uD8eF2m7cSESG7K/Hfj/Hk5asAwNg==}
hasBin: true hasBin: true
dependencies: dependencies:
glob: 10.3.10 glob: 10.3.10
jasmine-core: 5.1.1 jasmine-core: 5.0.1
dev: true dev: true
/jayson@2.1.2: /jayson@2.1.2: