8000 Test for updated doc. on `latest` / ranges / `-rc` by paulo-ferraz-oliveira · Pull Request #349 · erlef/setup-beam · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Test for updated doc. on latest / ranges / -rc #349

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

Merged
merged 8 commits into from
Jun 26, 2025

Conversation

paulo-ferraz-oliveira
Copy link
Collaborator

Description

I'm trying to bring some clarity to #321, with the following in mind:

  1. don't break the interface
  2. clarify the assumptions in README.md
  3. test the assumption

Closes #321.

@paulo-ferraz-oliveira paulo-ferraz-oliveira force-pushed the fix/clarify-test-latest-ranges branch from d7d8283 to 6be4922 Compare June 24, 2025 23:57
@paulo-ferraz-oliveira
Copy link
Collaborator Author
8000 paulo-ferraz-oliveira commented Jun 25, 2025

@Schultzer, I'm looking at #269 to find a reference for the change proposed in the PR.

Can you remember what this was for: https://github.com/erlef/setup-beam/pull/269/files#diff-6406ae11684199b17d2cdca1efe2cfa29fb4587c3b142f1d33ad5f81a5acf7adR388-R389?


Edit: I also think there's something strange with https://github.com/erlef/setup-beam/pull/269/files#diff-86f99337fc28b990485e054ebd09d9d3c29ec10775791de7abd2f1a85e17e241R611-R619. I think you're wrongly getting 27.0; and not 27.0-rc3.

@paulo-ferraz-oliveira
Copy link
Collaborator Author
paulo-ferraz-oliveira commented Jun 25, 2025

Also, fwiw, I'm getting a match for > 26 on maint-27 but I think it's the fault of our implementation, not semver's. Still looking at it...

Edit: I think we simply didn't count on maint-... versions before.

@paulo-ferraz-oliveira
Copy link
Collaborator Author

This just seems wrong

> semver.coerce('maint-27')
SemVer {
  options: {},
  loose: false,
  includePrerelease: false,
  raw: '27.0.0',
  major: 27,
  minor: 0,
  patch: 0,
  prerelease: [],
  build: [],
  version: '27.0.0'
}

@Schultzer
Copy link
Contributor

Can you remember what this was for: https://github.com/erlef/setup-beam/pull/269/files#diff-6406ae11684199b17d2cdca1efe2cfa29fb4587c3b142f1d33ad5f81a5acf7adR388-R389?

Yes, Rebar has both alpha- and beta- tag names.

Edit: I also think there's something strange with https://github.com/erlef/setup-beam/pull/269/files#diff-86f99337fc28b990485e054ebd09d9d3c29ec10775791de7abd2f1a85e17e241R611-R619. I think you're wrongly getting 27.0; and not 27.0-rc3.

The ubuntu version are different, one has the rc version the other not.

You can take a look in the test data to verify. Also I don’t believe we implemented logic for different main/maint versions for latest as it does not make sense in a release context.

@Schultzer
Copy link
Contributor
Schultzer commented Jun 25, 2025

This just seems wrong

> semver.coerce('maint-27')
SemVer {
  options: {},
  loose: false,
  includePrerelease: false,
  raw: '27.0.0',
  major: 27,
  minor: 0,
  patch: 0,
  prerelease: [],
  build: [],
  version: '27.0.0'
}

What is wrong with this, it’s parsed according to spec. You can try the loose option, it might preserve the maint part.

Also, fwiw, I'm getting a match for > 26 on maint-27 but I think it's the fault of our implementation, not semver's. Still looking at it...

Edit: I think we simply didn't count on maint-... versions before.

There might be a bug in the version range implementation, I think the simplest solution would be to filter the OTP versions of main out if main is not specifically specified and if main is specified coerce and sort. It’s possible to use semver sorting functions to sort the array.

@paulo-ferraz-oliveira
Copy link
Collaborator Author

Yes, Rebar has both alpha- and beta- tag names.

Cool. I'm gonna add a comment for this.

@paulo-ferraz-oliveira
Copy link
Collaborator Author
8000

The ubuntu version are different, one has the rc version the other not.

When there's 27-rc1, -rc2, -rc3, latest is -rc3. This makes sense (ubuntu-22.04).
Now when you add 27, latest is that one (skipping the -rc). Ah... I think that makes sense from a time point of view (as in "27 comes after 27-rc3").

@@ -474,8 +483,8 @@ function getVersionFromSpec(spec0, versions0) {
const altVersions = {}
Object.entries(versions0).forEach(([version, altVersion]) => {
let coerced
if (isStrictVersion() || isRC(version)) {
// If `version-type: strict` or version is RC, we just try to remove a potential initial v
if (isStrictRCOrKnown(spec)) {
Copy link
Contributor
@Schultzer Schultzer Jun 25, 2025

Choose a reason for hiding this comment

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

I’m on mobile, but it looks to me that this is the change that is causing the maint issue, as the logic has changed from isStrict or isRC. And I’m not sure why we would allow known branches here.

But if we are, then we need to refactor our implementation to sort and pick the right version, obviously the version range would need to be something like > maint.

But I’m not sure supporting branches in version ranges even makes sense, in my mind if you choose to test on maint you properly want to be strict with your versions.

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’m in mobile, but it looks to me that this is the change that is causing the maint issue

There's still no issue; I'm testing as I go.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

And I’m not sure why we would allow known branches here.

Well, the else is "maybe coerce it", and since known branches can't be coerced, the result is the same as changing that bit.

@paulo-ferraz-oliveira
Copy link
Collaborator Author

Spec states

<valid semver> ::= <version core>
                 | <version core> "-" <pre-release>
                 | <version core> "+" <build>
                 | <version core> "-" <pre-release> "+" <build>

<version core> ::= <major> "." <minor> "." <patch>

<major> ::= <numeric identifier>

<minor> ::= <numeric identifier>

<patch> ::= <numeric identifier>

Doesn't this mean that it should make maint-27 invalid? I mean, it's called coerce, sure...

@Schultzer
Copy link
Contributor
Schultzer commented Jun 25, 2025

The ubuntu version are different, one has the rc version the other not.

When there's 27-rc1, -rc2, -rc3, latest is -rc3. This makes sense (ubuntu-22.04). Now when you add 27, latest is that one (skipping the -rc). Ah... I think that makes sense from a time point of view (as in "27 comes after 27-rc3").

Yes you are correct, one of the matrix has 27 with is the most of the listed versions.

@Schultzer
Copy link
Contributor

Spec states

<valid semver> ::= <version core>
                 | <version core> "-" <pre-release>
                 | <version core> "+" <build>
                 | <version core> "-" <pre-release> "+" <build>

<version core> ::= <major> "." <minor> "." <patch>

<major> ::= <numeric identifier>

<minor> ::= <numeric identifier>

<patch> ::= <numeric identifier>

Doesn't this mean that it should make maint-27 invalid? I mean, it's called coerce, sure...

When we coerce then we take something that might not be valid semver and make it into valid semver. If you wanted to check if the the version is valid semver you should use valid function.

@paulo-ferraz-oliveira paulo-ferraz-oliveira force-pushed the fix/clarify-test-latest-ranges branch from b676b81 to 623cda0 Compare June 25, 2025 02:09
@paulo-ferraz-oliveira paulo-ferraz-oliveira force-pushed the fix/clarify-test-latest-ranges branch from 623cda0 to abc3213 Compare June 25, 2025 02:17
@paulo-ferraz-oliveira
Copy link
Collaborator Author

When we coerce then we take something that might not be valid semver and make it into valid semver.

You are correct. It's per spec for the semver coerce definition.

@paulo-ferraz-oliveira
Copy link
Collaborator Author

Tests are passing. I'm gonna make this Ready for review. I'll then point out, in the diff. elements, via comments, stuff we can discuss in threads, if any.

@paulo-ferraz-oliveira paulo-ferraz-oliveira marked this pull request as ready for review June 25, 2025 02:21
@paulo-ferraz-oliveira paulo-ferraz-oliveira force-pushed the fix/clarify-test-latest-ranges branch from f6334dc to 200b93b Compare June 25, 2025 02:29
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 thoroughly revisited this as a way to make it as clear as possible... please give it a read and lemme know otherwise.

Comment on lines +26353 to +26358
if (
isStrictVersion() ||
isRC(version) ||
isKnownBranch(version) ||
isKnownVerBranch(version)
) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are the exception we use when building the comparison list. We don't want maint-27 in the same bucket as 27.0, for example. Or even 27.0-rc3 since we state these are opt-in and latest already takes care of that.

Comment on lines +26376 to +26381
if (
isStrictVersion() ||
isRC(spec0) ||
isKnownBranch(spec0) ||
isKnownVerBranch(spec0)
) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Similarly, when the input is strict, and rc, ... we don't need to compare it in a range (done below), so we skip that entirely.

assert.deepStrictEqual(got, expected)

spec = '> 0'
expected = 'OTP-26.2.5'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Below we can see that latest is with RC, but considering a range is without it.

Copy link
Contributor
@Schultzer Schultzer left a comment

Choose a reason for hiding this comment

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

LGTM

@paulo-ferraz-oliveira
Copy link
Collaborator Author

@starbelly, I'll also leave it open for you to say something, but will eventually merge.

@paulo-ferraz-oliveira paulo-ferraz-oliveira merged commit 6a38171 into main Jun 26, 2025
73 checks passed
@paulo-ferraz-oliveira paulo-ferraz-oliveira deleted the fix/clarify-test-latest-ranges branch June 26, 2025 19:39
@wojtekmach
Copy link
Collaborator

I tried latest main with elixir-version: "> 0" and otp-version: "> 0" like below:

name: Main
on:
  push:
jobs:
  elixir-latest:
    runs-on: ubuntu-24.04
    steps:
      - uses: erlef/setup-beam@6a38171948a866c69ed72a5c19102478ec2ab81f
        with:
          elixir-version: "> 0"
          otp-version: "28.0.1"
      - run: |
          elixir --version

  otp-latest:
    runs-on: ubuntu-24.04
    steps:
      - uses: erlef/setup-beam@6a38171948a866c69ed72a5c19102478ec2ab81f
        with:
          elixir-version: "1.18.4"
          otp-version: "> 0"
      - run: |
          elixir --version

The first job succeeded however it picked latest unstable release:

image

The second job failed:

image

@Schultzer
Copy link
Contributor
Schultzer commented Jun 26, 2025

I tried latest main with elixir-version: "> 0" and otp-version: "> 0" like below:

name: Main
on:
  push:
jobs:
  elixir-latest:
    runs-on: ubuntu-24.04
    steps:
      - uses: erlef/setup-beam@6a38171948a866c69ed72a5c19102478ec2ab81f
        with:
          elixir-version: "> 0"
          otp-version: "28.0.1"
      - run: |
          elixir --version

  otp-latest:
    runs-on: ubuntu-24.04
    steps:
      - uses: erlef/setup-beam@6a38171948a866c69ed72a5c19102478ec2ab81f
        with:
          elixir-version: "1.18.4"
          otp-version: "> 0"
      - run: |
          elixir --version

The first job succeeded however it picked latest unstable release:

image The second job failed: image

Why is it installing Elixir rc?

Would be great to see which versions of elixir and otp the action is picking.

Also, can you link to the actions?

@wojtekmach
Copy link
Collaborator

@paulo-ferraz-oliveira
Copy link
Collaborator Author
paulo-ferraz-oliveira commented Jun 26, 2025

Hm... that's odd. The tests show differently. Do you see the issue with the latest released version?

Fwiw, here's a test: https://github.com/erlef/setup-beam/pull/349/files#diff-86f99337fc28b990485e054ebd09d9d3c29ec10775791de7abd2f1a85e17e241R883

and considered versions are:

OTP-26.0 8c0ea6bd3306cfd6ca19730d180a2a93a716e1ee 2023-05-16T10:29:00Z
OTP-26.0-rc1 127026003180a834e9fa5d5919c824a184faeb92 2023-02-15T10:57:55Z
OTP-26.0-rc2 dac89a6acc1a93a615930ca18f1dbf4e9323b038 2023-03-23T14:46:42Z
OTP-26.0-rc3 1f897adc9df5e0de5d5a85633a8629a7e45ddeab 2023-04-12T10:01:33Z
OTP-26.0.1 b54b86ad4f1253f46fd4552a73923756660c1d53 2023-06-08T14:30:57Z
OTP-26.0.2 d051172925a5c84b2f21850a188a533f885f201c 2023-06-29T09:18:18Z
OTP-26.1 e962af35263618665c1df57df5135c0c703ad502 2023-09-20T07:51:10Z
OTP-26.1.1 2bdd30b872ab91dc376998d2c417f2a8b514d1aa 2023-09-28T09:34:57Z
OTP-26.1.2 c41d424db42ba84b72f3e25167470c3555723d87 2023-10-12T09:11:33Z
OTP-26.2 7fc0898502cb3370b7c6d523a7393cd101808493 2023-12-13T08:53:46Z
OTP-26.2.1 ca8b893f9d5bdd0957b78514ba523032e762c644 2023-12-18T16:49:32Z
OTP-26.2.2 b83df13eec5446beab06dd24315d37a5b0633fd2 2024-02-08T15:01:20Z
OTP-26.2.3 928d03e6da416208fce7b9a7dbbfbb4f25d26c37 2024-03-07T10:01:57Z
OTP-26.2.4 e26c5206dc98ec1b8f978fceaa61fd1354266ccb 2024-04-12T13:05:00Z
10000

OTP-26.2.5 412bff5196fc0ab88a61fe37ca30e5226fc7872d 2024-05-02T16:02:47Z

@wojtekmach
Copy link
Collaborator

If you meant erlef/setup-beam@v1, same result: https://github.com/wojtekmach/setup_beam_bug/actions/runs/15912266022

@paulo-ferraz-oliveira
Copy link
Collaborator Author

Lemme try to load the same builds.txt that example is using.

@paulo-ferraz-oliveira
Copy link
Collaborator Author

Oh, yeah, that's most likely because the tests don't go to the same interface. 😢 They use a lower level version, whereas your use case is crashing "above" it.

@paulo-ferraz-oliveira
Copy link
Collaborator Author

Actually, if you look closely, Erlang installed. It's just that we're using the same input for Elixir and it crashes there... lemme try something.

@paulo-ferraz-oliveira
Copy link
Collaborator Author

@wojtekmach, if you use a range for Elixir but a "regular" version for Erlang, does it work?

@Schultzer
Copy link
Contributor
Schultzer commented Jun 26, 2025

Yup: https://github.com/wojtekmach/setup_beam_bug/actions/runs/15912204912

Interesting, I wonder what it would pick if both elixir and otp used the version range.

I’m not on my computer, but I would imagine that there is some kind of issue in our implementation for version range or maybe the sorted versions. Since per semver spec you should never get a rc.

I’m not sure but this build name might be misleading v1.19-otp-28 since it does not contain rc.

@wojtekmach
Copy link
Collaborator

@wojtekmach, if you use a range for Elixir but a "regular" version for Erlang, does it work?

That's:

          elixir-version: "> 0"
          otp-version: "28.0.1"

right? Or you had different values in mind?

@paulo-ferraz-oliveira
Copy link
Collaborator Author

That should do.

@paulo-ferraz-oliveira
Copy link
Collaborator Author

Interesting, I wonder what it would pick if both elixir and otp used the version range.

Since Erlang installs first, if we use the result of that for Elixir version we should be Ok. But we're using direct input from the action. We probably shouldn't.

@wojtekmach
Copy link
Collaborator

That was the first example!

@paulo-ferraz-oliveira
Copy link
Collaborator Author

I’m not sure but this build name might be misleading v1.19-otp-28 since it does not contain rc.

I guess...

@paulo-ferraz-oliveira
Copy link
Collaborator Author

That was the first example!

Sorry, I missed there were two, since I was already looking at the error. I think we can get around it by not trying to recalculate OTP major from consumer input, but just using what's there from the installOTP function.

@paulo-ferraz-oliveira
Copy link
Collaborator Author

I got good results in my latest implementation. Now I just gotta figure out how to mock the inputs, because the functions that actually get the versions rely on remote.

@paulo-ferraz-oliveira
Copy link
Collaborator Author

This was released in v1.20.2.

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.

Add support for latest **stable** release
3 participants
0