ci: refs#6706 CI fixes
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Juan Ferrer 2024-02-06 21:51:15 +01:00
parent a8a5ddd889
commit a67a347a9e
9 changed files with 61 additions and 33 deletions

View File

@ -1,4 +1,6 @@
node_modules node_modules
print/node_modules print/node_modules
front/node_modules front
services db
e2e
storage

23
Jenkinsfile vendored
View File

@ -86,9 +86,6 @@ pipeline {
} }
} }
stage('Stack') { stage('Stack') {
environment {
TZ = 'Europe/Madrid'
}
parallel { parallel {
stage('Back') { stage('Back') {
stages { stages {
@ -104,14 +101,10 @@ pipeline {
} }
post { post {
always { always {
script { junit(
try { testResults: 'junitresults.xml',
junit 'junitresults.xml' allowEmptyResults: true
junit 'junit.xml' )
} catch (e) {
echo e.toString()
}
}
} }
} }
} }
@ -144,6 +137,14 @@ pipeline {
steps { steps {
sh 'jest --ci --reporters=default --reporters=jest-junit --maxWorkers=10' sh 'jest --ci --reporters=default --reporters=jest-junit --maxWorkers=10'
} }
post {
always {
junit(
testResults: 'junit.xml',
allowEmptyResults: true
)
}
}
} }
stage('Build') { stage('Build') {
when { when {

View File

@ -1,19 +1,36 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
const path = require('path'); const path = require('path');
const getopts = require('getopts');
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');
const helper = require('./tests-helper'); const helper = require('./tests-helper');
const opts = getopts(process.argv.slice(2), {
string: [
'network'
],
boolean: [
'ci',
'junit'
]
});
let server; let server;
const isCI = process.argv[2] === 'ci';
const PARALLEL = false; const PARALLEL = false;
const TIMEOUT = 900000; const TIMEOUT = 900000;
process.on('SIGINT', teardown);
process.on('exit', teardown); process.on('exit', teardown);
process.on('uncaughtException', onError); process.on('uncaughtException', onError);
process.on('unhandledRejection', onError); process.on('unhandledRejection', onError);
const exitSignals = [
'SIGINT',
'SIGUSR1',
'SIGUSR2'
];
for (const signal of exitSignals)
process.on(signal, () => process.exit());
async function setup() { async function setup() {
console.log('Building and running DB container.'); console.log('Building and running DB container.');
@ -21,9 +38,9 @@ async function setup() {
await myt.init({ await myt.init({
workspace: path.join(__dirname, '..'), workspace: path.join(__dirname, '..'),
random: true, random: true,
ci: isCI, ci: opts.ci,
tmpfs: process.platform == 'linux', tmpfs: process.platform == 'linux',
network: isCI ? 'jenkins' : null network: opts.network || null
}); });
server = await myt.run(Run); server = await myt.run(Run);
await myt.deinit(); await myt.deinit();
@ -38,18 +55,19 @@ async function setup() {
async function teardown() { async function teardown() {
if (!server) return; if (!server) return;
const oldServer = server;
server = null;
if (!PARALLEL) if (!PARALLEL)
await helper.deinit(); await helper.deinit();
console.log('Stopping and removing DB container.'); console.log('Stopping and removing DB container.');
await server.rm(); await oldServer.rm();
server = null;
} }
async function onError(err) { async function onError(err) {
await teardown();
console.error(err); console.error(err);
process.exit(1);
} }
async function test() { async function test() {
@ -79,8 +97,8 @@ async function test() {
const SpecReporter = require('jasmine-spec-reporter').SpecReporter; const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
runner.addReporter(new SpecReporter({ runner.addReporter(new SpecReporter({
spec: { spec: {
displaySuccessful: isCI, displaySuccessful: opts.ci,
displayPending: isCI displayPending: opts.ci
}, },
summary: { summary: {
displayPending: false, displayPending: false,
@ -88,11 +106,12 @@ async function test() {
})); }));
} }
if (isCI) { if (opts.junit) {
const JunitReporter = require('jasmine-reporters'); const JunitReporter = require('jasmine-reporters');
runner.addReporter(new JunitReporter.JUnitXmlReporter()); runner.addReporter(new JunitReporter.JUnitXmlReporter());
runner.jasmine.DEFAULT_TIMEOUT_INTERVAL = TIMEOUT;
} }
if (opts.ci)
runner.jasmine.DEFAULT_TIMEOUT_INTERVAL = TIMEOUT;
// runner.loadConfigFile('back/jasmine.json'); // runner.loadConfigFile('back/jasmine.json');
runner.loadConfig(config); runner.loadConfig(config);

View File

@ -3,8 +3,9 @@ services:
front: front:
image: registry.verdnatura.es/salix-front:${VERSION:?} image: registry.verdnatura.es/salix-front:${VERSION:?}
build: build:
context: . context: front
dockerfile: front/Dockerfile environment:
- TZ
ports: ports:
- 80 - 80
deploy: deploy:
@ -18,11 +19,12 @@ services:
back: back:
image: registry.verdnatura.es/salix-back:${VERSION:?} image: registry.verdnatura.es/salix-back:${VERSION:?}
build: . build: .
ports:
- 3000
environment: environment:
- NODE_ENV - NODE_ENV
- DEBUG - DEBUG
- TZ
ports:
- 3000
configs: configs:
- source: datasources - source: datasources
target: /etc/salix/datasources.json target: /etc/salix/datasources.json

View File

@ -10,7 +10,7 @@ RUN apt-get update \
&& ln -sf /dev/stderr /var/log/nginx/error.log && ln -sf /dev/stderr /var/log/nginx/error.log
WORKDIR /etc/nginx WORKDIR /etc/nginx
COPY front/nginx.conf sites-available/salix COPY nginx.conf sites-available/salix
RUN rm sites-enabled/default && ln -s ../sites-available/salix sites-enabled/salix RUN rm sites-enabled/default && ln -s ../sites-available/salix sites-enabled/salix
COPY dist /salix/dist COPY dist /salix/dist

View File

@ -17,7 +17,7 @@ if (argv.NODE_ENV)
let langs = ['es', 'en']; let langs = ['es', 'en'];
let srcDir = './front'; let srcDir = './front';
let modulesDir = './modules'; let modulesDir = './modules';
let buildDir = 'dist'; let buildDir = 'front/dist';
let backSources = [ let backSources = [
'!node_modules', '!node_modules',

View File

@ -67,6 +67,7 @@
"eslint-plugin-jasmine": "^2.10.1", "eslint-plugin-jasmine": "^2.10.1",
"fancy-log": "^1.3.2", "fancy-log": "^1.3.2",
"file-loader": "^6.2.0", "file-loader": "^6.2.0",
"getopts": "^2.3.0",
"gulp": "^4.0.2", "gulp": "^4.0.2",
"gulp-concat": "^2.6.1", "gulp-concat": "^2.6.1",
"gulp-env": "^0.4.0", "gulp-env": "^0.4.0",
@ -107,7 +108,7 @@
"scripts": { "scripts": {
"dbtest": "nodemon -q db/tests.js -w db/tests", "dbtest": "nodemon -q db/tests.js -w db/tests",
"test:back": "nodemon -q back/tests.js --config back/nodemonConfig.json", "test:back": "nodemon -q back/tests.js --config back/nodemonConfig.json",
"test:back:ci": "node back/tests.js ci", "test:back:ci": "node back/tests.js --ci --junit --network jenkins",
"test:e2e": "node e2e/helpers/tests.js", "test:e2e": "node e2e/helpers/tests.js",
"test:front": "jest --watch", "test:front": "jest --watch",
"back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back", "back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back",

View File

@ -163,6 +163,9 @@ devDependencies:
file-loader: file-loader:
specifier: ^6.2.0 specifier: ^6.2.0
version: 6.2.0(webpack@5.90.1) version: 6.2.0(webpack@5.90.1)
getopts:
specifier: ^2.3.0
version: 2.3.0
gulp: gulp:
specifier: ^4.0.2 specifier: ^4.0.2
version: 4.0.2 version: 4.0.2

View File

@ -11,7 +11,7 @@ let baseConfig = {
entry: {salix: 'salix'}, entry: {salix: 'salix'},
mode, mode,
output: { output: {
path: path.join(__dirname, 'dist'), path: path.join(__dirname, 'front/dist'),
publicPath: '/' publicPath: '/'
}, },
module: { module: {
@ -139,7 +139,7 @@ let devConfig = {
host: '0.0.0.0', host: '0.0.0.0',
port: 5000, port: 5000,
publicPath: '/', publicPath: '/',
contentBase: 'dist', contentBase: 'front/dist',
quiet: false, quiet: false,
noInfo: false, noInfo: false,
hot: true, hot: true,