From 7d64d3d7401130e4c981be7b3a42f2c893634a67 Mon Sep 17 00:00:00 2001 From: 339 <393893729@qq.com> Date: Thu, 2 May 2024 13:12:58 +0800 Subject: [PATCH] update: github action sonarqube --- .github/workflows/build.yml | 42 --------------------------------- .github/workflows/sonarqube.yml | 35 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 42 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/sonarqube.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 198ffa5..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Build - -on: - push: - branches: - - master - paths-ignore: - - 'gradle/**' - - -jobs: - build: - name: Build - runs-on: ubuntu-latest - permissions: read-all - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - token: ${{ secrets.ACCESS_TOKEN }} - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - distribution: "oracle" - java-version: 17 - - 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 and analyze - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - run: ./gradlew build sonar --info diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml new file mode 100644 index 0000000..3df8a68 --- /dev/null +++ b/.github/workflows/sonarqube.yml @@ -0,0 +1,35 @@ +name: SonarQube analysis + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + workflow_dispatch: + +permissions: + pull-requests: read + +jobs: + Analysis: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Analyze with SonarQube + uses: SonarSource/sonarqube-scan-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + with: + projectBaseDir: app/src + args: + -Dsonar.projectKey=Keeper + -Dsonar.projectName=Keeper + -Dsonar.sources=main/kotlin + -Dsonar.tests=test/kotlin