-
Notifications
You must be signed in to change notification settings - Fork 7
Support pre-release versions for PureScript tool #27
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
Conversation
@JordanMartinez Thanks for putting this together! I don't think we need this amount of flexibility around the If we want to let you opt in to the latest in a particular series or something then we should probably support SemVer ranges rather than come up with our own scheme. |
Ok, I'll update this PR to do that. |
|
I can’t give this a good review until later today, but at a glance it looks good to me. |
src/Setup/BuildPlan.purs
Outdated
liftEffect do | ||
Core.info $ fold [ "Fetching most recent version (pre-release or not) for ", Tool.name tool ] | ||
version <- liftAff $ fetchFromGitHubReleases AnyRelease (Tool.repository tool) | ||
pure (pure { tool, version }) |
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.
Usually we read the latest tag from the stored versions.json
file:
https://github.com/purescript-contrib/setup-purescript/blob/main/dist/versions.json
We do this because it's really easy to burn requests to the GitHub API and these versions don't change that frequently. You can see this in practice in the Latest
case right above this, where we read the file.
I think we might want to update the format of this file to something like:
{
"purs": { "stable": ..., "unstable": ... },
...
}
and then we can read either the latest stable or unstable version depending on what the user wants. Note that if we ever want to update to the latest unstable version faster than the daily check this repo does, we can always manually update the versions.json
file right away.
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.
(At this point it would probably help to have an actual type and JSON encoding / decoding, rather than the inline thing we've got going now)
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 keep trying to write this but then run into friction over the design of this project. Could you clarify why Tool
and Key
are separate things?
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.
The difference is a little annoying, and we probably should have just used the executable name for everything. But the reason it exists is that there can be a difference between the name of a tool (PureScript) and the name of the executable (purs).
Other than that, the only difference between Tool and Key is that the tool is a data type and the key is a string, the actual thing the user types into their action.yml file.
We also need to update the README to acknowledge this is a possible version to specify: https://github.com/purescript-contrib/setup-purescript#specify-versions |
This JSON encoding doesn't yet produce the JSON that would decode properly here.
Note: for tools using fetchFromGitHubTags, latest is the same as unstable
Edit: it did terminate but it took a long time. |
CI is failing because it's attempting to read Perhaps we should add an env check to use the PR's |
CI now builds. |
Per a call with Thomas, the following issues were pointed out. First, while most of One could ask, "Why wasn't this repo released, such that the versions file is frozen to prevent such migration issues?" Freezing the file like that would prevent the Second, to workaround this design constraint, we can provide different versions of the
Third, since this new design touches a couple of things, we'll want to implement it in a single module to keep everything together. |
Note: this PR still updates purs to v0.14.7
@thomashoneyman I haven't tested this locally, but this is the design I went with. I can walk you through this via a call if that would help, but I'll try to summarize things below. I put the version files in In the codecs, I decided not to reuse things like |
README.md
Outdated
Each tool can accept one of the following: | ||
- a semantic version (only exact versions currently supported) | ||
- the string `"latest"`, which represents the latest non-prerelease version | ||
- the string `"unstable"`, which represents the latest version (pre-release or not) |
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.
Perhaps we can specify that:
"latest"
will bring in the latest version that uses major, minor, and patch, but it will omit versions using build metadata or prerelease identifiers"unstable"
will bring in the latest version no matter what it is (ie. build metadata and prerelease identifiers are accepted)
src/Setup/Data/VersionFiles.purs
Outdated
-- in case we add support for other tools in the future... | ||
toolToMbString = case _ of |
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.
Maybe just printTool
for the name, and update the comment to say something like:
-- We preserve the set of tools that existed at the time this version format was produced;
-- if more tools are added, they should map to `Nothing`
src/Setup/UpdateVersions.purs
Outdated
Just versions' -> do | ||
let | ||
unstable = firstUnstableVersion <|> Array.head versions' | ||
latest = Array.find (not <<< Version.isPreRelease) versions' |
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 really ought to check for build metadata, too. We can check that the Version.buildMetadata
list is empty.
pure | ||
if isDraft then Nothing | ||
else Just version |
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 is a little clunky (I know it's not your code) -- mind updating it to use guard
?
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 tried, but either implementation of guard
doesn't work.
src/Setup/UpdateVersions.purs:165:23
165 guard isDraft
^^^^^^^^^^^^^
No type class instance was found for
Control.Alternative.Alternative Aff
while applying a function guard
of type Alternative t2 => Boolean -> t2 Unit
to argument isDraft
while checking that expression guard isDraft
has type t0 t1
in value declaration toolVersions
and
src/Setup/UpdateVersions.purs:165:23
165 guard isDraft version
^^^^^^^^^^^^^^^^^^^^^
Could not match type
Version
with type
t0 (Maybe t3)
or
src/Setup/UpdateVersions.purs:165:23
165 guard isDraft $ Just version
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Could not match type
Version
with type
Maybe t3
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, the ol' guardA
. No worries, we can leave it as-is.
This looks good enough for me! With my comments addressed we can move forward. Thanks! |
Also, did you want to update your PureScript version in Nix? Looks like you're on |
If you don't mind, it would be great to update! Thanks! |
Fixes #26 using the below syntax
Similar to using
latest
as the version string, the code will find the most recent pre-release version whose version matches the one used in the string. Sounstable-0.15.0
orunstable-v0.15.0
would drop theunstable-
prefix and parse the0.15.0
part as its correspondingVersion
value. Using theVersion
value, we search for the first pre-release version that has the same version (albeit different pre-release or build metadata). Thus,unstable-0.15.0
would match0.15.0-rc.1
,0.15.0-rc.2
, or0.15.0-rc.3
, etc.. Moreover,unstable-0.15.1
would not find0.15.0-rc.1
or vice versa.In the event there are multiple pre-releases, we use whichever one was published most recently. GitHub's API returns the most recent releases first, so we don't have to do any additional sorting. If this ever changes, we'd need to update the code.
Using this API URL: https://api.github.com/repos/purescript/purescript/releases?per_page=10&page=1 the releases at the given index prove this ordering:
v0.14.0
v0.14.0-rc.5
v0.14.0-rc.4
v0.14.0-rc.3