Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.buildobjects.process.StartupException: Could not startup process 'flutter analyze --no-fatal-warnings --no-fatal-infos'. #225

Closed
iBelow opened this issue Jun 26, 2024 · 13 comments
Labels
waiting for feedback A feeback is necessary to investigate further

Comments

@iBelow
Copy link

iBelow commented Jun 26, 2024

git actions:

....
     - name: πŸ•΅οΈ Analyze
        run: flutter analyze .
/// SUCCESS
      - name: πŸ§ͺ Run Tests
        run: flutter test --coverage --coverage-path=coverage/lcov.info --test-randomize-ordering-seed=random --concurrency=10
/// SUCCESS
      - name: πŸͺ² Run Sonar analyze
        uses: sonarsource/sonarqube-scan-action@master
        env:
          SONAR_TOKEN: ${{secrets.SONAR_TOKEN}}
          SONAR_PROJECT_KEY: ${{secrets.SONAR_KEY}}
          SONAR_HOST_URL: ${{secrets.SONAR_HOST_URL}}
/// ERROR org.buildobjects.process.StartupException: Could not startup process 'flutter analyze --no-fatal-warnings --no-fatal-infos'.

logic:
git action -> self-hosted runner

So, the runner raises a Docker container, inside which it tries to run the scanner, and, it fails with an error

@zippy1978
Copy link
Contributor

Hi @iBelow,

The error you get means that the "flutter" command what not found on system path.
In your "Run Sonar analyze" step, you use a different docker image (sonarsource/sonarqube-scan-action@master) where flutter is not installed.

You should install sonar-scanner on the flutter docker image, instead of using another one.

@zippy1978 zippy1978 added the waiting for feedback A feeback is necessary to investigate further label Jul 15, 2024
@iBelow
Copy link
Author

iBelow commented Jul 15, 2024

Yo, the issue is that the container is rockin’ the Flutter SDK image. You can peep that from the sweet results of the previous steps, like flutter analyze, flutter test, flutter coverage, and whatnot.

action script:

jobs:
  build:
    runs-on: self-hosted
    steps:
      - name: πŸ“š Git Checkout
        uses: actions/[email protected]

      - name: Get Flutter Version From FVM config
        id: get_flutter_version
        run: echo "::set-output name=version::$(cat .fvm/fvm_config.json | jq -r '.flutterSdkVersion')"

      - name: 🐦 Setup Flutter
        uses: subosito/[email protected]
        with:
          flutter-version: ${{ steps.get_flutter_version.outputs.version }}
          channel: stable
          cache: true
          cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}

      - name: πŸ“¦ Install Dependencies
        run: |
          flutter pub global activate very_good_cli
          flutter pub global activate intl_utils 2.8.4
          flutter pub global activate coverage

      - name: πŸ¦„ Generate Code
        run: |
          flutter pub global run intl_utils:generate
          dart run build_runner build --delete-conflicting-outputs
  
      # - name: ✨ Check Formatting
      #   run: dart format --set-exit-if-changed .

      - name: πŸ•΅οΈ Analyze
        run: flutter analyze .


      - name: πŸ§ͺ Run Tests
        run: flutter test --coverage --coverage-path=coverage/lcov.info --test-randomize-ordering-seed=random --concurrency=10

      - name: πŸͺ² Run Sonar analyze
        uses: sonarsource/sonarqube-scan-action@master
        env:
          SONAR_TOKEN: ${{secrets.SONAR_TOKEN}}
          SONAR_PROJECT_KEY: ${{secrets.SONAR_KEY}}
          SONAR_HOST_URL: ${{secrets.SONAR_HOST_URL}}
      - name: πŸ“ˆ Upload Coverage
        uses: codecov/[email protected]
        with:
          # not needed for public repos
          token: ${{ secrets.CODECOV_TOKEN }}
          file: ./coverage/lcov.info
          flags: unittests
          name: codecov-umbrella
          slug: <SLUG>
          fail_ci_if_error: true

@zippy1978
Copy link
Contributor

Ok, strange...
Maybe install sonar-scanner manually instead of using sonarsource/sonar-scan-action task.
Check #118 (comment)

@elcponce
Copy link

elcponce commented Sep 3, 2024

We fixed a similar issue at our organization updating the execution permissions of a JRE 17 file.

The details are here: #214 (comment)

@iBelow
Copy link
Author

iBelow commented Sep 5, 2024

actual:

INFO: Backup of original analysis_options.yaml file to analysis_options.yaml.sonar
INFO: Running 'flutter [analyze, --no-fatal-warnings, --no-fatal-infos]'
INFO: Restored original analysis_options.yaml file
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 1:06.109s
ERROR: Error during SonarScanner execution
INFO: Final Memory: 27M/100M
org.buildobjects.process.StartupException: Could not startup process 'flutter analyze --no-fatal-warnings --no-fatal-infos'.
INFO: ------------------------------------------------------------------------
	at org.buildobjects.process.Proc.<init>(Proc.java:91)
	at org.buildobjects.process.ProcBuilder.run(ProcBuilder.java:205)
	at fr.insideapp.sonarqube.dart.lang.issues.dartanalyzer.executable.AnalyzerExecutable.analyze(AnalyzerExecutable.java:88)
	at fr.insideapp.sonarqube.dart.lang.issues.dartanalyzer.DartAnalyzerSensor.execute(DartAnalyzerSensor.java:[67](https://github.com/<URI>/actions/runs/10717198992/job/29716394975#step:3:68))
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:88)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:61)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:79)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:61)
	at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)
	at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:204)
	at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:200)
	at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:173)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)
	at org.sonar.scanner.bootstrap.SpringScannerContainer.doAfterStart(SpringScannerContainer.java:351)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)
	at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:138)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:71)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:65)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:5[68](https://github.com/<URI>/actions/runs/10717198992/job/29716394975#step:3:69))
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at jdk.proxy1/jdk.proxy1.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:126)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
	at org.sonarsource.scanner.cli.Main.main(Main.java:62)
Caused by: java.io.IOException: Cannot run program "flutter" (in directory "/github/workspace"): error=2, No such file or directory
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:10[73](https://github.com/<URI>/actions/runs/10717198992/job/29716394975#step:3:74))
	at java.base/java.lang.Runtime.exec(Runtime.java:594)
	at org.buildobjects.process.Proc.<init>(Proc.java:77)
	... 36 more

what interesting:

Caused by: java.io.IOException: Cannot run program "flutter" (in directory "/github/workspace"): error=2, No such file or directory

So, the basic configuration looks like this:

name: "Code Analysis"

on:
  push:
    branches: [develop/base]

  pull_request:
    branches: [develop/base]

  workflow_dispatch:

jobs:
  build:
    runs-on: self-hosted
    steps:
      - name: πŸ“š Git Checkout
        uses: actions/[email protected]

      - name: Get Flutter Version From FVM config
        id: get_flutter_version
        run: echo "::set-output name=version::$(cat .fvm/fvm_config.json | jq -r '.flutterSdkVersion')"

      - name: 🐦 Setup Flutter
        uses: subosito/[email protected]
        with:
          flutter-version: ${{ steps.get_flutter_version.outputs.version }}
          channel: stable
          cache: true
          cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}

      - name: πŸ“¦ Install Dependencies
        run: |
          flutter pub global activate very_good_cli
          flutter pub global activate intl_utils 2.8.7
          flutter pub global activate coverage
      - name: πŸ¦„ Generate Code
        run: |
          dart run build_runner build --delete-conflicting-outputs
      - name: ✨ Generate Locales
        run: |
          flutter pub global run intl_utils:generate
      - name: πŸ•΅οΈ Analyze
        run: flutter analyze .

      - name: πŸ§ͺ Run Tests
        run: flutter test --coverage --coverage-path=coverage/lcov.info --test-randomize-ordering-seed=random --concurrency=10

      - name: πŸͺ² Run Sonar Analysis
        uses: sonarsource/[email protected]
        env:
          SONAR_TOKEN: ${{secrets.SONAR_TOKEN}}
          SONAR_PROJECT_KEY: ${{secrets.SONAR_KEY}}
          SONAR_HOST_URL: ${{secrets.SONAR_HOST_URL}}

      - name: πŸ“ˆ Upload Coverage
        uses: codecov/[email protected]
        with:
          # not needed for public repos
          token: ${{ secrets.CODECOV_TOKEN }}
          file: ./coverage/lcov.info
          flags: unittests
          name: codecov-umbrella
          slug: <SLUG>
          fail_ci_if_error: true

The idea is that the current Flutter version is obtained from FVM, downloaded, cached, and used throughout all steps. Sonar, as I understand, works through a Docker container and has some issues.

It might have been fixed, but in the version sonarsource/[email protected], the fix might not be included yet.

@zippy1978
Copy link
Contributor

Hi @iBelow !
I created a test projet here based on your config: https://github.com/insideapp-oss/sonar-flutter-example.
When using sonarsource/sonarqube-scan-action@mastereverything runs fine.
So maybe the action was updated since your issue.

Let me know if it is running on your side as well.

@gokul-ektar
Copy link

@zippy1978 Thanks.

I notice that the following errors in your GitHub Action run, should we ignore these errors? Moreover, in my run, these errors are not ignored and they are FATAL and terminates the GitHub action and fails the build.

INFO: Running 'flutter analyze'...
ERROR: org.buildobjects.process.StartupException: Could not startup process 'flutter analyze'.
INFO: Sensor dartanalyzer sensor [flutter] (done) | time=8ms
java.io.IOException: org.buildobjects.process.StartupException: Could not startup process 'flutter analyze'.
INFO: Sensor Flutter unit tests [flutter]
at fr.insideapp.sonarqube.dart.lang.issues.dartanalyzer.DartAnalyzerSensor.getIssuesFromAnalyzer(DartAnalyzerSensor.java:137)
at fr.insideapp.sonarqube.dart.lang.issues.dartanalyzer.DartAnalyzerSensor.recordIssuesFromAnalyzer(DartAnalyzerSensor.java:117)
at fr.insideapp.sonarqube.dart.lang.issues.dartanalyzer.DartAnalyzerSensor.execute(DartAnalyzerSensor.java:103)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:88)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:61)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:79)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:61)
at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:403)
at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:399)
at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:368)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:137)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at jdk.proxy1/jdk.proxy1.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.cli.Main.execute(Main.java:126)
at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
at org.sonarsource.scanner.cli.Main.main(Main.java:62)
Caused by: org.buildobjects.process.StartupException: Could not startup process 'flutter analyze'.
at org.buildobjects.process.Proc.(Proc.java:91)
at org.buildobjects.process.ProcBuilder.run(ProcBuilder.java:205)
at fr.insideapp.sonarqube.dart.lang.issues.dartanalyzer.DartAnalyzerSensor.getIssuesFromAnalyzer(DartAnalyzerSensor.java:130)
... 32 common frames omitted
Caused by: java.io.IOException: Cannot run program "flutter": error=2, No such file or directory
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
at java.base/java.lang.Runtime.exec(Runtime.java:594)
at org.buildobjects.process.Proc.(Proc.java:77)
... 34 common frames omitted
Caused by: java.io.IOException: error=2, No such file or directory
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.(ProcessImpl.java:314)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:244)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
... 37 common frames omitted

ERROR: Unable to find test file /home/runner/work/sonar-flutter-example/sonar-flutter-example/test/widget_test.dart
INFO: Sensor Flutter unit tests [flutter] (done) | time=13ms

@zippy1978
Copy link
Contributor

Hi @gokul-ektar ,
As explained in the trace this error means that "flutter" command cannot be launch for analysis.
So either "flutter" is not installed (or command not on path / wrong path), either you don't have permission to run the command.

@iBelow
Copy link
Author

iBelow commented Sep 9, 2024

But this GitHub Action runs in a Docker container environment, so Flutter should be inside it, ideally.

Run sonarsource/sonarqube-scan-action@master
  with:
    projectBaseDir: .
  env:
    SONAR_TOKEN: ***
    SONAR_PROJECT_KEY: 
    SONAR_HOST_URL: ***
/usr/bin/docker run --name b7b5015850d490801410096ccd44efc4e94cc_2e0282 --label 3b7b50 --workdir /github/workspace --rm -e "SONAR_TOKEN" -e "SONAR_PROJECT_KEY" -e "SONAR_HOST_URL" -e "INPUT_ARGS" -e "INPUT_PROJECTBASEDIR" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE
INFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: /github/workspace/sonar-project.properties
INFO: SonarScanner 5.0.1.3006
INFO: Java 17.0.11 Alpine (64-bit)
INFO: Linux 5.15.0-91-generic amd64
........

INFO: Sensor Dart pubspec.yaml sensor [flutter] (done) | time=2ms
INFO: Sensor Dart analysis sensor [flutter]
INFO: Detected Flutter project with version 0.0.1+1
INFO: Backup of original analysis_options.yaml file to analysis_options.yaml.sonar
INFO: Running 'flutter [analyze, --no-fatal-warnings, --no-fatal-infos]'
INFO: Restored original analysis_options.yaml file
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 59.818s
INFO: Final Memory: 27M/97M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
org.buildobjects.process.StartupException: Could not startup process 'flutter analyze --no-fatal-warnings --no-fatal-infos'.
	at org.buildobjects.process.Proc.<init>(Proc.java:91)
	at org.buildobjects.process.ProcBuilder.run(ProcBuilder.java:205)
	at fr.insideapp.sonarqube.dart.lang.issues.dartanalyzer.executable.AnalyzerExecutable.analyze(AnalyzerExecutable.java:88)
	at fr.insideapp.sonarqube.dart.lang.issues.dartanalyzer.DartAnalyzerSensor.execute(DartAnalyzerSensor.java:67)
.....
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

@zippy1978
Copy link
Contributor

@iBelow,
The problem is that if you look at the sonarsource/sonarqube-scan-action@master source: you'll se that the sonar-scanne r is running inside it's own container without flutter installed (and I do actually have the problem on my example project).

I will fix my example project

@zippy1978
Copy link
Contributor

@iBelow,
Here is a Github Actions script (from example project), that does not use sonarsource/sonarqube-scan-action:

name: Sonar Flutter Example

on:
  push:
    branches:
      - main

jobs:
  analyze:
    runs-on: ubuntu-latest
    steps:
      - name: πŸ“š Git Checkout
        uses: actions/[email protected]

      - name: Get Flutter Version From FVM config
        id: get_flutter_version
        run: echo "::set-output name=version::$(cat .fvm/fvm_config.json | jq -r '.flutterSdkVersion')"

      - name: 🐦 Setup Flutter
        uses: subosito/[email protected]
        with:
          flutter-version: ${{ steps.get_flutter_version.outputs.version }}
          channel: stable
          cache: true
          cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}

      - name: πŸ“¦ Install Dependencies
        run: flutter pub get

      - name: πŸ§ͺ Run Tests
        run: flutter test --machine --coverage > tests.output

      - name: 🍡 Setup Java
        uses: actions/setup-java@v4
        with:
          distribution: 'temurin'
          java-version: '17'

      - name: πŸͺ² Run Sonar
        run: |
          wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.1.0.4477.zip
          unzip sonar-scanner-cli-6.1.0.4477.zip
          ./sonar-scanner-6.1.0.4477/bin/sonar-scanner \
            -Dsonar.login=${{secrets.SONAR_TOKEN}} \
            -Dsonar.host.url=${{secrets.SONAR_HOST_URL}}

@iBelow
Copy link
Author

iBelow commented Sep 11, 2024

@iBelow, Here is a Github Actions script (from example project), that does not use sonarsource/sonarqube-scan-action:

name: Sonar Flutter Example

on:
  push:
    branches:
      - main

jobs:
  analyze:
    runs-on: ubuntu-latest
    steps:
      - name: πŸ“š Git Checkout
        uses: actions/[email protected]

      - name: Get Flutter Version From FVM config
        id: get_flutter_version
        run: echo "::set-output name=version::$(cat .fvm/fvm_config.json | jq -r '.flutterSdkVersion')"

      - name: 🐦 Setup Flutter
        uses: subosito/[email protected]
        with:
          flutter-version: ${{ steps.get_flutter_version.outputs.version }}
          channel: stable
          cache: true
          cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}

      - name: πŸ“¦ Install Dependencies
        run: flutter pub get

      - name: πŸ§ͺ Run Tests
        run: flutter test --machine --coverage > tests.output

      - name: 🍡 Setup Java
        uses: actions/setup-java@v4
        with:
          distribution: 'temurin'
          java-version: '17'

      - name: πŸͺ² Run Sonar
        run: |
          wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.1.0.4477.zip
          unzip sonar-scanner-cli-6.1.0.4477.zip
          ./sonar-scanner-6.1.0.4477/bin/sonar-scanner \
            -Dsonar.login=${{secrets.SONAR_TOKEN}} \
            -Dsonar.host.url=${{secrets.SONAR_HOST_URL}}

great, i will try the suggested solution and let you know

@iBelow
Copy link
Author

iBelow commented Sep 13, 2024

@iBelow, Here is a Github Actions script (from example project), that does not use sonarsource/sonarqube-scan-action:

name: Sonar Flutter Example

on:
  push:
    branches:
      - main

jobs:
  analyze:
    runs-on: ubuntu-latest
    steps:
      - name: πŸ“š Git Checkout
        uses: actions/[email protected]

      - name: Get Flutter Version From FVM config
        id: get_flutter_version
        run: echo "::set-output name=version::$(cat .fvm/fvm_config.json | jq -r '.flutterSdkVersion')"

      - name: 🐦 Setup Flutter
        uses: subosito/[email protected]
        with:
          flutter-version: ${{ steps.get_flutter_version.outputs.version }}
          channel: stable
          cache: true
          cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}

      - name: πŸ“¦ Install Dependencies
        run: flutter pub get

      - name: πŸ§ͺ Run Tests
        run: flutter test --machine --coverage > tests.output

      - name: 🍡 Setup Java
        uses: actions/setup-java@v4
        with:
          distribution: 'temurin'
          java-version: '17'

      - name: πŸͺ² Run Sonar
        run: |
          wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.1.0.4477.zip
          unzip sonar-scanner-cli-6.1.0.4477.zip
          ./sonar-scanner-6.1.0.4477/bin/sonar-scanner \
            -Dsonar.login=${{secrets.SONAR_TOKEN}} \
            -Dsonar.host.url=${{secrets.SONAR_HOST_URL}}

its works! thanx!

@iBelow iBelow closed this as completed Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for feedback A feeback is necessary to investigate further
Projects
None yet
Development

No branches or pull requests

4 participants