hey24sheep / azure-flutter-tasks

Easily build and deploy with latest Flutter build tasks for Azure DevOps Pipelines Tasks
https://marketplace.visualstudio.com/items?itemName=Hey24sheep.flutter
MIT License
90 stars 22 forks source link

How to run two or more tests coverage tasks for a project with multiple modules in pipeline yml? #79

Open md99991234 opened 1 year ago

md99991234 commented 1 year ago

Hello, I have used task hey24sheep.flutter.flutter-test.FlutterTest@0 in the pipeline to run the tests and get coverage. But my question is if i have multiple modules in my project, and if i want to see their test coverage individually then how to have multiple tasks that will run test coverage with different projectDirectory or module directories ? it is currently not allowing multiple tasks for FlutterTest for different modules. I think it is allowing only single FlutterTest task in pipeline.yml for the whole project. Can you tell me how can I have multiple FlutterTest tasks in pipeline file?

Code example:

- task: hey24sheep.flutter.flutter-test.FlutterTest@0
    displayName: 'Flutter Test rider journey Packages'
    inputs:
      projectDirectory: 'AppCore/rider_journey'
      generateCodeCoverageReport: true
    enabled: true
    continueOnError: true

- task: hey24sheep.flutter.flutter-test.FlutterTest@0
    displayName: 'Flutter Test user journey Packages'
    inputs:
      projectDirectory: 'AppCore/user_journey'
      generateCodeCoverageReport: true
    enabled: true
    continueOnError: true

the above code doesnt work. Pipeline/Build doest work whenever we use multiple flutter test tasks.

hey24sheep commented 1 year ago

It should work with multiple tasks. There is no restriction of any sort that you can't add multiple Flutter test task. Remove quotes from projectDirectory, try that.

Also you don't need enabled by default it's always enabled.

If for some reason it doesn't work. You can run command task with the custom flutter test command pointing to your directory.

projectDirectory: AppCore/user_journey
md99991234 commented 1 year ago

no multiple test converage tasks are not working in same pipeline file. Also without quotes it is not working as well.

hey24sheep commented 1 year ago

What's the error you are getting? Post the logs and screenshot of the build.

Also open this issue on Azure Pipelines GitHub as it seems to be related to them.

On Wed, May 24, 2023, 12:35 AM md99991234 @.***> wrote:

no multiple test converage tasks are not working in same pipeline file. Also without quotes it is not working as well.

— Reply to this email directly, view it on GitHub https://github.com/hey24sheep/azure-flutter-tasks/issues/79#issuecomment-1559985513, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHQCT5XRTTPOA5AT3WZ2ZWTXHUC7JANCNFSM6AAAAAAYL3D7D4 . You are receiving this because you commented.Message ID: @.***>

md99991234 commented 1 year ago

this is the error i am getting while using two or more flutter test tasks:

/pipeline.yml: (Line: 84, Col: 18, Idx: 2818) - (Line: 84, Col: 18, Idx: 2818): Mapping values are not allowed in this context.

I have tried using two flutter command task also, it is giving same error. It seems multiple of same type of tasks are not running/allowed. Can you please help.

hey24sheep commented 1 year ago

@md99991234 multiple tasks are allowed. We have used them in our builds and it works normally. Also, many other people are doing what you are trying to do. So there is something else wrong with your configuration.

Post your pipeline.yml file here.

md99991234 commented 1 year ago

sure, please find the pipeline.yml below:

variables:
  - name: flutter_version
    value: 3.7.3

steps:
  - task: hey24sheep.flutter.flutter-env.FlutterEnv@0
    displayName: 'Flutter Environment setup'
    inputs:
      customPath: '/home/user/fvm/versions/${{ variables.flutter_version }}'

  - bash: |

     echo Y | fvm use ${{ variables.flutter_version }}

      fvm flutter --version

      fvm flutter pub get --verbose

    displayName: 'Pub get'
    enabled: true

  - task: hey24sheep.flutter.flutter-command.FlutterCommand@0
    displayName: 'Flutter Command coverage rider journey'
    inputs:
        projectDirectory: 'AppCore/rider_journey'
        arguments: 'test --coverage'

  - bash: |
      cd AppCore/rider_journey
      genhtml -o coverage coverage/lcov.info
    displayName: 'genhtml rider_journey'
    continueOnError: true

  - task: hey24sheep.flutter.flutter-command.FlutterCommand@0
      displayName: 'Flutter Command coverage user journey'
      inputs:
        projectDirectory: 'AppCore/user_journey'
        arguments: 'test --coverage'

  - bash: |
      cd AppCore/user_journey
      genhtml -o coverage coverage/lcov.info
   displayName: 'genhtml user journey'
   continueOnError: true
hey24sheep commented 1 year ago

The issue is related to your YAML and not with this extension. Post your full yaml here, I can't help otherwise.

Also refer to these links first

hey24sheep commented 1 year ago

@md99991234 You can copy your YAML and paste it in https://yamlpipelinesvalidator.dev/ and click validate. It will tell you all the errors there are.