From 79d29ef5a13af84c9b3209a9ec2ab2798513cd18 Mon Sep 17 00:00:00 2001 From: Mehmet Cevheri BOZOGLAN Date: Mon, 18 Nov 2024 22:53:36 +0300 Subject: [PATCH] Sonarcloud integration (#27) * test: add account repository test * fix: register json data * chore: add synchronized package * build: disable sonar * chore: storage package erase * fix: GetStorage test * test: add account test * fix: flutter analyze issues * feat: IMPORTANT feat... add AppLocalStorage management. removed get_storage, path_provider, synchronized and fake_async * build: sonarcloud integration --- .github/workflows/build_and_test.yml | 3 ++ .github/workflows/sonar_scanner.yml | 43 +++++++++++++++++++++++++--- sonar-project.properties | 27 +++++++++++++++++ 3 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 sonar-project.properties diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index df41214..ad4348d 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -20,6 +20,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Setup Flutter uses: subosito/flutter-action@v2.16.0 with: @@ -29,6 +30,7 @@ jobs: uses: dart-lang/setup-dart@v1.6.5 with: dart-version: 3.5.4 + - name: Setup Java JDK 17 uses: actions/setup-java@v4 with: @@ -38,6 +40,7 @@ jobs: run: echo "JAVA_HOME=/usr/lib/jvm/temurin-17-jdk-amd64" >> $GITHUB_ENV - name: flutter jdk configuration run: flutter config --jdk-dir /usr/lib/jvm/temurin-17-jdk-amd64 + - name: Install dependencies run: flutter pub get - name: Analyze diff --git a/.github/workflows/sonar_scanner.yml b/.github/workflows/sonar_scanner.yml index 430b981..10ce37f 100644 --- a/.github/workflows/sonar_scanner.yml +++ b/.github/workflows/sonar_scanner.yml @@ -3,24 +3,57 @@ on: push: branches: - sonar + - main pull_request: - types: [opened, synchronize, reopened] + branches: + - sonar + - main + types: [ opened, synchronize, reopened ] jobs: build: name: Build and analyze runs-on: ubuntu-latest container: - image: ghcr.io/cirruslabs/flutter:stable + image: ghcr.io/cirruslabs/flutter:3.24.4 steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + +# - name: Setup Flutter +# uses: subosito/flutter-action@v2.16.0 +# with: +# flutter-version: 3.24.4 +# channel: stable +# - name: Setup Dart +# uses: dart-lang/setup-dart@v1.6.5 +# with: +# dart-version: 3.5.4 + +# - name: Setup Java JDK 17 +# uses: actions/setup-java@v4 +# with: +# distribution: 'temurin' +# java-version: '17' +# - name: set JAVA_HOME +# run: echo "JAVA_HOME=/usr/lib/jvm/temurin-17-jdk-amd64" >> $GITHUB_ENV +# - name: flutter jdk configuration +# run: flutter config --jdk-dir /usr/lib/jvm/temurin-17-jdk-amd64 + + - name: Install dependencies + run: flutter pub get + - name: Analyze + run: flutter analyze + - name: Run tests + run: flutter test --coverage + - name: Cache SonarQube Cloud packages uses: actions/cache@v4 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar + - name: Build run: flutter build apk --release --target lib/main/main_prod.dart - name: Download sonar-scanner @@ -29,9 +62,11 @@ jobs: unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ - name: Build and analyze env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | $HOME/.sonar/sonar-scanner-6.2.1.4610-linux-x64/bin/sonar-scanner \ -Dsonar.projectKey=cevheri_flutter-bloc-advanced \ - -Dsonar.organization=cevheri-open-source + -Dsonar.organization=cevheri-open-source \ + -Dsonar.sources=. \ + -Dsonar.host.url=https://sonarcloud.io \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..a157722 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,27 @@ +# This is the name and version displayed in the SonarCloud UI. +sonar.projectKey=cevheri_flutter-bloc-advanced +sonar.organization=cevheri-open-source +sonar.host.url=https://sonarcloud.io + + +sonar.projectName=flutter-template +sonar.projectVersion=1.0 + + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=lib/ +sonar.exclusions=**/test/** +#sonar.test.exclusions=test/** +sonar.tests=test/ +#sonar.verbose=true + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 + +sonar.c.file.suffixes=- +sonar.cpp.file.suffixes=- +sonar.objc.file.suffixes=- + + + +sonar.dart.lcov.reportPaths=coverage/lcov.info \ No newline at end of file