very_good_workflows icon indicating copy to clipboard operation
very_good_workflows copied to clipboard

feat: test coverage in all directories

Open l-borkowski opened this issue 2 years ago • 0 comments

Description Hey, I've been using very_good_workflow for a while but I've some ideas that I feel like might be a good enhancement to this tool cause I feel like It's good to first write my idea here before making my own custom workflow.

But to the point, as a developer, I would like to check test coverage for the whole project with packages that I wrote, and here's the first problem cause flutter test --coverage won't do it so locally I've done it by using melos package that I'm surprised that you're not using and It's definitely worth to check out, cause with simple config in melos.yaml

name: example

packages:
  - "*"
  - packages/**

and then running melos exec flutter test --coverage --test-randomize-ordering-seed random will automatically go through all tests directories in the project directory and packages directory.

Second thing is to merge all lcov.info files into one and check/generate report from this one file which is also easily done with melos and coverde packages that are CLI tools you have to only run melos exec --file-exists=coverage/lcov.info -- coverde filter --input ./coverage/lcov.info --output MELOS_ROOT_PATH/coverage/filtered.lcov.info --filters \.g\.dart and it will output combined file named filtered.lcov.info in coverage folder so it would be awesome to be able to at least pass this lcov file to workflow, but even better if that would be able happens by itself cause coverde and melos are fully dart packages that can be installed by dart pub global activate.

That can be even more compact by adding this to melos.yaml

name: example

packages:
  - "*"
  - packages/**

scripts:
  M:
    description: Merge all packages coverage tracefiles ignoring data related to generated files.
    run: >
      coverde rm MELOS_ROOT_PATH/coverage/filtered.lcov.info &&
      melos exec flutter test --coverage --test-randomize-ordering-seed random &&
      melos exec --file-exists=coverage/lcov.info -- coverde filter --input ./coverage/lcov.info --output MELOS_ROOT_PATH/coverage/filtered.lcov.info --filters \.g\.dart &&
      coverde value -i  coverage/filtered.lcov.info --no-verbose

with that configuration, we can just run melos M ('M' is really just a random name specified in yaml above) and it will delete previously merged lcov, run ALL test that will generate coverage and then merge them to filtered.lcov.info and then print coverage value, you can easily change coverde value to coverde check, to output coverage %

I feel like it might be a good improvement to this tool that everybody could use so that's why I want to share my thoughts here. So please let me know what you think about it.

l-borkowski avatar Mar 09 '22 12:03 l-borkowski