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

Action not working properly inside example/ #2

Open
llucax opened this issue Jan 19, 2021 · 14 comments
Open

Action not working properly inside example/ #2

llucax opened this issue Jan 19, 2021 · 14 comments
Labels
help wanted Extra attention is needed

Comments

@llucax
Copy link

llucax commented Jan 19, 2021

Hi, I have a package that provides an example. When running flutter analyze locally, it all works fine, but when running this GitHub action I get some errors. See: https://github.com/lunofono/lunofono_player/pull/9/checks?check_run_id=1727456103#step:6:18

At some point I had those errors locally, but it was fixed after doing a flutter pub get, so maybe the action is missing that step?

@llucax
Copy link
Author

llucax commented Jan 19, 2021

At some point I had those errors locally, but it was fixed after doing a flutter pub get, so maybe the action is missing that step?

The weird thing about this is none of the pubspec.lock files were changed (in the root or in the example/) by the pub get.

@zgosalvez
Copy link
Owner

@llucax, I'll check this out further tomorrow. The readme already shows examples to run flutter pub get or dart pub get, or did you mean it also needs to be run inside of your examples folder?

@llucax
Copy link
Author

llucax commented Jan 19, 2021

@llucax, I'll check this out further tomorrow. The readme already shows examples to run flutter pub get or dart pub get, or did you mean it also needs to be run inside of your examples folder?

Yes, I'm running flutter pub get in the top folder. Not sure if it is necessary to run it somewhere else (it is supposed to run inside example too automatically when doing it in the top-level). I'm not exactly sure why this is failing in the action and not locally, nor how could I reproduce it locally, so I'm sorry I can give so few details. I can't spend much time on debugging this myself now, but maybe you had an idea on what the cause could be. If I manage to do some more investigation I will share my findings here.

@zgosalvez
Copy link
Owner

See: https://github.com/lunofono/lunofono_player/pull/9/checks?check_run_id=1727456103#step:6:18

@llucax, this link no longer points to the issue. Please identify which run failed here: https://github.com/lunofono/lunofono_player/actions. I want to be sure of the error first before I attempt to debug.

@llucax
Copy link
Author

llucax commented Jan 20, 2021

I created a separate PR that only upgrades to this action, so it's easier to see the issue in isolation: lunofono/lunofono_player#12

@zgosalvez
Copy link
Owner

Great! I appreciate the help. I'll look into this in the coming days.

@llucax
Copy link
Author

llucax commented Jan 20, 2021

The job using the action is test (static), here is a direct link to the failure again: https://github.com/lunofono/lunofono_player/pull/12/checks?check_run_id=1730340592#step:6:14

@zgosalvez
Copy link
Owner

zgosalvez commented Jan 21, 2021

@llucax, I found that the issue is caused by the dartanalyzer running from the top-level project, since it is also analyzing the example directory, which is technically a different project. I got it to work by splitting the jobs like so:

    - name: Analyze lib
      if: matrix.test_type == 'static'
      uses: zgosalvez/github-actions-analyze-flutter@v1
      with:
        working-directory: lib
        fail-on-warnings: true

    - name: Analyze test
      if: matrix.test_type == 'static'
      uses: zgosalvez/github-actions-analyze-flutter@v1
      with:
        working-directory: test
        fail-on-warnings: true

    - name: Analyze example
      if: matrix.test_type == 'static'
      uses: zgosalvez/github-actions-analyze-flutter@v1
      with:
        working-directory: example
        fail-on-warnings: true

I could also implement an excludes input to this action so that we can simplify the workflow further like so:

    - name: Analyze
      if: matrix.test_type == 'static'
      uses: zgosalvez/github-actions-analyze-flutter@v1
      with:
        excludes: example
        fail-on-warnings: true

    - name: Analyze example
      if: matrix.test_type == 'static'
      uses: zgosalvez/github-actions-analyze-flutter@v1
      with:
        working-directory: example
        fail-on-warnings: true

Thoughts?

@llucax
Copy link
Author

llucax commented Jan 21, 2021

For me what would be natural as a user of the action is that these details are handled automatically and the action behaves the same as running flutter analyze which handles the change of directory correctly when analyzing the example directory, as example is a well known standard directory in a flutter/dart package.

@zgosalvez
Copy link
Owner

It appears this action should be refactored to use the dart tool instead of using dartanalyzer and dartfmt to analyze the code. This will support your use case. Since this will be a major change to the functionality, I'll take a few weeks to have this done and tested on my projects. My main hurdle would be parsing the dart tool's response.

@llucax
Copy link
Author

llucax commented Jan 23, 2021

Oh, dann, that seems like a lot of work. I would have thought that the dart tool commands used dartanalyzer et al and had the same output format. Thanks for the update. I might go with the workaround for now

@zgosalvez
Copy link
Owner

I had initially thought that as well when I developed this action. When I read the dart tool documentation, it mentioned using the dart tool instead of dartanalyzer and dartfmt. Doesn't explain much but it seems that they're planning to have dart replace most of the existing commands.

@zgosalvez zgosalvez added the help wanted Extra attention is needed label May 12, 2021
@Bhupesh-V
Copy link

Hey is there any update on this?
the exclude option in analysis_options.yaml doesn't seem to be respected

analyzer:
  exclude: [dirA, dirB]
linter:
  rules:
#    flutter
    - avoid_print
    - ....

@jbrownsw
Copy link

I've been working around this for a while, but just happened to see this issue. If anyone is curious I just override dartanalyzer with my own script which also reformats the output since flutter analyze outputs in a different format than what the annotation expects:

    - name: Hack to use flutter analyze instead of dartanalyzer
      run: |
        cat >/opt/flutter/bin/dartanalyzer <<EOF
          #!/bin/bash
          flutter analyze --no-preamble --no-pub | head -n-1 | sed -r 's/\s[\x80-\xFF]+\s/|/g; s/^\s+//; s/:/|/g;' | awk -F\| '{printf "%s||%s|%s|%s|%s||%s\n", toupper(\$1), \$6, \$3, \$4, \$5, \$2}'
        EOF
        chmod +x /opt/flutter/bin/dartanalyzer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants