Skip to content

Commit

Permalink
Code coverage with codeclimate.com #5 (#12)
Browse files Browse the repository at this point in the history
Added code coverage for codeclimate.com
  • Loading branch information
samokisha authored and malikin committed Sep 9, 2019
1 parent 88eee47 commit dc8c9d6
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 3 deletions.
22 changes: 21 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
language: java
jdk:
- openjdk12
- openjdk12

env:
global:
- JACOCO_SOURCE_PATH=src/main/java

cache:
directories:
- $HOME/.m2

before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build

script:
- make test

after_script:
- if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then ./cc-test-reporter format-coverage target/site/jacoco/jacoco.xml -t jacoco; fi
- if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then ./cc-test-reporter upload-coverage; fi
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.DEFAULT_GOAL := build-run

run:
java -jar ./target/hexlet-correction-0.0.1-SNAPSHOT.jar
java -jar ./target/hexlet-correction-*.jar

clean:
rm -rf ./target
Expand All @@ -12,4 +12,7 @@ build:
./mvnw clean package

update:
./mvnw versions:update-properties versions:display-plugin-updates
./mvnw versions:update-properties versions:display-plugin-updates

test:
./mvnw clean test
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[![Build Status](https://travis-ci.com/Hexlet/hexlet-correction.svg?branch=master)](https://travis-ci.com/Hexlet/hexlet-correction)
[![Maintainability](https://api.codeclimate.com/v1/badges/377ea817e9c8b7d9d6cf/maintainability)](https://codeclimate.com/github/Hexlet/hexlet-correction/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/377ea817e9c8b7d9d6cf/test_coverage)](https://codeclimate.com/github/Hexlet/hexlet-correction/test_coverage)

# hexlet-correction

Expand Down
56 changes: 56 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
<lombok.version>1.18.8</lombok.version>
<h2database.version>1.4.199</h2database.version>
<checkstyle.config.location>checkstyle.xml</checkstyle.config.location>

<!-- Code Coverage -->
<jacoco-maven-plugin.version>0.8.4</jacoco-maven-plugin.version>
<jacoco-maven-plugin.lines-coverage-ratio>0.8</jacoco-maven-plugin.lines-coverage-ratio>
<jacoco-maven-plugin.methods-coverage-ratio>0.8</jacoco-maven-plugin.methods-coverage-ratio>
</properties>

<dependencies>
Expand Down Expand Up @@ -88,6 +93,57 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<configuration>
<excludes>
<exclude>**/HexletCorrectionApplication.*</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>jacoco-check</id>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>PACKAGE</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco-maven-plugin.lines-coverage-ratio}</minimum>
</limit>
<limit>
<counter>METHOD</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco-maven-plugin.methods-coverage-ratio}</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down

0 comments on commit dc8c9d6

Please sign in to comment.