Skip to content

Commit

Permalink
Merge pull request #4 from spookyvale/master
Browse files Browse the repository at this point in the history
New version with visual reports
  • Loading branch information
spookyvale authored Dec 11, 2018
2 parents 81ced1d + 3251e5c commit 118029c
Show file tree
Hide file tree
Showing 49 changed files with 1,863 additions and 70 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ cache:
- $HOME/.m2

install:
- mvn clean compile -DskipTests -Dmaven.javadoc.skip=true -Dcheckstyle.skip=true
- mvn clean compile -DskipTests -Dmaven.javadoc.skip=true -Dcheckstyle.failOnViolation=false -Denforcer.fail=false

script:
- mvn package -DskipTests
- mvn package -DskipTests -Denforcer.fail=false

before_deploy:
- export RELEASE_FILE=$(ls target/*.hpi)
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
buildPlugin(jenkinsVersions: [null, '2.60.1'])
buildPlugin(jenkinsVersions: [null, '2.150.1'])
152 changes: 100 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,100 @@
# STAMP DSpot Jenkins plugin
[![Build Status](https://travis-ci.org/STAMP-project/dspot-jenkins-plugin.svg?branch=master)](https://travis-ci.org/STAMP-project/dspot-jenkins-plugin)

The plugin is meant to run DSpot as a build step within Jenkins.
Both freestyle jobs and pipelines are supported.

Developed in the context of [STAMP project](https://stamp.ow2.org/)

## Latest release
v.1.0.1-SNAPSHOT (DSpot 1.2.2-SNAPSHOT)

## Install
* Install the plugin in Jenkins (for details on how to install a plugin see [here](https://jenkins.io/doc/book/managing/plugins/)).

* You can download the released hpi file or build from source with

```
mvn package
```

## Configure

### Freestyle job
* Create a freestyle job that complies your tests
* Add a build action to run Dspot

### Pipeline
add the dspot step in the build stage:
`dspot variable1: value1, ..., variable1: valueN`
see the table below for the variable list.
All variables are optional and default to the values in the table

## Options

| Option | pipeline variable | Usage | Default |
| -------- | ------ | --------------------------------------------------- | ------- |
| `Project Location` | `projectPath` | path to the target project root from the folder where dspot is executed. | Defaults to Workspace |
| `Source location` | `srcCode` | path to the source code folder | `src/main/java/` |
| `Tests location` | `testCode` | path to the test source folder | `src/test/java/` |
| `Source binary location` | `srcClasses` | path to the compiled code folder. (.class files) | `target/classes/` |
| `Tests binary location` | `testClasses` | path to the compiled tests folder. (.class files) | `target/test-classes/` |
| `Filter` | `testFilter` | filter on the package name containing tests to be amplified | all tests |
| `Output directory` | `outputDir` | path to the output folder | `dspot-out` |
| `Run on changes` | `onlyChanges` | Runs only on new or changed tests since the last build | `false` |

For detailed information on the options have a look at [DSpot documentation](https://github.com/STAMP-project/dspot).

## Use
Build your project.
DSpot will be run on the selected tests and the reports / amplified tests will be stored in the specified folder in your workspace.

_Initial development by Engineering_
# STAMP DSpot Jenkins plugin
[![Build Status](https://travis-ci.org/STAMP-project/dspot-jenkins-plugin.svg?branch=master)](https://travis-ci.org/STAMP-project/dspot-jenkins-plugin)

The plugin is meant to run DSpot as a build step within Jenkins and visualize reports in the Jenkins UI.
Both freestyle jobs and pipelines are supported.

Developed in the context of [STAMP project](https://stamp.ow2.org/)

## Latest release
v.1.0.1-SNAPSHOT (DSpot 1.2.2-SNAPSHOT)

## Install
* Install the plugin in Jenkins (for details on how to install a plugin see [here](https://jenkins.io/doc/book/managing/plugins/)).

* You can download the released hpi file or build from source with

```
mvn package
```

## Configure

### Freestyle job
* Create a freestyle job that complies your tests
* Add a build action to run Dspot

### Pipeline
add the `dspot` step in the build stage:
`dspot variable1: value1, ..., variable1: valueN`
see the table below for the variable list.
All variables are optional and default to the values in the table


### Reports Only
You can use the plugin only to visualize reports of DSpot in the Jenkins UI if DSpot was used as a Maven Plugin or by any other mean.
For this you can add the Post-build action `STAMP DSpot Reports` in freestyle jobs or the step with symbol `dspot-report`.
Note that the step must be in the same node where DSpot run.


## Options

### Plugin Options
| Option | pipeline variable | Usage | Default |
| -------- | ------ | --------------------------------------------------- | ------- |
| `Run on changes` | `onlyChanges` | Runs only on new or changed tests since the last build | `false` |
| `Show reports` | `showReports` | shows the DSpot reports in a visual format in the Jenkins UI | `false` |

### Base DSPot Options
| Option | pipeline variable | Usage | Default |
| -------- | ------ | --------------------------------------------------- | ------- |
| `Project Location` | `projectPath` | path to the target project root from the folder where dspot is executed. | Defaults to Workspace |
| `Source location` | `srcCode` | path to the source code folder | `src/main/java/` |
| `Tests location` | `testCode` | path to the test source folder | `src/test/java/` |
| `Source binary location` | `srcClasses` | path to the compiled code folder. (.class files) | `target/classes/` |
| `Tests binary location` | `testClasses` | path to the compiled tests folder. (.class files) | `target/test-classes/` |
| `Filter` | `testFilter` | filter on the package name containing tests to be amplified | all tests |
| `Output directory` | `outputDir` | path to the output folder | `dspot-out` |


### Advanced Options
| Option | pipeline variable | Usage | Default |
| -------- | ------ | --------------------------------------------------- | ------- |
| `Amplifiers` | `lAmplifiers` | List of amplifiers to use | NONE |
| `Selector` | `selector` | specify the test adequacy criterion to be maximized | `PitMutantScoreSelector` |
| `Budgetizer` | `budgetizer` | specify a Bugdetizer | `NoBudgetizer` |
| `Number of Iterations` | `numIterations` | the number of amplification iterations | 3 |
| `Second Version path` | `secondFolder` | Path to the root of the second version of the project. Must be specified when using `ChangeDetectorSelector` | EMPTY |


For detailed information on the options have a look at [DSpot documentation](https://github.com/STAMP-project/dspot).

### Report Options

| Option | pipeline variable | Usage | Default |
| -------- | ------ | --------------------------------------------------- | ------- |
| `Output directory` | `outputDir` | path to the output folder of Dspot results (relative to the workspace folder) | `dspot-out` |

(these options will be ignored when the `showReports` option is enabled in the Dspot build step)

## Use
Build your project.
DSpot will be run on the selected tests and the reports / amplified tests will be stored in the specified folder in your workspace.

## Graphical Reports
A build dashboard is created to display STAMP DSpot reports.
From the dashboard the user can directly access the content of the output forlder of DSpot.

### Build views

For each build, a menu item is created to show the detailed Report of the DSpot run.

![Build dashboard](docs/img/build.PNG?raw=true "DSpot dashboard")

If test cases are successfully amplified, the user can navigate the details of the test class, getting more information on the amplified test cases.
Reports adapt based on the Selector used.

![PIT selector](docs/img/mutant.PNG?raw=true "PIT Mutant selector view")


_Initial development by Engineering in the context of STAMP H2020 project_
Binary file added docs/img/build.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/mutant.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 15 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>3.4</version>
<version>3.28</version>
<relativePath />
</parent>
<groupId>eu.stamp-project</groupId>
<artifactId>dspot-jenkins-plugin</artifactId>
<version>1.0.0</version>
<version>1.0.1-SNAPSHOT</version>
<packaging>hpi</packaging>
<properties>
<jenkins.version>2.7.3</jenkins.version>
<jenkins.version>2.150.1</jenkins.version>
<java.level>8</java.level>
</properties>
<name>Jenkins Plugin to run DSpot</name>
Expand Down Expand Up @@ -79,7 +79,18 @@
<dependency>
<groupId>eu.stamp-project</groupId>
<artifactId>dspot</artifactId>
<version>1.2.1</version>
<version>1.2.2-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>eu.stamp-project</groupId>
<artifactId>test-runner</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>eu.stamp-project</groupId>
<artifactId>test-runner</artifactId>
<version>2.0.5-SNAPSHOT</version>
</dependency>
</dependencies>
<description>Run Dspot as a Build step in Jenkins</description>
Expand Down
101 changes: 101 additions & 0 deletions src/main/java/eu/stamp_project/dspot/jenkins/DSpotReportCollector.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package eu.stamp_project.dspot.jenkins;

import java.io.IOException;
import java.io.PrintStream;

import javax.annotation.Nonnull;

import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

import eu.stamp_project.dspot.jenkins.report.DSpotResults;
import hudson.Extension;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractProject;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Notifier;
import hudson.tasks.Publisher;
import jenkins.tasks.SimpleBuildStep;

/**
* @author VDIGIACO
*
*/
@SuppressWarnings("rawtypes")
public class DSpotReportCollector extends Notifier implements SimpleBuildStep {

@Nonnull
private String outputDir = STAMPDescriptor.defaultOutputDir;

@DataBoundConstructor
public DSpotReportCollector() {

}

public String getOutputDir() {
return outputDir;
}

@DataBoundSetter
public void setOutputDir(@Nonnull String outputDir) {
this.outputDir = outputDir;
}

/*
* (non-Javadoc)
*
* @see hudson.tasks.BuildStep#getRequiredMonitorService()
*/
@Override
public BuildStepMonitor getRequiredMonitorService() {
return BuildStepMonitor.NONE;
}

@Override
public void perform(Run<?, ?> run, FilePath wsp, Launcher arg2, TaskListener listener)
throws InterruptedException, IOException {

PrintStream logger = listener.getLogger();
if(run.getAction(DSpotResultsAction.class) == null){
logger.print("DSpot report already configured from Buld step. skipping post build step config.");
return;
}
DSpotResults results = new DSpotResults(new FilePath(wsp, outputDir));

if (results.getProjectTime() == null) {
logger.print("Build WARNING. STAMP Report file was not found or it is not well-formed.");
return;
}

DSpotResultsAction action = new DSpotResultsAction(run, results);
run.addAction(action);
return;
}

@Override
public boolean needsToRunAfterFinalized() {
return true;
}

@Symbol("dspot-report")
@Extension
public static class STAMPDescriptor extends BuildStepDescriptor<Publisher> {

public static final String defaultOutputDir = "dspot-out";

@Override
public String getDisplayName() {
return "STAMP DSpot Reports";
}

@Override
public boolean isApplicable(Class<? extends AbstractProject> jobType) {
return true;
}
}
}
Loading

0 comments on commit 118029c

Please sign in to comment.