melos icon indicating copy to clipboard operation
melos copied to clipboard

GitHub CI with packages/*/example issue when bumping versions

Open tenhobi opened this issue 2 years ago • 15 comments

Hi, as already discussed on Discord, I have an issue with melos running on CI (locally it works). I have two packages at packages/*, they have an example each at packages/*/example and there are other examples at examples/*.

With

packages:
  - packages/*
  - packages/*/example
  - examples/*

Now, when I bump version of those two pub-packages (packages/*) and update their version at global examples (examples/*), it works fine. When I also bump their examples (packages/*/example) it fails with

For a reference and example:

  • PR: https://github.com/netglade/auto_mappr/pull/121
  • when bumping only packages/* and examples/* (not packages/*/example) (works ok): https://github.com/netglade/auto_mappr/actions/runs/6203062251/job/16843023234
  • when bumping everything (fail): https://github.com/netglade/auto_mappr/actions/runs/6203119739/job/16843198140

As mentioned, locally with fresh clone it works, it does not work only on CI. Both tested Melos 3.1.1

tenhobi avatar Sep 15 '23 21:09 tenhobi

+1, https://github.com/GregoryConrad/mimir/actions/runs/5547031968/job/15028237279

GregoryConrad avatar Sep 15 '23 21:09 GregoryConrad

Could you try to write it like this and see if it makes any difference?

packages:
  - packages/**
  - examples/*

Might not be a solution, since you might have other packages that you don't want to bootstrap, but it would be interesting to see the result, since it works for with the package examples for us in Flame.

spydon avatar Dec 04 '23 10:12 spydon

We tried this https://github.com/netglade/auto_mappr/pull/121/commits/aa2b79b9d763a727ce22cee794a9187dc2266c0a (and various other ways, in https://github.com/netglade/auto_mappr/pull/121) and it didn't work for us.

tenhobi avatar Dec 04 '23 11:12 tenhobi

Very strange that it only fails in CI too, I guess you're also using the same Flutter version locally and in CI?

spydon avatar Dec 04 '23 11:12 spydon

Hmmm, we actually use setup-dart in GitHub actions, so it's true that the Dart version might have been different. 🤔

- uses: dart-lang/setup-dart@v1
- uses: bluefireteam/melos-action@v2

It's pure Dart project btw. Therefore we do not use FVM there.

tenhobi avatar Dec 04 '23 11:12 tenhobi

Without any specified version in that action it will take the latest stable version of Dart, so probably the same as you're running locally?

spydon avatar Dec 04 '23 12:12 spydon

Aaah, I think I know what it could be now. pub get will run for the example automatically after it runs for the package, and since you depend on more than one package within the monorepo in the example, it hasn't fully set up the other packages yet, I think that you will be able to use #604 to solve it. It probably works locally because the pubspec_overrides.yaml files are already there.

spydon avatar Dec 04 '23 14:12 spydon

Won't #604 require passing in another flag to bootstrap though? Then if we do want to bootstrap the example package, we would have to melos bs twice, the first with --no-example? That seems a bit roundabout. Why not just treat examples as separate packages in the dependency graph? Or am I missing something here?

GregoryConrad avatar Dec 04 '23 14:12 GregoryConrad

But on CI pubspec_overrides.yaml is also already there after bootstrap, no?

tenhobi avatar Dec 04 '23 15:12 tenhobi

@GregoryConrad I think that you will have to pass in the flag indeed, but since you have the examples in the packages list it should be handling them as packages too. What happens if you don't have the packages/*/example btw?

@tenhobi it is the bootstrap command that fails right?

spydon avatar Dec 04 '23 15:12 spydon

Yes, bootstrap fails (or Run bluefireteam/melos-action@v2 task, to be specific).

tenhobi avatar Dec 04 '23 15:12 tenhobi

What happens if you don't have the packages/*/example btw?

Not sure what would happen on CI, but locally you get a lot of warnings because pub get is not ran (a you would not be able to run examples, if they can be run of course).

tenhobi avatar Dec 04 '23 15:12 tenhobi

What happens if you don't have the packages/*/example btw?

Not sure, this failure seems to only pop up for me when I release a package using GitHub Actions. I think it is related to the local packages (in this case the example) referencing a version that is not yet published to pub, but is specified in the pubspec.yaml.

Edit: let me see if I can replicate this locally for you with mimir...

GregoryConrad avatar Dec 04 '23 15:12 GregoryConrad

Not sure, this failure seems to only pop up for me when I release a package using GitHub Actions. I think it is related to the local packages (in this case the example) referencing a version that is not yet published to pub.

Yeah exactly, so that is what the pubspec_overrides.yaml that Melos sets up is for you in the bootstrap step does, it links in the local packages.

I'm thinking that maybe the examples are handled implicitly without having them in the package list, so that's why I'm interested in what would happen if that line that I mentioned wasn't there.

spydon avatar Dec 04 '23 15:12 spydon

Nvm, since it has an identical example as your setup in the docs that is probably not the case: https://melos.invertase.dev/configuration/overview#packages

spydon avatar Dec 04 '23 15:12 spydon