melos icon indicating copy to clipboard operation
melos copied to clipboard

Combining/inheriting filters

Open QuirijnGB opened this issue 3 years ago • 2 comments

I currently have a setup similar to this:

  ## TESTING
  test:flutter:
    run: |
      melos exec --fail-fast  --dir-exists="test" --depends-on="flutter_test" --flutter -- \
        "flutter test --no-pub --machine > tests.json"
    description: Run `flutter test` for flutter packages.

  test:dart:
    run: |
      melos exec --fail-fast --dir-exists="test"  --depends-on="test" --no-flutter -- \
        "dart test --reporter=json > tests.json"
    description: Run `dart test` for dart packages.

  test:report:
    run: |
      melos exec --fail-fast --file-exists="./tests.json" -- \
       "tojunit -i tests.json -o test-report.xml"
    description: Convert the test report.

  test:
    run: |
      melos run test:flutter && melos run test:dart && melos run test:report
    description: Run all the tests.

Multiple similar commands with different filters combined into one command to make my life easier.

This works great, but now I want to reduce my test/build time by just testing the affected packages using --since

melos run test --since=v1.2.3

The since option is essentially ignored. Am I missing something or is it currently not possible?

QuirijnGB avatar Jun 15 '21 06:06 QuirijnGB

This isn't supported at the moment and I'm not sure if adding it would even be possible without a lot of work since in this scenario there's multiple Melos processes running nested, melos run > test script > test:report script - combining filters through each process could prove tricky.

I can see it being useful though, I'll take a look into it

Salakar avatar Jun 15 '21 11:06 Salakar

With the testing changes, package filtering is now done through a reusable PackageFilter class – which is de/serializable.

So we could potentially have melos run & melos exec serialize their filters and send it to the executed command with a MELOS_PACKAGE_FILTER env variable

And have run/exec deserialize this env variable and merge it with the command args.

rrousselGit avatar Jun 20 '21 07:06 rrousselGit