Skip to content

Commit

Permalink
Issue #866: Convert project-to-test into yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
piyush kumar sadangi authored and piyush kumar sadangi committed May 28, 2024
1 parent 33c184b commit 4e403d4
Show file tree
Hide file tree
Showing 14 changed files with 503 additions and 126 deletions.
24 changes: 12 additions & 12 deletions .ci/validation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ checkstyle-tester-diff-groovy-patch)
cd .ci-temp/checkstyle
git checkout -b patch-branch
cd ../../checkstyle-tester
cp projects-to-test-on.properties ../.ci-temp/projects-to-test-on.properties
sed -i'' 's/^guava/#guava/' ../.ci-temp/projects-to-test-on.properties
sed -i'' 's/#checkstyle/checkstyle/' ../.ci-temp/projects-to-test-on.properties
groovy diff.groovy -l ../.ci-temp/projects-to-test-on.properties \
cp projects-to-test-on.yml ../.ci-temp/projects-to-test-on.yml
sed -i'' 's/^guava/#guava/' ../.ci-temp/projects-to-test-on.yml
sed -i'' 's/#checkstyle/checkstyle/' ../.ci-temp/projects-to-test-on.yml
groovy diff.groovy -l ../.ci-temp/projects-to-test-on.yml \
-c my_check.xml -b master -p patch-branch -r ../.ci-temp/checkstyle
;;

Expand All @@ -49,7 +49,7 @@ checkstyle-tester-diff-groovy-base-patch)
cd .ci-temp/checkstyle
git checkout -b patch-branch
cd ../../checkstyle-tester
groovy diff.groovy -l projects-to-test-on.properties \
groovy diff.groovy -l projects-to-test-on.yml \
-bc my_check.xml -pc my_check.xml -b master -p patch-branch -r ../.ci-temp/checkstyle
;;

Expand All @@ -58,7 +58,7 @@ checkstyle-tester-diff-groovy-patch-only)
cd .ci-temp/checkstyle
git checkout -b patch-branch
cd ../../checkstyle-tester
groovy diff.groovy -l projects-to-test-on.properties \
groovy diff.groovy -l projects-to-test-on.yml \
-pc my_check.xml -p patch-branch -r ../.ci-temp/checkstyle -m single
;;

Expand All @@ -70,20 +70,20 @@ checkstyle-tester-diff-groovy-regression-single)
# Run report from master branch of contribution
checkout_from https://github.com/checkstyle/contribution
cd .ci-temp/contribution/checkstyle-tester
sed -i'' 's/^guava/#guava/' projects-to-test-on.properties
sed -i'' 's/#checkstyle|/checkstyle|/' projects-to-test-on.properties
sed -i'' 's/^guava/#guava/' projects-to-test-on.yml
sed -i'' 's/#checkstyle|/checkstyle|/' projects-to-test-on.yml
export MAVEN_OPTS="-Xmx2048m"
groovy ./diff.groovy --listOfProjects projects-to-test-on.properties \
groovy ./diff.groovy --listOfProjects projects-to-test-on.yml \
-pc ../../../checkstyle-tester/diff-groovy-regression-config.xml \
-r ../../checkstyle -xm "-Dcheckstyle.failsOnError=false" \
-m single -p master

# Run report with current branch
cd ../../../checkstyle-tester/
sed -i'' 's/^guava/#guava/' projects-to-test-on.properties
sed -i'' 's/#checkstyle|/checkstyle|/' projects-to-test-on.properties
sed -i'' 's/^guava/#guava/' projects-to-test-on.yml
sed -i'' 's/#checkstyle|/checkstyle|/' projects-to-test-on.yml
rm -rf reports repositories
groovy ./diff.groovy --listOfProjects projects-to-test-on.properties \
groovy ./diff.groovy --listOfProjects projects-to-test-on.yml \
-pc diff-groovy-regression-config.xml -r ../.ci-temp/checkstyle/ \
-m single -p master -xm "-Dcheckstyle.failsOnError=false"

Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ environment:
CMD3: " && cd checkstyle && git checkout -b patch-branch"
CMD4: " "
CMD5: " && cd ..\\checkstyle-tester "
CMD6: " && groovy diff.groovy -l projects-to-test-on.properties -c my_check.xml -b master -p patch-branch -r C:\\projects\\contribution\\checkstyle -s"
CMD6: " && groovy diff.groovy -l projects-to-test-on.yml -c my_check.xml -b master -p patch-branch -r C:\\projects\\contribution\\checkstyle -s"
- JAVA_HOME: C:\Program Files\Java\jdk11
DESC: "checkstyle-tester (diff.groovy with base and patch configs) on guava"
CMD1: " git clone -q --depth=10 --branch=master "
CMD2: " https://github.com/checkstyle/checkstyle C:\\projects\\contribution\\checkstyle "
CMD3: " && cd checkstyle && git checkout -b patch-branch"
CMD4: " "
CMD5: " && cd ..\\checkstyle-tester "
CMD6: " && groovy diff.groovy -l projects-to-test-on.properties -bc my_check.xml -pc my_check.xml -b master -p patch-branch -r C:\\projects\\contribution\\checkstyle -s"
CMD6: " && groovy diff.groovy -l projects-to-test-on.yml -bc my_check.xml -pc my_check.xml -b master -p patch-branch -r C:\\projects\\contribution\\checkstyle -s"

build_script:
- ps: >
Expand Down
22 changes: 11 additions & 11 deletions checkstyle-tester/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# CHECKSTYLE-TESTER

checkstyle-tester is a tool for Checkstyle report generation over very
[basic set of external projects](https://github.com/checkstyle/contribution/blob/master/checkstyle-tester/projects-to-test-on.properties).
[basic set of external projects](https://github.com/checkstyle/contribution/blob/master/checkstyle-tester/projects-to-test-on.yml).
checkstyle-tester generates reports from violations printed from a supplied user
config over the aforementioned projects. The generated reports are in HTML format.
They can be viewed in any browser and can be posted online for others to view.
Expand Down Expand Up @@ -78,7 +78,7 @@ When the script finishes its work the following directory structure will be crea
in the root of checkstyle-tester directory:

*/repositories* - directory with downloaded projects sources which are specified
in projects-to-test-on.properties;
in projects-to-test-on.yml;

*/reports/diff* - directory with diff reports;

Expand Down Expand Up @@ -120,7 +120,7 @@ Should be used with `Diff Regression config:`
3) **Conditional** `New module config: {{URI to new_module_config.xml}}`
Report configuration [template][template_my_check] for new modules, e.g. for new check.

4) **Optional** `Diff Regression projects: {{URI to projects-to-test-on.properties}}`
4) **Optional** `Diff Regression projects: {{URI to projects-to-test-on.yml}}`
Link to custom list of projects ([template][projects-to-test-on_prp]).
If no list is provided, [default][for-github-action_prp] list is taken.

Expand All @@ -145,7 +145,7 @@ To check the job, you can open "Actions" tab and find your job there.

#### Examples of URIs

- https://raw.githubusercontent.com/checkstyle/contribution/master/checkstyle-tester/projects-to-test-on.properties
- https://raw.githubusercontent.com/checkstyle/contribution/master/checkstyle-tester/projects-to-test-on.yml

- https://gist.githubusercontent.com/strkkk/121653f4a334be38b9e77e4245e144e2/raw/691fe6e90ff40473707ce77518b7a0b058bd0955/config.xml

Expand Down Expand Up @@ -209,7 +209,7 @@ the custom configuration created with all the permutations.
```bash
groovy diff.groovy --localGitRepo /home/johndoe/projects/checkstyle \
--baseBranch i111-my-fix --patchBranch i111-my-fix-mutation \
--config config.xml --listOfProjects projects-to-test-on.properties
--config config.xml --listOfProjects projects-to-test-on.yml
```

ATTENTION:
Expand Down Expand Up @@ -267,7 +267,7 @@ You may modify all the checks that depend on external files to use default setti
of the configuration files, you should use the [`my_check.xml`]
(https://github.com/checkstyle/contribution/blob/master/checkstyle-tester/my_check.xml)
file as a base**, and add the checks from `checkstyle-checks.xml` to it. Then `diff.groovy`
should be run on all projects in `projects-to-test-on.properties`, using the `diff.groovy`
should be run on all projects in `projects-to-test-on.yml`, using the `diff.groovy`
script once for each configuration file.
[See instructions above]
(https://github.com/checkstyle/contribution/tree/master/checkstyle-tester#basic-difference-report)
Expand All @@ -281,13 +281,13 @@ This report is generated using the [`launch_diff_antlr.sh`]
(https://github.com/checkstyle/contribution/blob/master/checkstyle-tester/launch_diff_antlr.sh)
script. This script generates a report based on the differences in the ASTs generated
from your PR branch and Checkstyle's 'main' branch using projects that are selected
(uncommented) in the [`projects-to-test-on.properties`]
(https://github.com/checkstyle/contribution/blob/master/checkstyle-tester/projects-to-test-on.properties)
(uncommented) in the [`projects-to-test-on.yml`]
(https://github.com/checkstyle/contribution/blob/master/checkstyle-tester/projects-to-test-on.yml)
file. For the ANTLR regression report, we usually only want to see that changes
to the Checkstyle project. To ensure that you test against any new inputs that
you have created (unit test inputs, etc.), please make sure that you comment out
all other projects, and add the following line to [`projects-to-test-on.properties`]
(https://github.com/checkstyle/contribution/blob/master/checkstyle-tester/projects-to-test-on.properties):
all other projects, and add the following line to [`projects-to-test-on.yml`]
(https://github.com/checkstyle/contribution/blob/master/checkstyle-tester/projects-to-test-on.yml):

```bash
my-checkstyle|git|https://github.com/<username>/checkstyle.git|<pr-branch>||
Expand Down Expand Up @@ -326,4 +326,4 @@ Windows users should use the `SET` command instead of the `export` command.

[template_my_check]:https://raw.githubusercontent.com/checkstyle/contribution/master/checkstyle-tester/my_check.xml
[for-github-action_prp]:https://raw.githubusercontent.com/checkstyle/contribution/master/checkstyle-tester/projects-to-test-on-for-github-action.properties
[projects-to-test-on_prp]:https://raw.githubusercontent.com/checkstyle/contribution/master/checkstyle-tester/projects-to-test-on.properties
[projects-to-test-on_prp]:https://raw.githubusercontent.com/checkstyle/contribution/master/checkstyle-tester/projects-to-test-on.yml
22 changes: 11 additions & 11 deletions checkstyle-tester/README_MANUAL_EXECUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
Before you are ready to execute `diff.groovy`, you will have to prepare some
external files and branches first.

### projects-to-test-on.properties
### projects-to-test-on.yml

`projects-to-test-on.properties` lists all the projects that `diff.groovy` will execute.
`projects-to-test-on.yml` lists all the projects that `diff.groovy` will execute.
Anything that starts with `#` is considered a comment and is ignored.
`projects-to-test-on.properties` is expected to be in the following format:
`projects-to-test-on.yml` is expected to be in the following format:

`REPO_NAME|[local|git|hg]|URL|[COMMIT_ID]|[EXCLUDE FOLDERS]|`

You should modify `projects-to-test-on.properties` and test as many projects as possible.
You should modify `projects-to-test-on.yml` and test as many projects as possible.
Each project has its own unique style and it is common to find new and different violations
in 1 and not the others.

You can also specify projects that are already available on your local file system
in `projects-to-test-on.properties`.
in `projects-to-test-on.yml`.
For this you can either use `git` or `hg` type which will clone the local repository
into the workspace and use the specified branch.
Alternatively you can use `local` type, where the specified branch is ignored and
Expand Down Expand Up @@ -114,14 +114,14 @@ that specify the report you want generated.
```bash
groovy diff.groovy --localGitRepo /home/johndoe/projects/checkstyle \
--baseBranch master --patchBranch i111-my-fix --config my_check.xml \
--listOfProjects projects-to-test-on.properties
--listOfProjects projects-to-test-on.yml
```

or with short command line arguments names:

```bash
groovy diff.groovy -r /home/johndoe/projects/checkstyle \
-b master -p i111-my-fix -c my_check.xml -l projects-to-test-on.properties
-b master -p i111-my-fix -c my_check.xml -l projects-to-test-on.yml
```

#### Difference Report with Different Base and Patch Config
Expand All @@ -132,14 +132,14 @@ patch branch use the following command:
```bash
groovy diff.groovy --localGitRepo /home/johndoe/projects/checkstyle \
--baseBranch master --patchBranch i111-my-fix --baseConfig base_config.xml \
--patchConfig patch_config.xml --listOfProjects projects-to-test-on.properties
--patchConfig patch_config.xml --listOfProjects projects-to-test-on.yml
```

or with short command line arguments names:

```bash
groovy diff.groovy -r /home/johndoe/projects/checkstyle -b master -p i111-my-fix \
-bc base_config.xml -pc patch_config.xml -l projects-to-test-on.properties
-bc base_config.xml -pc patch_config.xml -l projects-to-test-on.yml
```

#### Basic Single Report
Expand All @@ -150,14 +150,14 @@ use the following command:
```bash
groovy diff.groovy --localGitRepo /home/johndoe/projects/checkstyle --patchBranch \
i111-my-fix --patchConfig patch_config.xml \
--listOfProjects projects-to-test-on.properties --mode single`
--listOfProjects projects-to-test-on.yml --mode single`
```

or with short command line arguments names:

```bash
groovy diff.groovy -r /home/johndoe/projects/checkstyle -p i111-my-fix \
-pc patch_config.xml -l projects-to-test-on.properties -m single
-pc patch_config.xml -l projects-to-test-on.yml -m single
```

## Deploying Report
Expand Down
4 changes: 2 additions & 2 deletions checkstyle-tester/README_OLD.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# CHECKSTYLE-TESTER

Launch command for testing against google_checks.xml and very [basic set of java projects]
(https://github.com/checkstyle/contribution/blob/master/checkstyle-tester/projects-to-test-on.properties):
(https://github.com/checkstyle/contribution/blob/master/checkstyle-tester/projects-to-test-on.yml):

```bash
./launch.sh
Expand Down Expand Up @@ -69,7 +69,7 @@ to generate compact diff report before and after your change please use tool

ATTENTION:

you can specify at projects-to-test-on.properties path to local file system if you have some
you can specify at projects-to-test-on.yml path to local file system if you have some
repositories on your local, example:
"checkstyle=/home/username/java/git-repos/checkstyle/checkstyle".

Expand Down
5 changes: 0 additions & 5 deletions checkstyle-tester/diff.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,6 @@ def generateCheckstyleReport(cfg) {
project ->
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 repoName = params[repoNameParamNo]
def repoType = params[repoTypeParamNo]
Expand Down
2 changes: 1 addition & 1 deletion checkstyle-tester/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ while read line ; do

echo -e "$REPO_NAME is synchronized\n"

done < projects-to-test-on.properties
done < projects-to-test-on.yml

echo "Running 'mvn clean' on $SOURCES_DIR ..."
mvn --batch-mode clean
Expand Down
16 changes: 8 additions & 8 deletions checkstyle-tester/launch_diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,23 +141,23 @@ function launch {
while read line ; do
[[ "$line" == \#* ]] && continue # Skip lines with comments
[[ -z "$line" ]] && continue # Skip empty lines

REPO_NAME=`echo $line | cut -d '|' -f 1`
REPO_TYPE=`echo $line | cut -d '|' -f 2`
REPO_URL=` echo $line | cut -d '|' -f 3`
COMMIT_ID=`echo $line | cut -d '|' -f 4`
EXCLUDES=` echo $line | cut -d '|' -f 5`

echo "Running Launch on $REPO_NAME ..."

if [ ! -d "$REPOSITORIES_DIR" ]; then
mkdir $REPOSITORIES_DIR
fi
CURRENT_REPO_DIR=""

if [ "$REPO_TYPE" == "git" ]; then
GITPATH=$REPOSITORIES_DIR/$REPO_NAME

if [ ! -d "$GITPATH" ]; then
echo "Cloning $REPO_TYPE repository '${REPO_NAME}' ..."
git clone $REPO_URL $GITPATH
Expand Down Expand Up @@ -216,7 +216,7 @@ function launch {
fi

echo "Running Launch on $REPO_NAME - completed"
done < $TESTER_DIR/projects-to-test-on.properties
done < $TESTER_DIR/projects-to-test-on.yml
}

function containsElement {
Expand Down Expand Up @@ -341,11 +341,11 @@ if $RUN_REPORTS ; then
while read line ; do
[[ "$line" == \#* ]] && continue # Skip lines with comments
[[ -z "$line" ]] && continue # Skip empty lines

REPO_NAME=`echo $line | cut -d '|' -f 1`

EXTPROJECTS+=($REPO_NAME)
done < $TESTER_DIR/projects-to-test-on.properties
done < $TESTER_DIR/projects-to-test-on.yml
fi

echo "Starting all Reports"
Expand Down
10 changes: 5 additions & 5 deletions checkstyle-tester/launch_diff_antlr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,23 @@ function launch {
while read line ; do
[[ "$line" == \#* ]] && continue # Skip lines with comments
[[ -z "$line" ]] && continue # Skip empty lines

REPO_NAME=`echo $line | cut -d '|' -f 1`
REPO_TYPE=`echo $line | cut -d '|' -f 2`
REPO_URL=` echo $line | cut -d '|' -f 3`
COMMIT_ID=`echo $line | cut -d '|' -f 4`
EXCLUDES=` echo $line | cut -d '|' -f 5`

echo "Running Launches on $REPO_NAME ..."

if [ ! -d "$REPOSITORIES_DIR" ]; then
mkdir $REPOSITORIES_DIR
fi
REPO_SOURCES_DIR=

if [ "$REPO_TYPE" == "git" ]; then
GITPATH=$REPOSITORIES_DIR/$REPO_NAME

if [ ! -d "$GITPATH" ]; then
echo "Cloning $REPO_TYPE repository '${REPO_NAME}' ..."
git clone $REPO_URL $GITPATH
Expand Down Expand Up @@ -167,7 +167,7 @@ echo "$f"
fi

echo "Running Launch on $REPO_NAME - completed"
done < $TESTER_DIR/projects-to-test-on.properties
done < $TESTER_DIR/projects-to-test-on.yml
}

function containsElement {
Expand Down
4 changes: 2 additions & 2 deletions checkstyle-tester/multi_config_check_regression.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ static void main(String[] args) {
def configFilesDir = cliOptions.configDir
def outputDirectory = cliOptions.outputDir
def patchBranch = cliOptions.patchBranch
def projectsToTestOn = new File("projects-to-test-on.properties")
def projectsToTestOn = new File("projects-to-test-on.yml")

println "Running check regression reports for patch branch: ${patchBranch}."
println "Make sure that you have selected (uncommented)" +
" correct projects from projects-to-test-on.properties!"
" correct projects from projects-to-test-on.yml!"

def reportDirectoryName =
java.time.LocalDate.now().toString() + "_" + patchBranch + "_reports";
Expand Down
Loading

0 comments on commit 4e403d4

Please sign in to comment.