Skip to content

Commit

Permalink
#22993 merge master done
Browse files Browse the repository at this point in the history
  • Loading branch information
jdotcms committed Nov 21, 2022
2 parents 3d7a52c + 5a69183 commit d3310f6
Show file tree
Hide file tree
Showing 398 changed files with 96,153 additions and 5,620 deletions.
17 changes: 8 additions & 9 deletions .github/actions/run-integration-tests/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,10 +554,7 @@ const getAppends = (propertyMap) => {
},
{
file: `${itResourcesFolder}/it-dotcms-config-cluster.properties`,
lines: [
'ES_ENDPOINTS=http://localhost:9200',
'ES_PROTOCOL=http'
]
lines: ['ES_ENDPOINTS=http://localhost:9200', 'ES_PROTOCOL=http']
},
{
file: `${dotCmsFolder}/src/main/webapp/WEB-INF/elasticsearch/config/elasticsearch-override.yml`,
Expand Down Expand Up @@ -648,16 +645,18 @@ const run = () => __awaiter(void 0, void 0, void 0, function* () {
const result = yield integration.runTests(cmds);
const skipReport = !(result.outputDir && fs.existsSync(result.outputDir));
setOutput('tests_results_location', result.outputDir);
setOutput('tests_results_report_location', result.reportDir);
setOutput('tests_results_report_location', result.reportDir, true);
setOutput('ci_index', result.ciIndex);
setOutput('tests_results_status', result.exitCode === 0 ? 'PASSED' : 'FAILED');
setOutput('tests_results_skip_report', skipReport);
setOutput(`${dbType}_tests_results_status`, result.exitCode === 0 ? 'PASSED' : 'FAILED');
setOutput(`${dbType}_tests_results_status`, result.exitCode === 0 ? 'PASSED' : 'FAILED', true);
setOutput(`${dbType}_tests_results_skip_report`, skipReport);
});
const setOutput = (name, value) => {
const val = value === undefined ? '' : value;
core.notice(`Setting output '${name}' with value: '${val}'`);
const setOutput = (name, value, notify = false) => {
const val = value || '';
if (notify && !!val) {
core.notice(`Setting output '${name}' with value: '${val}'`);
}
core.setOutput(name, value);
};
// Run main function
Expand Down
12 changes: 7 additions & 5 deletions .github/actions/run-integration-tests/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ const run = async () => {
const result = await integration.runTests(cmds)
const skipReport = !(result.outputDir && fs.existsSync(result.outputDir))
setOutput('tests_results_location', result.outputDir)
setOutput('tests_results_report_location', result.reportDir)
setOutput('tests_results_report_location', result.reportDir, true)
setOutput('ci_index', result.ciIndex)
setOutput('tests_results_status', result.exitCode === 0 ? 'PASSED' : 'FAILED')
setOutput('tests_results_skip_report', skipReport)
setOutput(`${dbType}_tests_results_status`, result.exitCode === 0 ? 'PASSED' : 'FAILED')
setOutput(`${dbType}_tests_results_status`, result.exitCode === 0 ? 'PASSED' : 'FAILED', true)
setOutput(`${dbType}_tests_results_skip_report`, skipReport)
}

const setOutput = (name: string, value: string | boolean | number | undefined) => {
const val = value === undefined ? '' : value
core.notice(`Setting output '${name}' with value: '${val}'`)
const setOutput = (name: string, value?: string | boolean | number, notify = false) => {
const val = value || ''
if (notify && !!val) {
core.notice(`Setting output '${name}' with value: '${val}'`)
}
core.setOutput(name, value)
}

Expand Down
5 changes: 5 additions & 0 deletions .github/actions/run-postman-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ inputs:
type: boolean
required: false
default: 'false'
include_analytics:
description: 'Include Analytics infrastructure flag'
type: boolean
required: false
default: 'false'
outputs:
tests_results_status:
description: 'Tests results status'
Expand Down
98 changes: 59 additions & 39 deletions .github/actions/run-postman-tests/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,18 @@ const run = () => __awaiter(void 0, void 0, void 0, function* () {
core.info("Running Core's postman tests");
const results = yield postman.runTests();
setOutput('tests_results_location', resultsFolder);
setOutput('tests_results_report_location', reportFolder);
setOutput('tests_results_report_location', reportFolder, true);
setOutput('tests_results_status', results.testsResultsStatus);
setOutput('tests_results_skip_report', results.skipResultsReport);
if (results.testsRunExitCode !== 0) {
core.setFailed(`Postman tests failed: ${JSON.stringify(results)}`);
}
});
const setOutput = (name, value) => {
const val = value === undefined ? '' : value;
core.notice(`Setting output '${name}' with value: '${val}'`);
const setOutput = (name, value, notify = false) => {
const val = value || '';
if (notify && !!val) {
core.notice(`Setting output '${name}' with value: '${val}'`);
}
core.setOutput(name, value);
};
// Run main function
Expand Down Expand Up @@ -115,20 +117,15 @@ const exec = __importStar(__nccwpck_require__(1514));
const fs = __importStar(__nccwpck_require__(7147));
const path = __importStar(__nccwpck_require__(1017));
const shelljs = __importStar(__nccwpck_require__(3516));
// const resolveTomcat = (): string => {
// const dotServerFolder = path.join(projectRoot, 'dist', 'dotserver')
// const tomcatFolder = shelljs.ls(dotServerFolder).find(folder => folder.startsWith('tomcat-'))
// return path.join(dotServerFolder, tomcatFolder || '')
// }
const projectRoot = core.getInput('project_root');
// const buildEnv = core.getInput('build_env')
const builtImageName = core.getInput('built_image_name');
const waitForDeps = core.getInput('wait_for_deps');
const dbType = core.getInput('db_type');
const licenseKey = core.getInput('license_key');
const customStarterUrl = core.getInput('custom_starter_url');
const tests = core.getInput('tests');
const exportReport = core.getBooleanInput('export_report');
const includeAnalytics = core.getBooleanInput('include_analytics');
const cicdFolder = path.join(projectRoot, 'cicd');
const resourcesFolder = path.join(cicdFolder, 'resources', 'postman');
const dockerFolder = path.join(cicdFolder, 'docker');
Expand All @@ -155,12 +152,13 @@ const DEPS_ENV = {
JVM_ENDPOINT_TEST_PASS: 'obfuscate_me'
};
/*
* Run postman tests and provides a summary of such.
*
* @returns a number representing the command exit code
* @returns a object representing run status
*/
const runTests = () => __awaiter(void 0, void 0, void 0, function* () {
yield setup();
startDeps();
yield startDeps();
printInfo();
try {
return yield runPostmanCollections();
Expand Down Expand Up @@ -196,6 +194,9 @@ const setup = () => __awaiter(void 0, void 0, void 0, function* () {
yield prepareLicense();
yield printInfo();
});
/**
* Prints docker command info
*/
const printInfo = () => __awaiter(void 0, void 0, void 0, function* () {
yield execCmd(toCommand('docker', ['images']));
yield execCmd(toCommand('docker', ['ps']));
Expand All @@ -210,58 +211,46 @@ const installDeps = () => __awaiter(void 0, void 0, void 0, function* () {
npmArgs.push('newman-reporter-htmlextra');
}
yield execCmd(toCommand('npm', npmArgs));
// if (!fs.existsSync(tomcatRoot) && buildEnv === 'gradle') {
// core.info(`Tomcat root does not exist, creating it`)
// await exec.exec('./gradlew', ['clonePullTomcatDist'])
// tomcatRoot = resolveTomcat()
// if (!tomcatRoot) {
// throw new Error('Cannot find any Tomcat root folder')
// }
// }
});
/**
* Start postman depencies: db, ES and DotCMS isntance.
*/
const startDeps = () => {
const startDeps = () => __awaiter(void 0, void 0, void 0, function* () {
// Starting dependencies
core.info(`
=======================================
Starting postman tests dependencies
=======================================`);
if (includeAnalytics) {
execCmdAsync(toCommand('docker-compose', ['-f', 'analytics-compose.yml', 'up'], dockerFolder));
yield waitFor(140, 'Analytics Infrastructure');
}
execCmdAsync(toCommand('docker-compose', ['-f', 'open-distro-compose.yml', '-f', `${dbType}-compose.yml`, '-f', 'dotcms-compose.yml', 'up'], dockerFolder, DEPS_ENV));
//await startDotCMS()
};
});
/**
* Stop postman depencies: db, ES and DotCMS isntance.
*/
const stopDeps = () => __awaiter(void 0, void 0, void 0, function* () {
//await stopDotCMS()
// Stopping dependencies
core.info(`
===================================
Stopping postman tests dependencies
===================================`);
if (includeAnalytics) {
try {
yield execCmd(toCommand('docker-compose', ['-f', 'analytics-compose.yml', 'down', '-v'], dockerFolder));
}
catch (err) {
console.error(`Error stopping dependencies: ${err}`);
}
}
try {
yield execCmd(toCommand('docker-compose', ['-f', 'open-distro-compose.yml', '-f', `${dbType}-compose.yml`, '-f', 'dotcms-compose.yml', 'down'], dockerFolder, DEPS_ENV));
yield execCmd(toCommand('docker-compose', ['-f', 'open-distro-compose.yml', '-f', `${dbType}-compose.yml`, '-f', 'dotcms-compose.yml', 'down', '-v'], dockerFolder, DEPS_ENV));
}
catch (err) {
console.error(`Error stopping dependencies: ${err}`);
}
});
// const startDotCMS = async () => {
// core.info(`
// =======================================
// Starting DotCMS instance
// =======================================`)
// exec.exec(path.join(tomcatRoot, 'bin', 'startup.sh'))
// }
// const stopDotCMS = async () => {
// core.info(`
// =======================================
// Stopping DotCMS instance
// =======================================`)
// await exec.exec(path.join(tomcatRoot, 'bin', 'shutdown.sh'))
// }
/**
* Run postman tests.
*
Expand Down Expand Up @@ -442,6 +431,12 @@ const resolveSpecific = () => {
core.info(`Resolved specific collections:\n${resolved.join(',')}`);
return resolved;
};
/**
* Extracts postman tests from commit message.
*
* @param message commit message
* @returns filtered tests
*/
const extractFromMessg = (message) => {
if (!message) {
return [];
Expand All @@ -456,6 +451,15 @@ const extractFromMessg = (message) => {
}
return extracted;
};
/**
* Gather values and build a Command instance.
*
* @param cmd command
* @param args arguments
* @param workingDir working dir
* @param env environment variables
* @returns Command object
*/
const toCommand = (cmd, args, workingDir, env) => {
return {
cmd,
Expand All @@ -464,6 +468,11 @@ const toCommand = (cmd, args, workingDir, env) => {
env
};
};
/**
* Prints string Command representation.
*
* @param cmd Command object
*/
const printCmd = (cmd) => {
var _a;
let message = `Executing cmd: ${cmd.cmd} ${((_a = cmd.args) === null || _a === void 0 ? void 0 : _a.join(' ')) || ''}`;
Expand All @@ -475,10 +484,21 @@ const printCmd = (cmd) => {
}
core.info(message);
};
/**
* Executes command contained in Command object.
*
* @param cmd Command object
* @returns Promise with process number
*/
const execCmd = (cmd) => __awaiter(void 0, void 0, void 0, function* () {
printCmd(cmd);
return yield exec.exec(cmd.cmd, cmd.args || [], { cwd: cmd.workingDir, env: cmd.env });
});
/**
* Async executes command contained in Command object.
*
* @param cmd Command object
*/
const execCmdAsync = (cmd) => {
printCmd(cmd);
exec.exec(cmd.cmd, cmd.args || [], { cwd: cmd.workingDir, env: cmd.env });
Expand Down
10 changes: 6 additions & 4 deletions .github/actions/run-postman-tests/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const run = async () => {
const results = await postman.runTests()

setOutput('tests_results_location', resultsFolder)
setOutput('tests_results_report_location', reportFolder)
setOutput('tests_results_report_location', reportFolder, true)
setOutput('tests_results_status', results.testsResultsStatus)
setOutput('tests_results_skip_report', results.skipResultsReport)

Expand All @@ -24,9 +24,11 @@ const run = async () => {
}
}

const setOutput = (name: string, value: string | boolean | number | undefined) => {
const val = value === undefined ? '' : value
core.notice(`Setting output '${name}' with value: '${val}'`)
const setOutput = (name: string, value?: string | boolean | number, notify = false) => {
const val = value || ''
if (notify && !!val) {
core.notice(`Setting output '${name}' with value: '${val}'`)
}
core.setOutput(name, value)
}

Expand Down
Loading

0 comments on commit d3310f6

Please sign in to comment.