Skip to content

Commit

Permalink
Merge pull request #53 from scalaquest/feature/jacoco
Browse files Browse the repository at this point in the history
Add Scoverage plugin, coverage check into CI
  • Loading branch information
maldins46 authored Feb 6, 2021
2 parents e5958b2 + 74d3b9e commit 78ba246
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 109 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CI

# Continuous Integration workflow, which aims to assure correctness and
# quality of the sources that converges into the stable branches (dev and main).

on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev

jobs:
ci:
name: Lint, build and test
runs-on: ${{ matrix.os }}

strategy:
fail-fast: true
matrix:
os: [ ubuntu-latest, macOS-latest, windows-latest ]

steps:
- name: Checkout repository
uses: actions/checkout@v2

# The project uses by default Java 11 (LTS) with scala 2.13
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-gradle-
# run it on the entire matrix would be overkill
- name: Lint sources
if: contains(runner.os, 'Linux')
run: ./gradlew spotlessCheck

- name: Compile sources
run: ./gradlew assemble

- name: Test sources
run: ./gradlew check

- name: Check coverage
run: ./gradlew checkScoverage
29 changes: 21 additions & 8 deletions .github/workflows/opt-in-ci.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
name: Opt-in CI

# A minimal version of the Continuous Integration workflow, triggerable on-demand
# from feature branches when needed, by the use of keyword [lint], [build] or [test]
# (or combination of them).

on:
push:
branches:
# feature branches only
- 'feature/*'

jobs:
OptIn:
if: contains(github.event.head_commit.message, '[style]') || contains(github.event.head_commit.message, '[asm]')
build:
name: Lint, build and test
if: |
contains(github.event.head_commit.message, '[lint]') ||
contains(github.event.head_commit.message, '[build]') ||
contains(github.event.head_commit.message, '[test]')
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

# The project uses java 11 (LTS) with scala 2.13
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

# Use cache if available for Gradle
- name: Cache Gradle packages
uses: actions/cache@v2
with:
Expand All @@ -32,10 +39,16 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Syntax and Style Check with Spotless
if: contains(github.event.head_commit.message, '[style]')
- name: Lint sources
if: contains(github.event.head_commit.message, '[lint]')
run: ./gradlew spotlessCheck

- name: Compile all Scala sources
if: contains(github.event.head_commit.message, '[asm]')
- name: Compile sources
if: contains(github.event.head_commit.message, '[build]')
run: ./gradlew assemble

- name: Test sources and coverage check
if: contains(github.event.head_commit.message, '[test]')
run: |
./gradlew check
./gradlew checkScoverage
53 changes: 0 additions & 53 deletions .github/workflows/stable-branch-ci.yml

This file was deleted.

9 changes: 9 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
plugins {
// Root-level plugin is necessary to run aggregateScoverage
id("org.scoverage")
}

subprojects {
}

buildscript { repositories { mavenCentral() }}

repositories {
jcenter()
}
1 change: 1 addition & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies {
implementation("org.danilopianini:publish-on-central:_")
implementation("com.github.maiflai:gradle-scalatest:_")
implementation("com.diffplug.spotless:spotless-plugin-gradle:_")
implementation("gradle.plugin.org.scoverage:gradle-scoverage:_")

// Makes Detekt configurable
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:_")
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/config/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ performance:

style:
MagicNumber:
ignoreNumbers: ['-2', '-1', '0', '0.5', '1', '2', '3', '4', '10', '360.0']
ignoreNumbers: ['-2', '-1', '0','0.6', '0.5', '1', '2', '3', '4', '10', '360.0']
ForbiddenComment:
allowedPatterns: 'TODO:'
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ plugins {
// Adds support for Scala
scala

// Adds scoverage support
id("org.scoverage")

// Support for semantic gis-sensitive semantic versioning
id("org.danilopianini.git-sensitive-semantic-versioning")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ plugins {
// Apply the application plugin to add support for building a CLI application in Java
application
}

// examples do not need coverage checks
scoverage {
minimumRate.set(0.toBigDecimal())
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ plugins {
// Apply the java-library plugin for API and implementation separation.
`java-library`
}

// todo libraries need 75% coverage at least. Temporarily set at 0 as cli test must be finished
scoverage {
minimumRate.set(0.toBigDecimal())
}
3 changes: 1 addition & 2 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ dependencies {

// prolog
implementation("it.unibo.alice.tuprolog:tuprolog:3.3.0")

}
}
1 change: 0 additions & 1 deletion gradle.properties

This file was deleted.

2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
55 changes: 12 additions & 43 deletions versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,18 @@
## Please, don't put extra comments in that file yet, keeping them is not supported yet.

plugin.io.gitlab.arturbosch.detekt=1.15.0
## # available=1.15.0-RC2
## # available=1.16.0-RC1

version.com.diffplug.spotless..spotless-plugin-gradle=5.8.2
## # available=5.9.0

version.com.github.julien-truffaut..monocle-core_2.13=2.1.0
## # available=2.0.4
## # available=2.0.5
## # available=2.2.0-M1
## # available=3.0.0-M0a

version.com.github.julien-truffaut..monocle-macro_2.13=2.1.0
## # available=2.0.4
## # available=2.0.5
## # available=2.2.0-M1
## # available=3.0.0-M0a

version.com.github.maiflai..gradle-scalatest=0.30

Expand Down Expand Up @@ -95,6 +92,10 @@ version.com.vladsch.flexmark..flexmark-all=0.35.10
## # available=0.62.2

version.dev.zio..zio_2.13=1.0.4
## # available=1.0.4-1
## # available=1.0.4-2

version.gradle.plugin.org.scoverage..gradle-scoverage=5.0.0

version.io.gitlab.arturbosch.detekt..detekt-formatting=1.15.0-RC1

Expand All @@ -106,47 +107,15 @@ version.org.danilopianini..git-sensitive-semantic-versioning=0.2.2
## # available=0.2.3-dev02-5fe3322
## # available=0.2.3-dev03-54802b0
## # available=0.2.3-dev03-3a2bc63
## # available=0.2.3-dev04-44b3aff
## # available=0.2.3-dev04-5538fbe
## # available=0.2.3-dev05-154bcf0
## # available=0.2.3-dev05-4fe4749
## # available=0.2.3-dev06-1d3780f
## # available=0.2.3-dev06-6b47ae5
## # available=0.2.3

version.org.danilopianini..publish-on-central=0.4.2
## # available=0.4.0-dev0c-41d440e
## # available=0.4.0-dev0i-57f094a
## # available=0.4.0-dev0k-ab8cad0
## # available=0.4.0-dev0f-835bdb2
## # available=0.4.0-dev0a-6b80e12
## # available=0.4.0-dev0l-212cc26
## # available=0.4.0-dev0f-73e6556
## # available=0.4.0-dev0j-c377852
## # available=0.4.0-dev01-5c4d45d
## # available=0.4.0-dev01-c97bafa
## # available=0.4.0-dev01-c7fc5c9
## # available=0.4.0-dev02-70752ac
## # available=0.4.0-dev02-78cde9c
## # available=0.4.0-dev03-14dc1ee
## # available=0.4.0-dev03-1a0500f
## # available=0.4.0-dev04-9ca8353
## # available=0.4.0-dev04-af81085
## # available=0.4.0-dev05-057388d
## # available=0.4.0-dev05-a4e967d
## # available=0.4.0-dev06-0df5061
## # available=0.4.0-dev07-49e672d
## # available=0.4.0-dev09-612d591
## # available=0.4.0
## # available=0.4.1-dev01-030476c
## # available=0.4.1-dev02-097aec0
## # available=0.4.1-dev02-08c7590
## # available=0.4.1-dev02-1fb8824
## # available=0.4.1-dev03-246f752
## # available=0.4.1-dev03-8533087
## # available=0.4.1-dev04-30320b5
## # available=0.4.1-dev04-2bb3a34
## # available=0.4.1-dev05-817de0e
## # available=0.4.1-dev05-b46f15d
## # available=0.4.1-dev06-4f941de
## # available=0.4.1-dev06-037a4f5
## # available=0.4.1-dev07-e22f0aa
## # available=0.4.1-dev07-4ada7d1
## # available=0.4.1

version.org.scala-lang..scala-library=2.13.4

Expand Down

0 comments on commit 78ba246

Please sign in to comment.