From a7c6c507792575325e47b6515b161d7269ce4fd4 Mon Sep 17 00:00:00 2001 From: Nico Vidoni Date: Tue, 10 Dec 2024 14:47:03 +0100 Subject: [PATCH] fix: retrieve dependencies from cache in sonar_analysis --- .github/workflows/nightly_build.yml | 11 +++++++- .github/workflows/test.yml | 44 +++++++++++++++++++---------- sonar-project.properties | 15 +++++----- 3 files changed, 47 insertions(+), 23 deletions(-) diff --git a/.github/workflows/nightly_build.yml b/.github/workflows/nightly_build.yml index 1b5f446..a3ea42d 100644 --- a/.github/workflows/nightly_build.yml +++ b/.github/workflows/nightly_build.yml @@ -39,7 +39,16 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/download-artifact@v4 + - uses: subosito/flutter-action@v2 + with: + channel: stable + cache: true + + - name: Get dependencies + run: flutter pub get + + - name: Download gen srcs and coverage + uses: actions/download-artifact@v4 with: name: gen_srcs-and-coverage diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4dff19a..35000bd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,10 +33,10 @@ jobs: - name: format check run: dart format -l 120 -o none --set-exit-if-changed . - - name: test + - name: test # takes ~ 60s, hence we store the artifact for sonar run: | dart run build_runner build --delete-conflicting-outputs - flutter test --coverage + flutter test --coverage - uses: actions/upload-artifact@v4 with: @@ -46,15 +46,38 @@ jobs: **/*.g.dart **/*.mocks.dart + package_scorer: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: axel-op/dart-package-analyzer@v3 + id: analysis + with: + githubToken: ${{ secrets.GITHUB_TOKEN }} + + +### FROM HERE: ALL DONE AFTER VALIDATION SUCCEEDS + sonar_analysis: name: SonarScanning on SonarCloud runs-on: ubuntu-latest - needs: [validation] + needs: [ validation ] steps: - uses: actions/checkout@v4 - - uses: actions/download-artifact@v4 + - uses: subosito/flutter-action@v2 + with: + channel: stable + cache: true + + - name: Get dependencies + run: flutter pub get + + - name: Download gen srcs and coverage + uses: actions/download-artifact@v4 with: name: gen_srcs-and-coverage @@ -63,21 +86,12 @@ jobs: env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - package_scorer: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - uses: axel-op/dart-package-analyzer@v3 - id: analysis - with: - githubToken: ${{ secrets.GITHUB_TOKEN }} build-android: name: Build Android runs-on: ubuntu-latest - needs: [validation] + needs: [ validation ] defaults: run: working-directory: example @@ -113,7 +127,7 @@ jobs: build-iOS: name: Build iOS package runs-on: macos-latest - needs: [validation] + needs: [ validation ] defaults: run: working-directory: example diff --git a/sonar-project.properties b/sonar-project.properties index 9701c0c..2599df4 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -5,17 +5,18 @@ sonar.projectKey=SchweizerischeBundesbahnen_journey-maps-client-flutter sonar.organization=schweizerischebundesbahnen +# Encoding of the source code. Default is default system encoding. +sonar.sourceEncoding=UTF-8 + # Code location. Path is relative to the sonar-project.properties file. Defaults to . # Use commas to specify more than one folder. sonar.sources=lib -sonar.exclusions=lib/src/fonts/**,lib/src/sbb_map/sbb_map.dart sonar.tests=test +sonar.exclusions=lib/src/fonts/**,lib/src/sbb_map/sbb_map.dart,**/*.g.dart -# Encoding of the source code. Default is default system encoding. -sonar.sourceEncoding=UTF-8 - -# Use existing options to perform dartanalyzer analysis -sonar.dart.analysis.useExistingOptions=true +# Dart / Flutter setup +sonar.flutter.enabled=true +sonar.language=dart -# Path to coverage file +# Coverage (if testing with coverage reports) sonar.dart.lcov.reportPaths=coverage/lcov.info