Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifying the diff.groovy with yaml project-to-test-on.yaml #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions checkstyle-tester/diff.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import static java.lang.System.err
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING
import org.yaml.snakeyaml.Yaml

import java.nio.file.Files
import java.nio.file.Paths
Expand Down Expand Up @@ -77,6 +78,8 @@ def getCliOptions(args) {
+ ' \'diff\' or \'single\'. (optional, default is \'diff\')')
xm(longOpt: 'extraMvnRegressionOptions', args: 1, required: false, 'Extra arguments to pass to Maven' \
+ 'for Checkstyle Regression run (optional, ex: -Dmaven.prop=true)')
p(longOpt: 'projects', args: 1, required: false, argName: 'projects',
'Comma-separated list of projects to include (optional)')
}
return cli.parse(args)
}
Expand Down Expand Up @@ -246,31 +249,26 @@ def launchCheckstyleReport(cfg) {
return reportInfo
}

def parseProjects(listOfProjectsFile, allowExcludes) {
def parseProjects(listOfProjectsFile, allowExcludes, includedProjects) {
def projects = []
def fullParamListSize = 5

new File(listOfProjectsFile).eachLine { project ->
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not remove old functionality
please do check that file is with yaml extension and load it in yaml way, ELSE load it in "property"/old way

if (!project.startsWith('#') && !project.isEmpty()) {
def params = project.split('\\|', -1)
if (params.length < fullParamListSize) {
throw new InvalidPropertiesFormatException("Error: line '$project' " +
"in file '$listOfProjectsFile.name' should have $fullParamListSize " +
"pipe-delimited sections!")
def yaml = new Yaml()
def input = new File(listOfProjectsFile).text
def data = yaml.load(input)

data.projects.each { project ->
project.each { name, details ->
if (includedProjects.contains(name) && details.enabled != false) {
def projectConfig = new ProjectConfig(
repoName: name,
repoType: details.type,
repoUrl: details.url,
commitId: details.commit_id,
excludes: allowExcludes ? details.excludes?.join(",") : ""
)
projects << projectConfig
}

def projectConfig = new ProjectConfig(
repoName: params[0],
repoType: params[1],
repoUrl: params[2],
commitId: params[3],
excludes: allowExcludes ? params[4] : ""
)

projects << projectConfig
}
}

return projects
}

Expand All @@ -283,7 +281,7 @@ def generateCheckstyleReport(cfg) {
def reportsDir = 'reports'
makeWorkDirsIfNotExist(srcDir, reposDir, reportsDir)

def projects = parseProjects(cfg.listOfProjects, cfg.allowExcludes)
def projects = parseProjects(cfg.listOfProjects, cfg.allowExcludes, cfg.includedProjects)

projects.each { ProjectConfig projectConfig ->
deleteDir(srcDir)
Expand Down Expand Up @@ -788,6 +786,7 @@ class Config {
def shortFilePaths
def listOfProjects
def mode
def includedProjects

def baseBranch
def patchBranch
Expand Down Expand Up @@ -818,6 +817,7 @@ class Config {
shortFilePaths = cliOptions.shortFilePaths
listOfProjects = cliOptions.listOfProjects
extraMvnRegressionOptions = cliOptions.extraMvnRegressionOptions
includedProjects = cliOptions.projects?.split(',')

checkstyleVersion = cliOptions.checkstyleVersion
allowExcludes = cliOptions.allowExcludes
Expand Down Expand Up @@ -871,6 +871,7 @@ class Config {
extraMvnRegressionOptions: extraMvnRegressionOptions,
allowExcludes:allowExcludes,
useShallowClone: useShallowClone,
includedProjects: includedProjects,
]
}

Expand All @@ -884,6 +885,7 @@ class Config {
extraMvnRegressionOptions: extraMvnRegressionOptions,
allowExcludes: allowExcludes,
useShallowClone: useShallowClone,
includedProjects: includedProjects,
]
}

Expand All @@ -898,6 +900,7 @@ class Config {
mode: mode,
allowExcludes: allowExcludes,
useShallowClone: useShallowClone,
includedProjects: includedProjects,
]
}
}
Expand Down