Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/code-analyze-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Code Analyze Pull Request

run-name: Run code analyze triggered with pull request by ${{github.actor}}

on:
pull_request:
types: [opened, reopened, synchronize]
branches:
- main
- dev

jobs:
build:
name: Build and analyze
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin' # Alternative distribution options are available.
- name: Cache SonarQube packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build with tests
env:
JWT_SECRET: ${{ secrets.JWT_SECRET }}
continue-on-error: true
run: ./gradlew build --info

- name: SonarQube Analysis
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
run: ./gradlew sonar --info
46 changes: 46 additions & 0 deletions .github/workflows/code-analyze-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Code Analyze Push

run-name: Run code analyze triggered with push by ${{github.actor}}

on:
push:
branches:
- dev
jobs:
build:
name: Build and analyze
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin' # Alternative distribution options are available.
- name: Cache SonarQube packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build with tests
env:
JWT_SECRET: ${{ secrets.JWT_SECRET }}
continue-on-error: true
run: ./gradlew build --info

- name: SonarQube Analysis
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
run: ./gradlew sonar --info
24 changes: 24 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.4.5'
id 'io.spring.dependency-management' version '1.1.7'
id "org.sonarqube" version "6.0.1.5171"
id 'jacoco'
}

Expand Down Expand Up @@ -64,4 +65,27 @@ dependencies {

tasks.named('test') {
useJUnitPlatform()
finalizedBy jacocoTestReport
}

jacocoTestReport {
reports {
xml.required = true
html.required = true
}
dependsOn test
}

sonar {
properties {
property "sonar.projectKey", "CleanEngine_cleanengine-be_2b6f2f63-fa39-426c-b9c7-8aa127fd14d8"
property "sonar.projectName", "cleanengine-be"
property "sonar.host.url", System.getenv('SONAR_HOST_URL') ?: 'http://localhost:9000'
property "sonar.token", System.getenv('SONAR_TOKEN') ?: ''
property "sonar.java.source", '21'
property "sonar.java.target", '21'
property "sonar.sourceEncoding", "UTF-8"
property "sonar.java.coveragePlugin", "jacoco"
property "sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/jacoco/test/jacocoTestReport.xml"
}
}
Loading