erlef / build-and-packaging-wg

Build and Packaging Working Group
19 stars 5 forks source link

Improved offline builds for rebar3 #39

Closed tsloughter closed 1 year ago

tsloughter commented 2 years ago

Background

TODO

Tasks

TODO

KennethL commented 2 years ago

We want to bring up the importance of this and try to find a solution for this as soon as possible. We can implement the necessary changes and additions as soon as we agree on the way forward.

KennethL commented 2 years ago

I suggest to put this on the agenda for the Dec 7:th meeting

ferd commented 2 years ago

Ran a quick Demo with John.

The short version of it: Rebar3 can seemingly support the type of vendoring the Ericsson team requires in the following way:

  1. Declare an umbrella project (with code in apps/<libname>)
  2. Declare all external dependencies in each of the top-level apps' rebar.config file (e.g. apps/myapp/rebar.config contains {deps, [elli, recon]}) but no dependencies are declared in the root's rebar.config file (these definitions get inherited by all sub-applications, and when we do the vendor step, it creates a cycle)
  3. call rebar3 get-deps to fetch but not build dependencies. These should now be in _build/default/lib
  4. mkdir lib at the root, and then mv _build/default/lib/<app-to-vendor> lib/
  5. to upgrade libraries, remove it from lib/ and use rebar3 upgrade <appname> like usual to fetch a new build, and move it back into the lib/ directory

This will make the vendored app be tracked locally in source and rebar3 will not even attempt to fetch it.

The caveats we have:

josevalim commented 2 years ago

Is it worth making the _build/default/lib/ bit configurable so it always downloads to lib anyway?

ferd commented 2 years ago

Not really, because the trick is that the build is still in _build, that's where the artifacts go. The copy/move bit just lets you transform dependencies into source applications easily by letting rebar3 fetch them for you from wherever. In fact, for git deps this might also create .git directory if you used a git resource for it.

starbelly commented 2 years ago

This does not prevent unvendored app from being fetched (whether with hex or git), which should be done with capabilities or possibly by further patches

FWIW, the way mix and mix hex works could work for rebar3. Specifically, all the hex related odds and ends could be moved into rebar3_hex. A convenience task could be added to install rebar3_hex or explain how to add it. Likewise, and in the vein of mix, if you try to get external deps, you are prompted if you want to install hex. This would of course be a major breaking change I believe.

ferd commented 1 year ago

With vendoring and the offline switches added to the bootstrap process, I believe this is now decently covered.