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

Using Flutter within other GitHub Action does not work #320

Open
Friesenjung opened this issue Jul 12, 2024 · 3 comments
Open

Using Flutter within other GitHub Action does not work #320

Friesenjung opened this issue Jul 12, 2024 · 3 comments

Comments

@Friesenjung
Copy link

Hello there,

I am trying to set up the GitHub Action pipeline to check our codebase through flutter test with coverage and flutter analyze.

Within the Workflow I want to use SonarQube. I have installed the SonarQube Flutter Plugin.
My yml file looks like the following:

sonar-scanner:
needs: [ flutter-analysis ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Flutter SDK
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version-file: pubspec.yaml
- name: Download Test Results
uses: actions/download-artifact@v4
with:
name: test-results.json
- name: Download Coverage Results
uses: actions/download-artifact@v4
with:
name: coverage.LCOV
- uses: dart-lang/setup-dart@v1
- name: SonarQube Scan
uses: sonarsource/[email protected]
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }}
- name: SonarQube Quality Gate check
id: sonarqube-quality-gate-check
uses: sonarsource/sonarqube-quality-gate-action@master
# Force to fail step after specific time.
timeout-minutes: 1
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }}

During the SonarQube execution a get an error, saying that command flutter cannot be found:
org.buildobjects.process.StartupException: Could not startup process 'flutter analyze --no-fatal-warnings --no-fatal-infos'.
...
Caused by: java.io.IOException: Cannot run program "flutter" (in directory "/github/workspace"): error=2, No such file or directory

It seems that the command flutter is not installed as it would be installed if I am running the installation on a native server.
My question is, is there anything I can do to make the flutter command available to SonarQube using this action?
Thanks in advance!

@yurikoles
Copy link

yurikoles commented Jul 12, 2024

It seems like the flutter binary is pruned from PATH by subsequent actions. Could you please try to move Flutter setup action to the bottom, just before the latest one?

In order to debug, you may run: echo $PATH on each step and type -a flutter in each step after setting up the Flutter.

@Friesenjung
Copy link
Author

Thanks for the quick answer.
This is the output directly after the "Set Up Flutter SDK":
0s

Run echo $PATH

/home/runner/.pub-cache/bin:/opt/hostedtoolcache/flutter/stable-3.22.2-x64/bin/cache/dart-sdk/bin:/opt/hostedtoolcache/flutter/stable-3.22.2-x64/bin:/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
1s
Run type -a flutter
flutter is /opt/hostedtoolcache/flutter/stable-3.22.2-x64/bin/flutter

Which indicates for me, that everything is fine. The exact same output is printed after the Sonarqube Action when running it with continue-on-error: true.

This is my new yml file:

sonar-scanner:
needs: [ flutter-analysis ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download Test Results
uses: actions/download-artifact@v4
with:
name: test-results.json
- name: Download Coverage Results
uses: actions/download-artifact@v4
with:
name: coverage.LCOV
- name: Set up Flutter SDK
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version-file: pubspec.yaml
- run: echo $PATH
- run: type -a flutter
- name: SonarQube Scan
uses: sonarsource/[email protected]
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }}
continue-on-error: true
- run: echo $PATH
- run: type -a flutter
- name: SonarQube Quality Gate check
id: sonarqube-quality-gate-check
uses: sonarsource/sonarqube-quality-gate-action@master
# Force to fail step after specific time.
timeout-minutes: 1
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }}

@Friesenjung
Copy link
Author

Friesenjung commented Jul 13, 2024

I found out that the sonarqube Github Action is running within a container.
That might be the reason why it cannot access the flutter command outside of the container.
For example I cannot access the directory /github/workspace which is the directory where sonarqube is looking for flutter.
Any ideas who I can make it available within the container?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants