-
Notifications
You must be signed in to change notification settings - Fork 841
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] stack freeze
command
#4220
Conversation
@snoyberg could you have a glance on this initial attempt? |
Reviewing now, I'll leave comments inline
Yes and yes. And that reminds me that I need to add an issue about fixing up all the documentation on the pantry branch.
That would be ideal, yes. Ping me if you'd like some help on how to use the integration test suite. |
@@ -63,6 +63,7 @@ import Stack.Dot | |||
import Stack.GhcPkg (findGhcPkgField) | |||
import qualified Stack.Nix as Nix | |||
import Stack.FileWatch | |||
import Stack.Freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you forgot to git add
the new modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch, forgot the main part of it
src/Stack/Freeze.hs
Outdated
} | ||
|
||
freeze :: HasEnvConfig env => FreezeOpts -> RIO env () | ||
freeze freezeOpts = do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of working at the fully-parsed level of a source map, it would be better to work on the original stack.yaml
file and any custom snapshots it refers to. I can step through that with you on a call if that would be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just couldn't find that yet and checking out code of stack dot
was easy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After having a testcase changing implementation should be even easier
@snoyberg please check out new version including a test. Will add documentation file a bit later. |
This version outputs pinned version of |
src/Stack/Freeze.hs
Outdated
plm@(PLMutable _) -> pure plm | ||
resolver' <- completeSnapshotLocation resolver | ||
deps' <- mapM completePackageLocation' deps | ||
when (deps' /= deps || resolver' /= resolver) $ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about outputting a message to the user that no freezing was necessary because they're unmodified?
src/Stack/Freeze.hs
Outdated
liftIO $ B.putStr $ Yaml.encode p{ projectDependencies = deps' | ||
, projectResolver = resolver' | ||
} | ||
Nothing -> pure () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This deserves at least a logWarn
that there was no project found.
src/Stack/Freeze.hs
Outdated
when (snap' /= snap) $ | ||
liftIO $ B.putStr $ Yaml.encode snap' | ||
Nothing -> | ||
return () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with a logWarn
here
subs/pantry/src/Pantry/Types.hs
Outdated
, ["name" .= snapshotName snap] | ||
, ["packages" .= map mkUnresolvedPackageLocationImmutable (snapshotLocations snap)] | ||
, if Set.null (snapshotDropPackages snap) then [] else ["drop-packages" .= Set.map CabalString (snapshotDropPackages snap)] | ||
, if Map.null (snapshotFlags snap) then [] else ["flags" .= fmap toCabalStringMap (toCabalStringMap (snapshotFlags snap))] | ||
, if Map.null (snapshotHidden snap) then [] else ["hidden" .= toCabalStringMap (snapshotHidden snap)] | ||
, if Map.null (snapshotGhcOptions snap) then [] else ["ghc-options" .= toCabalStringMap (snapshotGhcOptions snap)] | ||
] | ||
where | ||
(usl, compiler) = unresolveSnapshotLocation $ snapshotParent snap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good call
main = do | ||
stackCheckStdout ["freeze"] $ \stdOut -> do | ||
let expected = unlines | ||
[ "packages:" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem with this approach, but you can sort of get multiline strings in Haskell with:
"foo\n\
\bar\n\
\baz"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know but unlines
looks a bit more readable in this case imo
packages: | ||
- . | ||
extra-deps: | ||
- a50-0.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please include a @rev:
or similar here, otherwise a Hackage trustee could break this test by making a revision.
@snoyberg I've resolved conflicts, added more output and also wrote down a basic doc. Please take a look |
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:
Please also shortly describe how you tested your change:
test/integration/tests/4220-freeze-command
stack freeze
on myxlsx
package