Skip to content

Commit

Permalink
Add sonarqube & coveralls integrations (#46)
Browse files Browse the repository at this point in the history
Add sonarqube plugin as main platform for continous code quality
Add coveralls plugin to explore its features as a code coverage tool
Add JUnit dependency on webapp module
Add default JacoboCoverageEnableModuleTest in case there are no tests on
that module (for Jacoco to report code coverage)
Update Readme to include new tool badges
  • Loading branch information
MatiasComercio authored Jan 9, 2017
1 parent dc9fddd commit 88ff648
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 58 deletions.
20 changes: 5 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
language: java
# https://docs.travis-ci.com/user/languages/java/#Testing-Against-Multiple-JDKs
jdk:
- oraclejdk8
sudo: false
addons:
apt:
packages:
- oracle-java8-installer
sonarqube:
token:
secure: "H4jf2AGwka6JHeQ1WRb7zVwn6ZGUYPYXY91Wt22E/BQCMVsk4XMTGl+P8e1W6wzYAfrRi2j6AC5+v0VF7y4jpkooeEbLmFCNCpsAf0SQ1W3/X5EbO6xGLdAx0pV2ycxniVK52O5EoulZQdOqfQ2R4tY4sJCvzgpsuydsqaAPmK5K7fJEU7MSATQdkiQQnXoK5GJNJe+/wPu9+9iYEFoCQJ9x5z+OULPiPC6xCw21culnkgwAVvygVc5vFeudiPECj2W8t3qe9rBYjhPBi5g916g2LY1OQMs80/+OT4xKeC6rBazC86T0pcCtQGUPoulUJvJdg2TKQ3yNDWucKjZ6FYaS4ijz2nDyYq3TVPCO8O8eAyP39LIAQZ6E5c6FldU8oGMmMl3BmtQoOnQL9Qgu1ZecAsS1ZdZ5ZEgRkBteEkQvxHu1oABKnXbE+Mg50XpMERmpaT9/hWuogBzeKvJCa3QfziT9WYtAdAyl5vl5Nwf5ZAMwtcTj7MSKSp2JmTm+LTE3esbnHmCE/9dx/PZP9n6E3ttE8ytf2bo3VV4u9IMnLVPuVAZocGkpDMsTi/pHcAreZ0jS8Q0VxXR6M3tF7kZEgOoffl6DSftGRXYa2Akl9Ieez5MIy7SlEF0GVV18kJGuUDOZ9zW7nb5oIsRmCtOVNMvcnxAfWU7VhIlR/h0="
github_token:
secure: "QvYInceq9oHVh/MPO+uHRYzOucx1g1SEFvtw0eAN3EeuBOCyoJU4Vgnls08+W00tvmwXoGEWMkUh+sDktAvtucPPRzbKfS3i1lbehXuu4az83L253/b58dnq9LVyZh9WTJYu2V416tf1N0a256Fk6xo4xYDe7IG1uEd8dByxT3cJuVFtfGi3oE4BPkYX4YmA4h2Y64YXgS2tHk+zBADWhBbzn70bdrDw3ieB865VX4ucjFsmGIMufSGqwYxLQVtLOmkgvqcH3iQb48ofZbSZyi72OSsCS1RhVi8exleDZfvXvdKDRjkHrO2ZiVOrbZepNzu7V/2F9wOhybesn2ufuTAcy6xTZ6iMGlETBFeVvTsqbBH3rtCecnacsHGJePkUT7v9aD0tcluO7MtB09rUmxk3QVWwL459jwO2yqWjemFGB9TBxTETutJ5e1aEWMA77pe0CZIMoFjKHUHVkooSffk3NPDBB73tJVA9nS6MA8YZ32qYj9s1QjCC0BGPfsleYmpWqYCiEh4tasp+MWrCjbPDileoVI0LxVFWF0D5dwJ/zisiZmz2hZRTIZM2Wy5KsvJfE66lgq2UB7xE4TWiP2sGTxQEbbyLy4zBU8yLLDi5zVPRjtXeWmbooWTYfLruBmkq7u5Ec8bOUR2/Zi1kI4V3QuX8ACTFlLvj9QBYkTA="
# safelist
branches:
only:
- master
- development
- stage
script:
- sonar-scanner
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar
- mvn clean package sonar:sonar -Dsonar.host.url=https://sonarqube.com -Dsonar.login=${SONAR_TOKEN}
- mvn sonar:sonar -Dsonar.sourceEncoding=UTF-8 -Dsonar.analysis.mode=preview -Dsonar.github.repository=MatiasComercio/paw -Dsonar.github.login=MatiasComercio -Dsonar.github.oauth=${GITHUB_ACCESS_TOKEN} -Dsonar.host.url=https://sonarqube.com -Dsonar.login=${SONAR_TOKEN} -Dsonar.github.pullRequest=${TRAVIS_PULL_REQUEST}
after_success:
- mvn clean test jacoco:report coveralls:report
cache:
directories:
- '$HOME/.m2/repository'
- '$HOME/.m2'
- '$HOME/.sonar/cache'
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# SGA - Sistema de Gestión Académica

[![Build Status](https://travis-ci.org/MatiasComercio/paw.svg?branch=development)](https://travis-ci.org/MatiasComercio/paw)

[![Build Status](https://travis-ci.org/MatiasComercio/paw.svg?branch=development)](https://travis-ci.org/MatiasComercio/paw) [![Coverage Status](https://coveralls.io/repos/github/MatiasComercio/paw/badge.svg)](https://coveralls.io/github/MatiasComercio/paw) [![Code Climate](https://codeclimate.com/github/MatiasComercio/paw/badges/gpa.svg)](https://codeclimate.com/github/MatiasComercio/paw)

[![alt text][2]][1]

[1]: https://sonarqube.com/dashboard?id=ar.edu.itba.paw%3Apaw
[2]: http://www.qatestingtools.com/sites/default/files/tools_shortcuts/sonarqube-150px.png (hover text)

![Quality Gate](https://sonarqube.com/api/badges/gate?key=ar.edu.itba.paw:paw) ![Coverage Gate](https://sonarqube.com/api/badges/measure?key=ar.edu.itba.paw:paw&metric=coverage&blinking=true) ![Code Smells Gate](https://sonarqube.com/api/badges/measure?key=ar.edu.itba.paw:paw&metric=code_smells&blinking=true) ![Bugs Gate](https://sonarqube.com/api/badges/measure?key=ar.edu.itba.paw:paw&metric=bugs&blinking=true) ![Vulnerabilities](https://sonarqube.com/api/badges/measure?key=ar.edu.itba.paw:paw&metric=vulnerabilities&blinking=true)


## Git pre push hook

Expand All @@ -17,7 +26,7 @@ You can skip the hook by adding `--no-verify` to your `git push`.
- Admin:
- DNI: 38457012
- Password: pass

- Student:
- DNI: 12345687
- Password: pass
Expand All @@ -27,4 +36,3 @@ You can skip the hook by adding `--no-verify` to your `git push`.
- Gonzalo Exequiel Ibars Ingman
- Matías Mercado
- Juan Martín Pascale

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package ar.edu.itba.paw.persistence;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
* Unit test for enabling Jacoco Coverage in case there are no other tests in this module
*/
public class JacocoCoverageEnableModuleTest extends TestCase {
/**
* Create the test case
*/
public JacocoCoverageEnableModuleTest(String testName) {
super(testName);
}

/**
* @return the suite of tests being tested
*/
public static Test suite() {
return new TestSuite(JacocoCoverageEnableModuleTest.class);
}

public void testApp() {
assertTrue(true);
}
}
26 changes: 24 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@
<maven-war-plugin.version>3.0.0</maven-war-plugin.version>
<hibernate.jpa-api.version>1.0.0.Final</hibernate.jpa-api.version>
<org.jboss.logging>3.3.0.Final</org.jboss.logging>
<maven-surefire-plugin.version>2.15</maven-surefire-plugin.version>
<jacoco.version>0.7.8</jacoco.version>
<jacoco.ut.execution.data.file>${project.build.directory}/coverage-reports/jacoco-ut.exec</jacoco.ut.execution.data.file>
<skip.unit.tests>false</skip.unit.tests>
<coveralls-maven-plugin.version>4.3.0</coveralls-maven-plugin.version>
<coveralls-maven-plugin.jacoco-report>${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml</coveralls-maven-plugin.jacoco-report>
<sonar-maven-plugin.version>3.0.1</sonar-maven-plugin.version>
</properties>
<build>
<plugins>
Expand All @@ -63,7 +67,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<argLine>${argLine}</argLine>
<skipTests>${skip.unit.tests}</skipTests>
Expand All @@ -72,6 +76,11 @@
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>${coveralls-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
Expand All @@ -94,11 +103,15 @@
</goals>
<configuration>
<dataFile>${jacoco.ut.execution.data.file}</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${sonar-maven-plugin.version}</version>
</plugin>
</plugins>
</build>
<dependencyManagement>
Expand Down Expand Up @@ -322,4 +335,13 @@
</dependency>
</dependencies>
</dependencyManagement>

<!-- More Project Information -->
<url>https://github.com/MatiasComercio/paw</url>

<!-- Environment Settings -->
<ciManagement>
<system>travis</system>
<url>https://travis-ci.org/MatiasComercio/paw</url>
</ciManagement>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package ar.edu.itba.paw.services;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
* Unit test for enabling Jacoco Coverage in case there are no other tests in this module
*/
public class JacocoCoverageEnableModuleTest extends TestCase {
/**
* Create the test case
*/
public JacocoCoverageEnableModuleTest(String testName) {
super(testName);
}

/**
* @return the suite of tests being tested
*/
public static Test suite() {
return new TestSuite(JacocoCoverageEnableModuleTest.class);
}

public void testApp() {
assertTrue(true);
}
}
38 changes: 0 additions & 38 deletions shared/src/test/java/ar/edu/itba/paw/shared/AppTest.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package ar.edu.itba.paw.shared;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
* Unit test for enabling Jacoco Coverage in case there are no other tests in this module
*/
public class JacocoCoverageEnableModuleTest extends TestCase {
/**
* Create the test case
*/
public JacocoCoverageEnableModuleTest(String testName) {
super(testName);
}

/**
* @return the suite of tests being tested
*/
public static Test suite() {
return new TestSuite(JacocoCoverageEnableModuleTest.class);
}

public void testApp() {
assertTrue(true);
}
}
11 changes: 11 additions & 0 deletions webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,16 @@
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>

<!--Testing-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
</dependency>
<!--/Testing-->
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package ar.edu.itba.paw.webapp;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
* Unit test for enabling Jacoco Coverage in case there are no other tests in this module
*/
public class JacocoCoverageEnableModuleTest extends TestCase {
/**
* Create the test case
*/
public JacocoCoverageEnableModuleTest(String testName) {
super(testName);
}

/**
* @return the suite of tests being tested
*/
public static Test suite() {
return new TestSuite(JacocoCoverageEnableModuleTest.class);
}

public void testApp() {
assertTrue(true);
}
}

0 comments on commit 88ff648

Please sign in to comment.