Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build target for dependency handling #61

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Build target for dependency handling #61

wants to merge 2 commits into from

Conversation

bjosv
Copy link
Collaborator

@bjosv bjosv commented May 10, 2022

Add a build target to upgrade dependencies and update rebar.lock and mix.lock.

To conform with the Elixir documentation the file mix.lock is added to the repo.
This will guarantee that everyone who uses the project will use the same dependency versions.

To conform with the Elixir documentation the file `mix.lock`
is added to guarantee that everyone who uses the project
will use the same dependency versions.
@bjosv
Copy link
Collaborator Author

bjosv commented May 10, 2022

@alexandremcosta After looking a bit at the Elixir docs I saw that you are right, adding the lockfile is recommended.
Does this look ok to you?
mix deps.compile and mix hex.build worked fine..

Copy link
Collaborator

@zuiderkwast zuiderkwast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about including rebar.lock and mix.lock in the Hex package? Currently we don't. I'm not sure we should, just that we should make a decision here, so technically/possibly we could generate the mix files and publish them on Hex. AFAIK, Elixir users tend to use Hex rather than git dependencies, so it seems more important what's in the hex package than what's in the git repo.

Ideally, we should have just one source of truth. If we write the rebar3 files by hand and generate the mix files, that could be achieved in that way. Another idea is to check that the mix and rebar files match in some way. Then there is still a possibility to include all of them into the repo.

How does inexact deps versions like ~> 1.5 work with exact lock file entries like "eredis": {:hex, :eredis, "1.5.1", "1f771ea08a6e36bbb51733ef3e0c3e4240003a6d8081abb45876cdf32ab7a7c0", [:mix, :rebar3], [], "hexpm", "2fcd62f26a61dd56ced58879fef9405f7e201a211ec360d41c8ae045fa61e6fe"}???

@bjosv
Copy link
Collaborator Author

bjosv commented May 11, 2022

Elixir users tend to use Hex rather than git dependencies, so it seems more important what's in the hex package than what's in the git repo.

Sounds right. When looking at the top elixir packages they dont seem to include the lock file in the package, but have in the repo. The reason for this might be that the a host project using the package ignores the lock file anyway, and uses the latest version allowed from mix.exs (See guideline)

Comment on lines +63 to +67
# Upgrade all dependencies and update lock files.
# rebar3 requires the --all flag from v3.18.0
upgrade:
@$(REBAR) upgrade --all || $(REBAR) upgrade
@mix deps.update --all
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I suppose you have concluded that this way works, i.e. no need to use the unlock and lock commands. (I didn't check.)

Makefile Outdated
@$(REBAR) upgrade --all || $(REBAR) upgrade
@mix deps.update --all

publish: upgrade edoc
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After upgrading the deps, don't we need to build and test? Therefore, I'm not sure the upgrade should be part of publish.

Copy link
Collaborator Author

@bjosv bjosv May 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok, this is here to make sure that we already use the latest dependencies.
The idea is that if the upgrade step will find anything new to upgrade it will generate new lock files, which this will block the publish in the git status step.
But if there was an upgrade during publish there might be a need to log something about the need to run tests again..
The alternative is to skip this and do manual upgrades when wanted...it might be a safer way

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think we should be able to publish without upgrading. Less dependencies between operations.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it's good to check that rebar and mix has the same versions, somehow...!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a must though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One problem I noticed was that while rebar3 supports notations like "~> 1.5" rebar2 does not.
rebar2 supports regex-like notations like "1.5.*"
We've had users before with issues regarding the use of unicode in rebar.config, which rebar2 doesn't support.
So, we might run into this problem in the future when/if changing to version-ranges like we have in mix.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

@bjosv bjosv changed the title Add Elixir's dependency lockfile to the repository Build target for dependency handling May 11, 2022
`make upgrade` will upgrade packages for both rebar3 and mix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants