Skip to content

Commit

Permalink
enable sonarcloud (#258)
Browse files Browse the repository at this point in the history
* enable sonarcloud

* rename workflow

* always build
  • Loading branch information
wuan authored Oct 13, 2024
1 parent 8d4735f commit d266021
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: Test and Build
on:
push:
branches: [ main ]
Expand All @@ -13,11 +14,13 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'

- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Cache Gradle packages
Expand All @@ -26,26 +29,26 @@ jobs:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle

- name: Cache SonarQube packages
uses: actions/cache@v4
if: github.ref_name == 'main' && github.event_name == 'push'
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Build and analyze
if: github.ref_name == 'main' && github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: ./gradlew build jacocoTestReport sonar

- name: Upload build artifacts
if: github.ref_name == 'main' && github.event_name == 'push'
uses: actions/upload-artifact@v4
with:
name: build
path: app/build/outputs
if-no-files-found: "error"

- name: Generate app bundle.
run: ./gradlew build app:bundleRelease --stacktrace
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ task clean(type: Delete) {

sonar {
properties {
property "sonar.projectKey", "bo-android"
property "sonar.projectKey", "wuan_bo-android"
property "sonar.organization", "wuan"
property "sonar.host.url", "https://sonarcloud.io"
}
}

0 comments on commit d266021

Please sign in to comment.