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

Make snapshot: a synonym for resolver: #4256

Closed
snoyberg opened this issue Aug 23, 2018 · 10 comments

Comments

Projects
4 participants
@snoyberg
Copy link
Contributor

commented Aug 23, 2018

I discussed this already on Twitter. Basic idea: resolver turns out to have not been a great name. That field is used for specifying a snapshot. Let's just call a spade a spade.

Implementation: in both snapshots and stack.yaml files, instead of looking for just resolver, we'll look for both resolver and snapshot. If both are present: it's an error. If one is present, use it. If neither are present, follow through with current behavior for when there's no resolver set.

@snoyberg snoyberg added this to the P0: Blocking release milestone Aug 23, 2018

@snoyberg snoyberg added this to To do in Pantry via automation Aug 23, 2018

@snoyberg snoyberg moved this from To do to Backlog in Pantry Aug 26, 2018

@DanBurton

This comment has been minimized.

Copy link
Contributor

commented Aug 30, 2018

Also: update stack new templates to prefer snapshot.

Does stack have any philosophy regarding deprecation? Should support for resolver eventually be removed?

@snoyberg

This comment has been minimized.

Copy link
Contributor Author

commented Aug 30, 2018

We don't have an official policy. In the past, we've:

  • Added a warning on the old syntax
  • Left it in for a few versions
  • Removed support for the old syntax
@aleksejkozin

This comment has been minimized.

Copy link
Contributor

commented Sep 17, 2018

Hi, guys!
I'm a new at Haskell, but already appreciate Stack a lot
I want to help you with this task
Is it free to take?
Is it a good place to start?

@snoyberg

This comment has been minimized.

Copy link
Contributor Author

commented Sep 17, 2018

Yes to both questions! The best place to start would be to grep the src directory for the string "resolver". The most important affected module is Stack.Types.Config.

@aleksejkozin

This comment has been minimized.

Copy link
Contributor

commented Oct 1, 2018

Guys, I'm sorry for the delay
For the last two weeks I hadn't had consistent working time due to personal circumstances
I still want to finish this issue, but I need more time, week or two

@snoyberg

This comment has been minimized.

Copy link
Contributor Author

commented Oct 2, 2018

No worries, thanks for the update.

@aleksejkozin

This comment has been minimized.

Copy link
Contributor

commented Oct 4, 2018

@snoyberg can you tell me if I'm thinking in the right direction?

I want to add snapshot support into stack.yaml
To achieve it I want to amend a function parseProjectAndConfigMonoid (because it contains "resolver"):

parseProjectAndConfigMonoid :: Path Abs Dir -> Value -> Yaml.Parser (WithJSONWarnings (IO ProjectAndConfigMonoid))

My plan is:

  • add several unit tests to ConfigSpec.hs
    describe "parseProjectAndConfigMonoid"
    it "parses snapshot using 'resolver'"
    it "parses snapshot using 'snapshot'"
    it "throws if both 'resolver' and 'snapshot' are present"
  • write actual code so the tests will pass

For now I'm thinking of how to write the tests:
I want to create a temp predefined stack.yaml and load it with parseProjectAndConfigMonoid
It will give me Project object from which I can get projectResolver :: SnapshotLocation
After that I will check if projectResolver is equal to a correct value

If that is a correct line of thought then I have a question:
My stack.yaml is

 resolver: lts-2.10
 packages: ['.']

How can I do something like

projectResolver `shouldBe` "lts-2.10"

in a test?
SnapshotLocation and String types are incomparable

@snoyberg

This comment has been minimized.

Copy link
Contributor Author

commented Oct 4, 2018

Overall that sounds right. I'm not quite sure what "temp predefined stack.yaml" means.

For the unit test, you're going to have to construct a SnapshotLocation value. You can use the ltsSnapshotLocation and nightlySnapshotLocation functions from pantry for LTS and nightly snapshots, and the SLCompiler data constructor for ghc-8.4.3 style snapshots.

@aleksejkozin aleksejkozin referenced this issue Oct 5, 2018

Merged

Make snapshot: a synonym for resolver #4341

2 of 2 tasks complete
@aleksejkozin

This comment has been minimized.

Copy link
Contributor

commented Oct 5, 2018

I'm not quite sure what "temp predefined stack.yaml" means.

I was trying to say that I will copy workflow of loadConfig tests:

  • changing working directory on a temp dir using inTempDir
  • creating stack.yaml file with content of a string constant defined in ConfigSpec.hs
  • loading data from the file and verifying it

For the unit test, you're going to have to construct a SnapshotLocation value. You can use the ltsSnapshotLocation and nightlySnapshotLocation functions from pantry for LTS and nightly snapshots, and the SLCompiler data constructor for ghc-8.4.3 style snapshots.

Thx for your help, it was useful!

@mihaimaruseac

This comment has been minimized.

Copy link
Contributor

commented Oct 9, 2018

Closed by #4341

Pantry automation moved this from Backlog to Done Oct 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.