build: refs #6706 Migration to pnpm #1990
|
@ -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 }
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
116
back/tests.js
116
back/tests.js
|
@ -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,32 +27,57 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onError(err) {
|
||||||
|
await teardown();
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function test() {
|
||||||
|
let runner;
|
||||||
|
const config = {
|
||||||
|
globalSetup: setup,
|
||||||
|
globalSetupTimeout: TIMEOUT,
|
||||||
|
globalTeardown: teardown,
|
||||||
|
globalTeardownTimeout: TIMEOUT,
|
||||||
|
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');
|
const Jasmine = require('jasmine');
|
||||||
const jasmine = new Jasmine();
|
runner = new Jasmine();
|
||||||
|
|
||||||
const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
|
const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
|
||||||
jasmine.addReporter(new SpecReporter({
|
runner.addReporter(new SpecReporter({
|
||||||
spec: {
|
spec: {
|
||||||
displaySuccessful: isCI,
|
displaySuccessful: isCI,
|
||||||
displayPending: isCI
|
displayPending: isCI
|
||||||
|
@ -70,35 +86,17 @@ async function test() {
|
||||||
displayPending: false,
|
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();
|
||||||
|
|
|
@ -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",
|
||||||
|
|
|
@ -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:
|
||||||
|
|
Loading…
Reference in New Issue