Open GZGavinZhao opened 2 years ago
I support better integration in principle. Figuring out the details is always fun, though.
CC @natebosch and @jakemac53
Personally I would suggest just creating your own script under tool
, which invokes melos and then mono_repo?
If we did want to support something like this I would probably just support running arbitrary commands, we don't want to be picking up a dependency on the api of melos.
we don't want to be picking up a dependency on the api of melos.
+1
would https://github.com/google/mono_repo.dart/pull/382 be sufficient to solve this use case?
@natebosch Yes, #382 would be sufficient.
I'm not very familiar with mono_repo
so I've created an example repo to better understand how to integrate it with Melos.
It's possible to get it working with Melos, but it's not great:
# a/mono_pkg.yaml
sdk:
- stable
stages:
- analyze:
- command:
- 'dart pub global activate melos'
- 'dart pub global run melos bootstrap --scope a'
- 'dart analyze'
- format:
- command:
- 'dart pub global activate melos'
- 'dart pub global run melos bootstrap --scope a'
- 'dart format --output=none --set-exit-if-changed .'
- test:
- command:
- 'dart pub global activate melos'
- 'dart pub global run melos bootstrap --scope a'
- 'dart test'
I don't think #382 would help all that much, since you would have to configure Melos for every job, if I understand the intent of the PR correctly.
It would be optimal, if there was a way to replace the pub upgrade
step with an arbitrary command. Even better, if the command gets the name of the current package in an environment variable.
If this was configurable in mono_repo.yaml
for all jobs, it would make it really simple to set up Melos.
Yeah, having some template silly (like #382 ) would be nice. Not sure how much complexity we'd be adding...
Would it make sense to expose TaskType.beforeAllSteps
/TaskType.afterEachSteps
, maybe via mono_repo.yaml
, similar to how on_completion
is exposed? My use case could also benefit from the lack of repetition. Another option would be to define a custom action in the repo and use #382, but that would lead to nearly the same amount of repetition, I think.
melos
is another tool for managing mono repos. However, I feel thatmono_repo
is better when generating readable/debuggable CI config in the least amount of typing. Therefore, we decided to use bothmelos
andmono_repo
for our repo.This, unfortunately, poses a problem:
melos
needs to bedart pub global activate
-d and ranmelos bootstrap
to link local packages using thepubspec_overrides.yaml
file. If not, then analyzing and testing might fail.mono_repo
provides no way of running arbitrary commands at the start of each CI job.I hope we can either allow defining commands to be run at the start of each job, or add a
melos
config tomono_repo.yaml
. When set totrue
, it will add a step to activate and bootstrapmelos
before any user-defined commands are run.I have already implemented the second option in a basic way. If accepted I'd be glad to further polish it!