diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml new file mode 100644 index 0000000..7f06314 --- /dev/null +++ b/.github/workflows/ci-workflow.yml @@ -0,0 +1,46 @@ +name: SonarCloud +on: + push: + branches: + - main + 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 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + cache: 'gradle' + + - name: grant permission to gradle + run: chmod +x gradlew + + - name: Cache SonarCloud packages + uses: actions/cache@v4 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Build and analyze + env: + GITHUB_TOKEN: ${{ secrets.TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: ./gradlew build sonar --info + + - name: Backend CI Discord Notification + uses: sarisia/actions-status-discord@v1 + if: ${{ failure() }} + with: + title: ❗️ Backend CI failed ❗️ + webhook: ${{ secrets.DISCORD_URL }} + color: FF0000 diff --git a/build.gradle b/build.gradle index e5ff970..3ad6605 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,8 @@ plugins { id 'java' id 'org.springframework.boot' version '3.3.1' id 'io.spring.dependency-management' version '1.1.5' + id "org.sonarqube" version "4.4.1.3373" + } group = 'gdsc.konkuk' @@ -36,3 +38,12 @@ dependencies { tasks.named('test') { useJUnitPlatform() } + +// sonarqube plugins +sonar { + properties { + property "sonar.projectKey", "gdsc-konkuk_platform-core" + property "sonar.organization", "gdsc-konkuk" + property "sonar.host.url", "https://sonarcloud.io" + } +} \ No newline at end of file diff --git a/src/main/java/gdsc/konkuk/platformcore/PlatformCoreApplication.java b/src/main/java/gdsc/konkuk/platformcore/PlatformCoreApplication.java index b34cd6b..d319705 100644 --- a/src/main/java/gdsc/konkuk/platformcore/PlatformCoreApplication.java +++ b/src/main/java/gdsc/konkuk/platformcore/PlatformCoreApplication.java @@ -8,5 +8,6 @@ public class PlatformCoreApplication { public static void main(String[] args) { SpringApplication.run(PlatformCoreApplication.class, args); + System.out.println("TESTCITEST"); } }