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

Always output all packages in build info #1126

Merged
merged 10 commits into from
Dec 3, 2023
Merged

Always output all packages in build info #1126

merged 10 commits into from
Dec 3, 2023

Conversation

JordanMartinez
Copy link
Contributor

Description of the change

Fixes #1124. I don't think there's any reason not to write out all packages... Does this need a test?

Checklist:

  • Added the change to the "Unreleased" section of the changelog
  • Added some example of the new feature to the README
  • Added a test for the contribution (if applicable)

P.S.: the above checks are not compulsory to get a change merged, so you may skip them. However, taking care of them will result in less work for the maintainers and will be much appreciated 😊

@f-f
Copy link
Member

f-f commented Nov 29, 2023

Ah brilliant, this is a good fix

I would say this doesn't need a test, but as you noted in the issue thread this thing has already regressed twice, which is strongly hinting at needing a test 😄

@JordanMartinez
Copy link
Contributor Author

Yeah.... I guess it does need a test.

Besides adding such tests, I also added an inline directive for buildInfo. On a separate note, is there a reason why buildInfo is a record containing each value rather than having each field within that record be a top-level value? (e.g. BuildInfo.packages.foo rather than BuildInfo.buildInfo.packages.foo)?

@f-f
Copy link
Member

f-f commented Nov 30, 2023

On a separate note, is there a reason why buildInfo is a record containing each value rather than having each field within that record be a top-level value? (e.g. BuildInfo.packages.foo rather than BuildInfo.buildInfo.packages.foo)?

Yes - I don't recall if we have TODOs about this anywhere, but it has that shape so that we can include things like build time, git commit and other non-package-specific info

@JordanMartinez
Copy link
Contributor Author

On a separate note, is there a reason why buildInfo is a record containing each value rather than having each field within that record be a top-level value? (e.g. BuildInfo.packages.foo rather than BuildInfo.buildInfo.packages.foo)?

Yes - I don't recall if we have TODOs about this anywhere, but it has that shape so that we can include things like build time, git commit and other non-package-specific info

Just to clarify, you are saying there is a reason for the current code below:

module Spago.Generated.BuildInfo where

buildInfo :: { packages :: <recordType>, pursVersion :: String, spagoVersion :: String }
buildInfo =
  { packages: { "foo": "1.2.3", "bar": "1.2.3" }
  , pursVersion: "1.2.3"
  , spagoVersion: "1.2.3"
  }

rather than this alternative implementation:

module Spago.Generated.BuildInfo where

packages :: <recordType>
packages =
  { "foo": "1.2.3"
  , "bar": "1.2.3"
  }

pursVersion :: String
pursVersion = "1.2.3"

spagoVersion :: String
spagoVersion = "1.2.3"

Could you clarify what that reason is?

@f-f
Copy link
Member

f-f commented Dec 1, 2023

Oh, I didn't get what you meant then - no specific reason for that, they are pretty much equivalent. If we want to change this we should do it asap, because I won't want to change it liberally once we are out of alpha.

Comment on lines 66 to 70
pursVersion = do
let pursBinary = if Process.platform == Just Win32 then "purs.cmd" else "purs"
Cmd.exec pursBinary [ "--version" ]
$ Cmd.defaultExecOptions { pipeStdout = false, pipeStderr = false, pipeStdin = StdinNewPipe }

Copy link
Member

Choose a reason for hiding this comment

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

We include in this setup phase only things that are dependent on the paths, because we run the tests in temp directories so we need to fix the paths at this point.

The version of purs is not path-dependent, so we can call it inside the test itself.

Moreover, we have a helper for this already that we can just call from every test, so you don't have to parse the output, etc:

getPurs = Cmd.getExecutable "purs" >>= parseVersionOutput

Suggested change
pursVersion = do
let pursBinary = if Process.platform == Just Win32 then "purs.cmd" else "purs"
Cmd.exec pursBinary [ "--version" ]
$ Cmd.defaultExecOptions { pipeStdout = false, pipeStderr = false, pipeStdin = StdinNewPipe }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -10,6 +10,7 @@ import Spago.Core.Config as Config
import Spago.FS as FS
import Test.Spago.Build.Pedantic as Pedantic
import Test.Spago.Build.Polyrepo as BuildPolyrepo
import Test.Spago.Build.BuildInfo as BuildBuildInfo
Copy link
Member

Choose a reason for hiding this comment

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

Why not just

Suggested change
import Test.Spago.Build.BuildInfo as BuildBuildInfo
import Test.Spago.Build.BuildInfo as BuildInfo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was following the convention used in BuildPolyRepo 😄

@JordanMartinez
Copy link
Contributor Author

Oh, I didn't get what you meant then - no specific reason for that, they are pretty much equivalent. If we want to change this we should do it asap, because I won't want to change it liberally once we are out of alpha.

I've opened an issue for this in #1128 along with a few other questions.

@f-f f-f merged commit e0013d6 into master Dec 3, 2023
3 checks passed
@f-f f-f deleted the jam/fix-build-info branch December 3, 2023 11:11
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.

Selecting a package causes code to fail to compile due to invalid BuildInfo.purs file
2 participants