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

[WIP] Lock files #4550

Closed
wants to merge 78 commits into from
Closed

[WIP] Lock files #4550

wants to merge 78 commits into from

Conversation

psibi
Copy link
Member

@psibi psibi commented Jan 30, 2019

Note: Documentation fixes for https://docs.haskellstack.org/en/stable/ should target the "stable" branch, not master.

Please include the following checklist in your PR:

  • Any changes that could be relevant to users have been recorded in the ChangeLog.md
  • The documentation has been updated, if necessary.

Please also shortly describe how you tested your change. Bonus points for added tests!

@psibi psibi changed the title Lock files [WIP] Lock files Jan 30, 2019
Copy link
Contributor

@qrilka qrilka left a comment

Choose a reason for hiding this comment

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

I think we need to discuss some details in a call

src/test/Stack/LockSpec.hs Outdated Show resolved Hide resolved
let cfInfo = CFIHash cabalHash (Just cabalSize)
packageIdRev = PackageIdentifierRevision name version cfInfo
pprintExtra (name, (version, BlobKey _ _)) =
let packageIdRev = PackageIdentifierRevision name version CFILatest
Copy link
Contributor

Choose a reason for hiding this comment

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

could you explain this change? Why do we use CFILatest when we have a particular blob key?

Copy link
Member Author

@psibi psibi Mar 1, 2019

Choose a reason for hiding this comment

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

This change is for the suggestions part. Without this, if a package is not in the snapshot - The stack build tool will recommend it to be added like this:

  * Recommended action: try adding the following to your extra-deps in /home/sibi/github/tldr-hs2/stack.yaml:

string-quote-0.0.1@sha256:7d91a0ba1be44b2443497c92f2f027cd4580453b893f8b5ebf061e1d85befaf3

With the above change, it will recommend it like this:

  * Recommended action: try adding the following to your extra-deps in /home/sibi/github/tldr-hs2/stack.yaml:

string-quote-0.0.1

The reason I made that change was because of Michael's comment in the issue:

... the original stack.yaml can be even more lightweight than it is today, e.g. including the @rev:0 information there will no longer be necessary at all.

Copy link
Contributor

Choose a reason for hiding this comment

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

But why not change the suggestion properly instead? This change above complicates the logic a bit an gives no hints about reasons

, isLockFileOutdated
, loadPackageLockFile
, loadSnapshotLayerLockFile
)
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need such a large multiline import list? Why not just everything from Stack.Lock? Also it doesn't look great when not aligned with other imports in the module

cachedCompletePackageLocation :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Map RawPackageLocation PackageLocation
-> RawPackageLocation
-> RIO env PackageLocation
cachedCompletePackageLocation cachePackages rp@(RPLImmutable rpli) = do
Copy link
Contributor

Choose a reason for hiding this comment

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

minor naming suggestion: what about s/cachePackages/cachedLocations/?

case item of
Nothing -> do
pl <- completePackageLocation rpli
pure $ PLImmutable pl
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe in 1 line as PLImmutable <$> completePackageLocation rpli?

(\x -> "Lock file package removed: " <> display x)
(chRemoved change)
mapM_ logDebug addedStr
mapM_ logDebug deletedStr
Copy link
Contributor

Choose a reason for hiding this comment

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

what about

forM_ (chRemoved change) $ \p ->
  logDebug $ "Lock file package removed: " <> display p

Imo it's much more readable - e.g. 2 lines instead of 5


loadSnapshotFile ::
Path Abs File -> Path Abs Dir -> IO [RawPackageLocationImmutable]
loadSnapshotFile path rootDir = do
Copy link
Contributor

Choose a reason for hiding this comment

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

I still see the same custom parsing, do I miss something?

value

loadPackageLockFile :: Path Abs File -> IO LockFile
loadPackageLockFile lockFile = do
Copy link
Contributor

Choose a reason for hiding this comment

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

project lock?

=> Map RawPackageLocationImmutable PackageLocationImmutable
-> RawPackageLocationImmutable
-> RIO env PackageLocationImmutable
cachedSnapshotCompletePackageLocation cachePackages rpli = do
Copy link
Contributor

Choose a reason for hiding this comment

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

duplicated in cachedCompletePackageLocation?

if lockFileOutdated
then do
logDebug "Lock file is outdated or isn't present"
generatePackageLockFile stackYamlFP
Copy link
Contributor

Choose a reason for hiding this comment

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

in generatePackageLockFile you complete locations when it's needed, why can't we just reuse that information and not to go through FS to get it?

Copy link
Member Author

Choose a reason for hiding this comment

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

and not to go through FS

We go through the FS to read the lock file to see if we can avoid doing completePackageLocation and rather reuse the information from the lock file. Is there a reason you don't want to go through FS ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see no reasons not to reuse already completed locations without going through FS

@snoyberg
Copy link
Contributor

Closing in favor of #4746

@snoyberg snoyberg closed this Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants