2018-05-13 16:50:16 -04:00
|
|
|
const nodeIndex = parseInt(process.env.CIRCLE_NODE_INDEX)
|
|
|
|
const nodeTotal = parseInt(process.env.CIRCLE_NODE_TOTAL)
|
|
|
|
const parallel = process.env.CIRCLE_NODE_INDEX !== undefined && process.env.CIRCLE_NODE_TOTAL !== undefined
|
|
|
|
const mc = require('../../')
|
2017-05-09 20:49:13 -04:00
|
|
|
|
|
|
|
// expected values :
|
|
|
|
// (0,4,10) -> (0,2)
|
|
|
|
// (1,4,10) -> (3,5)
|
|
|
|
// (2,4,10) -> (6,8)
|
|
|
|
// (3,4,10) -> (9,9)
|
2018-05-13 16:50:16 -04:00
|
|
|
function testedRange (nodeIndex, nodeTotal, numberOfVersions) {
|
|
|
|
const nbFirsts = Math.ceil(numberOfVersions / nodeTotal)
|
|
|
|
if (nodeIndex === (nodeTotal - 1)) { return {firstVersion: nbFirsts * nodeIndex, lastVersion: numberOfVersions - 1} }
|
2017-05-09 20:49:13 -04:00
|
|
|
|
2018-05-13 16:50:16 -04:00
|
|
|
return {firstVersion: nodeIndex * nbFirsts, lastVersion: (nodeIndex + 1) * nbFirsts - 1}
|
2017-05-09 20:49:13 -04:00
|
|
|
}
|
2018-05-13 16:50:16 -04:00
|
|
|
console.log({nodeIndex, nodeTotal, versions: mc.supportedVersions.length})
|
|
|
|
const {firstVersion, lastVersion} = parallel ? testedRange(nodeIndex, nodeTotal, mc.supportedVersions.length) : {firstVersion: 0, lastVersion: mc.supportedVersions.length - 1}
|
2017-05-09 20:49:13 -04:00
|
|
|
|
2018-05-13 16:50:16 -04:00
|
|
|
module.exports = {firstVersion, lastVersion}
|