Skip to content

Conversation

omus
Copy link
Collaborator

@omus omus commented Feb 20, 2025

Creates the action which essentially is the version resolution portion from julia-actions/setup-julia. The motivation for creating this action is that it allows GitHub Action users to resolve a set of actions like ["lts", "1.10", "1.11", "1"] and generate a unique set of resolved versions ["1.10.8", "1.11.3"] and avoiding redundant executions in job matrices.

I eventually want to have setup-julia depend on this as a package to avoid code duplication. Probably will save that for a follow up PR.

TODO:

Depends on PR:


@omus omus marked this pull request as ready for review February 26, 2025 16:49
@omus
Copy link
Collaborator Author

omus commented Feb 26, 2025

@kleinschmidt could you do an unofficial review?

@omus omus mentioned this pull request Feb 26, 2025
@omus omus mentioned this pull request Feb 28, 2025
Comment on lines +174 to 185
```bnf
<specifier> ::= <tilde> | <caret> | <partial> | <nightly> | <alias>
<tilde> ::= "~" <partial>
<caret> ::= "^" <partial>
<partial> ::= <n> | <n> "." <n> | <n> "." <n> "." <n>
<nightly> ::= <n> "." <n> "-nightly" | "nightly"
<alias> ::= "lts" | "min"
<n> ::= "0" | <positive> <digits>
<digits> ::= <digit> | <digit> <digits>
<digit> ::= "0" | <positive>
<positive> ::= "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
```
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Originally I used a Backus-Naur form grammar similar to what NPM semver used. However, that grammar isn't even internally consistent so I instead adopted the grammar syntax used by semver itself.

Copy link

@mattBrzezinski mattBrzezinski left a comment

Choose a reason for hiding this comment

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

Starting to review this PR, I'll come back to it some more more tomorrow and the following day!

})

it("Avoid YAML number parsing", async () => {
expect(parseVersionSpecifiers("1.10")).toEqual(["1.10"])

Choose a reason for hiding this comment

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

The README makes a reference to,

When passing in a scalar prefer using a string instead of a numeric value to avoid unwanted YAML decimal conversions (e.g. 1.10 will be interpreted as 1.1).

Which we should probably test

Copy link
Collaborator Author

@omus omus Mar 11, 2025

Choose a reason for hiding this comment

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

Testing that requires an integration test from within GHA (which I can do). The YAML parsing done from within this package doesn't have that issue. Let me elaborate as this is subtle.

In a GitHub Actions workflow when passing in parameters to an action via with you can pass in any YAML data type. If you pass in say version: 1.10 the GitHub Actions YAML parser recognizes 1.10 a number which gets simplified to 1.1. When the julia-version action receives the input it reads the string "1.1". The test here is for the situation where a user sets the parameter:

version: |
  - 1.10

In that scenario GitHub Actions just passes in the string "- 1.10" which is then YAML parsed by julia-version. Due to the use of the "failsafe" YAML schema we read all scalars as strings which ensures we read "1.10" which is what we are testing for here.

Choose a reason for hiding this comment

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

Ah gotcha, thanks for clearing that up!

Copy link

@mattBrzezinski mattBrzezinski left a comment

Choose a reason for hiding this comment

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

Almost done the review, I'll come back to the last 1/3'd later today!

Copy link

@mattBrzezinski mattBrzezinski left a comment

Choose a reason for hiding this comment

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

Left a few more comments but overall LGTM!

// Set outputs for other workflow steps to use
core.setOutput("time", new Date().toTimeString())
const uniqueVersions = versionSort(
uniqueArray(resolvedVersions.filter<string>((value) => value !== null))

Choose a reason for hiding this comment

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

Not quite following the scenarios where the version would be null?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For example ^2 would currently resolve to null. Additionally, we do a HTTP HEAD request to confirm that a nightly version exists. In a scenario where a nightly doesn't exit a null would be emitted.

range.startsWith("<=") ||
range === "*"
) {
return null

Choose a reason for hiding this comment

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

Instead of returning null here, would it not be better to fail earlier? Then we can simplify the resolveVersion() and resolveVersions().

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll consider that. I do think though that missing a julia compat entry doesn't always have to result in a failure.

Choose a reason for hiding this comment

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

Oh that's a good call! I was just looking at the diff here and noticed it seems to just get called in resolveVersion() where if !juliaCompatRange it would throw an error.

Base automatically changed from cv/initial-refactor to main March 12, 2025 18:26
@omus omus merged commit 19cb54f into main Mar 12, 2025
33 checks passed
@omus omus deleted the cv/implementation branch March 12, 2025 19:27
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.

2 participants