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
Closed

Make snapshot: a synonym for resolver: #4256

snoyberg opened this issue Aug 23, 2018 · 10 comments

Comments

@snoyberg
Copy link
Contributor

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.

@DanBurton
Copy link
Contributor

Also: update stack new templates to prefer snapshot.

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

@snoyberg
Copy link
Contributor Author

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
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor

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
Copy link
Contributor Author

snoyberg commented Oct 2, 2018

No worries, thanks for the update.

@aleksejkozin
Copy link
Contributor

@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
Copy link
Contributor Author

snoyberg 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
Copy link
Contributor

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
Copy link
Contributor

Closed by #4341

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants