invertase / melos

🌋 A tool for managing Dart projects with multiple packages. With IntelliJ and Vscode IDE support. Supports automated versioning, changelogs & publishing via Conventional Commits.
https://melos.invertase.dev/~melos-latest
Apache License 2.0
1.17k stars 206 forks source link

Combining/inheriting filters #136

Open QuirijnGB opened 3 years ago

QuirijnGB commented 3 years ago

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?

Salakar commented 3 years ago

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

rrousselGit commented 3 years ago

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.