Skip to content

Commit

Permalink
add currentmilestone param that defaults to colosseo_ii but can be ov…
Browse files Browse the repository at this point in the history
…erridden on the command line
  • Loading branch information
edd committed Jul 10, 2024
1 parent 5e35910 commit be1beab
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
3 changes: 2 additions & 1 deletion bin/approbation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
35 changes: 31 additions & 4 deletions src/check-references.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {}) : []
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit be1beab

Please sign in to comment.