diff --git a/bin/approbation.js b/bin/approbation.js index 801c49c..27b4345 100755 --- a/bin/approbation.js +++ b/bin/approbation.js @@ -123,6 +123,7 @@ if (command === 'check-filenames') { const categories = argv.categories const features = argv.features const ignoreGlob = argv.ignore + const currentMilestone = argv['current-milestone'] const showMystery = argv['show-mystery'] === true const showCategoryStats = argv['category-stats'] === true const isVerbose = argv.verbose === true @@ -162,7 +163,7 @@ if (command === 'check-filenames') { } // TODO: Turn in to an object - res = checkReferences(specsGlob, testsGlob, categories, ignoreGlob, features, showMystery, isVerbose, showCategoryStats, showFiles, shouldOutputCSV, shouldOutputJenkins, shouldShowFileStats, outputPath) + res = checkReferences(specsGlob, testsGlob, categories, ignoreGlob, features, showMystery, isVerbose, showCategoryStats, showFiles, shouldOutputCSV, shouldOutputJenkins, shouldShowFileStats, currentMilestone, outputPath) process.exit(res.exitCode) } else { diff --git a/package.json b/package.json index c9f3fd5..39554bd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vegaprotocol/approbation", - "version": "4.7.3", + "version": "4.8.0", "description": "Match Acceptance Criteria Codes with the tests that test them", "engine": ">= 18", "bin": "./bin/approbation.js", diff --git a/src/check-references.js b/src/check-references.js index e71da2b..6581381 100644 --- a/src/check-references.js +++ b/src/check-references.js @@ -211,7 +211,26 @@ function processReferences(specs, tests) { } } -function checkReferences(specsGlob, testsGlob, categoriesPath, ignoreGlob, featuresPath, showMystery = false, isVerbose = false, showCategoryStats = false, shouldShowFiles = false, shouldOutputCSV = false, shouldOutputJenkins = false, shouldShowFileStats = false, outputPath = './results') { +/** + * This function signature is madness, but refactoring it has yet to be worth the time + * + * @param {*} specsGlob + * @param {*} testsGlob + * @param {*} categoriesPath + * @param {*} ignoreGlob + * @param {*} featuresPath + * @param {*} showMystery + * @param {*} isVerbose + * @param {*} showCategoryStats + * @param {*} shouldShowFiles + * @param {*} shouldOutputCSV + * @param {*} shouldOutputJenkins + * @param {*} shouldShowFileStats + * @param {*} currentMilestone + * @param {*} outputPath + * @returns + */ +function checkReferences(specsGlob, testsGlob, categoriesPath, ignoreGlob, featuresPath, showMystery = false, isVerbose = false, showCategoryStats = false, shouldShowFiles = false, shouldOutputCSV = false, shouldOutputJenkins = false, shouldShowFileStats = false, currentMilestone = 'colosseo_II', outputPath = './results') { verbose = isVerbose showFiles = shouldShowFiles const ignoreList = ignoreGlob ? glob.sync(ignoreGlob, {}) : [] @@ -425,13 +444,21 @@ function checkReferences(specsGlob, testsGlob, categoriesPath, ignoreGlob, featu } if (shouldOutputJenkins) { - const currentMilestone = totals && totals.length > 0 ? totals.pop() : false + let cm + // If current milestone is set by parameter, use it + if (currentMilestone) { + cm = totals.find(t => t.Milestone === currentMilestone) + } + // If not, use the most recent + if (!cm) { + cm = totals && totals.length > 0 ? totals.pop() : false + } const skipCategories = ['Category', 'Specs', 'Acceptable'] let jenkinsLine = `All ACs: ${Object.entries(categories.pop()).map(([key, value]) => skipCategories.indexOf(key) === -1 ? `*${key}*: ${value}` : '').join(' ').trim()}` - if (currentMilestone && currentMilestone.Milestone && currentMilestone.Coverage) { - jenkinsLine += `\r\nCurrent milestone ACs: *${currentMilestone.Milestone}*: ${currentMilestone.Coverage}` + if (cm && cm.Milestone && cm.Coverage) { + jenkinsLine += `\r\nCurrent milestone ACs: *${cm.Milestone}*: ${cm.Coverage}` } fs.writeFileSync(`${outputPath}/jenkins.txt`, jenkinsLine)