Skip to content

Commit

Permalink
Add Sonar action
Browse files Browse the repository at this point in the history
  • Loading branch information
Isti01 committed Oct 1, 2024
1 parent 3013833 commit 177fff0
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 42 deletions.
36 changes: 0 additions & 36 deletions .github/workflows/build.yml

This file was deleted.

16 changes: 10 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ on:
push:
branches:
- master
paths:
- 'frontend/**'
- staging
pull_request:
branches:
- master
paths:
- 'frontend/**'
types: [opened, synchronize, reopened]

jobs:
run-linters:
Expand Down Expand Up @@ -42,3 +38,11 @@ jobs:

- name: TSC
run: yarn lint:typescript

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: frontend
40 changes: 40 additions & 0 deletions .github/workflows/sonar-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: SonarCloud
on:
push:
branches:
- staging
- master
pull_request:
types: [opened, synchronize, reopened]

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
- name: Cache SonarCloud 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 and analyze
working-directory: backend
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: sh ./gradlew build sonar --info
9 changes: 9 additions & 0 deletions backend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
id("org.owasp.dependencycheck") version "10.0.4"
kotlin("jvm") version "2.0.20"
kotlin("plugin.spring") version "2.0.20"
id("org.sonarqube") version "4.4.1.3373"
}

group = "hu.bme.sch"
Expand All @@ -23,6 +24,14 @@ tasks {
}
}

sonar {
properties {
property("sonar.projectKey", "kir-dev_cmsch-backend")
property("sonar.organization", "kir-dev")
property("sonar.host.url", "https://sonarcloud.io")
}
}

repositories {
mavenCentral()
}
Expand Down
13 changes: 13 additions & 0 deletions frontend/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sonar.projectKey=kir-dev_cmsch-frontend
sonar.organization=kir-dev

# This is the name and version displayed in the SonarCloud UI.
#sonar.projectName=cmsch-frontend
#sonar.projectVersion=1.0


# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
sonar.sources=.

# Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8

0 comments on commit 177fff0

Please sign in to comment.