Send analysis to sonarqube
This commit is contained in:
81
.github/workflows/gradle.yml
vendored
81
.github/workflows/gradle.yml
vendored
@@ -1,23 +1,76 @@
|
|||||||
name: CI
|
name: Tests
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ action, master ]
|
branches:
|
||||||
|
- 'master'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ action, master ]
|
branches:
|
||||||
|
- 'master'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
test:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Set up JDK 11
|
- name: Set up JDK 11
|
||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v1
|
||||||
with:
|
with:
|
||||||
java-version: 11
|
java-version: 11
|
||||||
- uses: eskatos/gradle-command-action@v1
|
|
||||||
with:
|
- name: Cache Gradle packages
|
||||||
gradle-version: 6.8
|
uses: actions/cache@v2
|
||||||
arguments: test
|
with:
|
||||||
|
path: |
|
||||||
|
~/.gradle/caches
|
||||||
|
~/.gradle/wrapper
|
||||||
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-gradle-
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
uses: eskatos/gradle-command-action@v1
|
||||||
|
with:
|
||||||
|
gradle-version: '7.1'
|
||||||
|
arguments: build -x test -x ktlintKotlinScriptCheck -x ktlintTestSourceSetCheck -x ktlintMainSourceSetCheck
|
||||||
|
- name: Cleanup Gradle Cache
|
||||||
|
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
|
||||||
|
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
|
||||||
|
run: |
|
||||||
|
rm -f ~/.gradle/caches/modules-2/modules-2.lock
|
||||||
|
rm -f ~/.gradle/caches/modules-2/gc.properties
|
||||||
|
|
||||||
|
- name: Lint
|
||||||
|
uses: eskatos/gradle-command-action@v1
|
||||||
|
with:
|
||||||
|
gradle-version: '7.1'
|
||||||
|
arguments: ktlintCheck
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
uses: eskatos/gradle-command-action@v1
|
||||||
|
with:
|
||||||
|
gradle-version: '7.1'
|
||||||
|
arguments: test
|
||||||
|
|
||||||
|
- name: Coverage
|
||||||
|
uses: eskatos/gradle-command-action@v1
|
||||||
|
with:
|
||||||
|
gradle-version: '7.1'
|
||||||
|
arguments: jacocoTestReport
|
||||||
|
|
||||||
|
- name: Cache SonarCloud packages
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ~/.sonar/cache
|
||||||
|
key: ${{ runner.os }}-sonar
|
||||||
|
restore-keys: ${{ runner.os }}-sonar
|
||||||
|
|
||||||
|
- name: Push analyse to sonarqube
|
||||||
|
uses: eskatos/gradle-command-action@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
|
||||||
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
with:
|
||||||
|
gradle-version: '7.1'
|
||||||
|
arguments: sonarqube --info
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ plugins {
|
|||||||
id("org.owasp.dependencycheck") version "6.1.1"
|
id("org.owasp.dependencycheck") version "6.1.1"
|
||||||
id("fr.coppernic.versioning") version "3.2.1"
|
id("fr.coppernic.versioning") version "3.2.1"
|
||||||
id("com.avast.gradle.docker-compose") version "0.14.0"
|
id("com.avast.gradle.docker-compose") version "0.14.0"
|
||||||
|
id("org.sonarqube") version "+"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "io.github.flecomte"
|
group = "io.github.flecomte"
|
||||||
@@ -44,6 +45,17 @@ tasks.test {
|
|||||||
finalizedBy(tasks.ktlintCheck)
|
finalizedBy(tasks.ktlintCheck)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.jacocoTestReport {
|
||||||
|
dependsOn(tasks.test)
|
||||||
|
reports {
|
||||||
|
xml.required.set(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.sonarqube.configure {
|
||||||
|
dependsOn(tasks.jacocoTestReport)
|
||||||
|
}
|
||||||
|
|
||||||
tasks.publishToMavenLocal {
|
tasks.publishToMavenLocal {
|
||||||
dependsOn(tasks.test)
|
dependsOn(tasks.test)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +1,8 @@
|
|||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
kotlin_version=1.3.31
|
kotlin_version=1.3.31
|
||||||
|
systemProp.sonar.host.url=https://sonarcloud.io
|
||||||
|
systemProp.sonar.projectKey=postgres-json
|
||||||
|
systemProp.sonar.projectName=PostgresJson
|
||||||
|
systemProp.sonar.organization=flecomte
|
||||||
|
systemProp.sonar.java.coveragePlugin=jacoco
|
||||||
|
systemProp.sonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml
|
||||||
Reference in New Issue
Block a user