cpp-actions icon indicating copy to clipboard operation
cpp-actions copied to clipboard

Wrong version range in docu?

Open Flamefire opened this issue 1 year ago • 5 comments

https://alandefreitas.github.io/cpp-actions/cpp-actions/actions/cpp-matrix.html says:

The semver range gcc >=4.8 <7 || 8.1 || >=10 would ensure version GCC8.1 specifically, and not any other version is the range >=8.0.0 <9.0.0 is tested.

Is this intended? I would expect the explanation to hold for gcc >=4.8 <8 || 8.1 || >=9. So it looks like either the expression or the explanation needs to be adjusted.

Flamefire avatar May 28 '24 10:05 Flamefire

The explanation holds for both. Both gcc >=4.8 <7 || 8.1 || >=10 and gcc >=4.8 <8 || 8.1 || >=9 would "ensure version GCC8.1 specifically, and not any other version is the range >=8.0.0 <9.0.0 is tested".

Maybe gcc >=4.8 <8 || 8.1 || >=9 has the benefit of being also equivalent to gcc >=4.8 except for the version in that range. That's something I didn't think about.

alandefreitas avatar May 28 '24 14:05 alandefreitas

I find it hard to understand why >=8.0.0 <9.0.0 is given. It certainly is true but isn't "GCC8.1 specifically, and not any other version in the range >=7 <10" more specific? I mean: Why would one expect that any 8.x version except the one specified is tested when the other conditions restrict to up to 6.x and from 10.x?
To me it feels like I'm missing something about the logic.

Maybe use gcc instead of clang in the preceding paragraph and use (2 typos fixed):

For instance, consider the default compiler range gcc >=4.8, which might test your library with too many versions of GCC. You could remove intermediary versions of GCC with the range gcc >=4.8 <5 || >=10, which ensure old versions ~are~and recent versions are covered, while eliminating intermediary versions.

Semver ranges can also help when a bug is found in a specific compiler version. Consider someone has reported a bug in GCC 8.1, and you want to keep track of that. The semver range gcc >=4.8 <5 || 8.1 || >=10 would ensure version GCC 8.1 specifically, and not any other version ~is~in the range >=5.0.0 <10.0.0 is tested.

I.e. building upon the previous example for showing that feature instead of using something new

Flamefire avatar May 28 '24 20:05 Flamefire

certainly is true but isn't "GCC8.1 specifically, and not any other version in the range >=7 <10" more specific?

Mmm... I see. Yes. I mean, ">=8.0.0 <9.0.0" is more specific than ">=7 <10" in terms of ranges, but I get what you mean.

The rationale for talking about ">=8.0.0 <9.0.0" rather than ">=7 <10" is because it typically chooses one major in each >=X <X+1 range. So this "trick" is exemplifying how to choose precisely 8.1 in this ">=8.0.0 <9.0.0" range.

Why would one expect that any 8.x version except the one specified is tested when the other conditions restrict to up to 6.x and from 10.x?

Isn't that the opposite? When we define it as 8.1, no 8.x version except the one specified is tested.

Semver describes what to include, not what to restrict. gcc >=4.8 <7 || 8.1 || >=10 includes versions from 4.8 to up to 6.x and from 10.x. They don't restrict to up to 6.x and from 10.x.

alandefreitas avatar May 29 '24 03:05 alandefreitas

The rationale for talking about ">=8.0.0 <9.0.0" rather than ">=7 <10" is because it typically chooses one major in each >=X <X+1 range. So this "trick" is exemplifying how to choose precisely 8.1 in this ">=8.0.0 <9.0.0" range.

The part below might make clear why I find the confusing in this context.

Why would one expect that any 8.x version except the one specified is tested when the other conditions restrict to up to 6.x and from 10.x?

Isn't that the opposite? When we define it as 8.1, no 8.x version except the one specified is tested.

Exactly: Without the "8.1" (which is the important/new thing in this paragraph) we have gcc >=4.8 <7 || >=10. So according the the above we expect "4.8, 6.x, 10.x, 11.x" (and maybe above). So where do "8.0.0" and "9.0.0" come from? Nothing hints at these, does it? Hence it surprised me and made me thing I missed something.

But I guess I now know what you meant: gcc >=4.8 <7 || 8.1 || >=10 as opposed to gcc >=4.8 doesn't choose any other 8.x in the range [8-9). Maybe gcc >=4.8 <8 || 8.1 || >=9 makes that more clear if you want to show how to include only a specific version of a major version.

Or my idea of extending the previous example of >=4.8 <5 || >=10 to include a specific version where a bug was reported and referring to the versions used.

Semver describes what to include, not what to restrict. gcc >=4.8 <7 || 8.1 || >=10 includes versions from 4.8 to up to 6.x and from 10.x. They don't restrict to up to 6.x and from 10.x.

TLDR: We do mean the same thing in the end.

I'm basically coming from "gcc"="test GCC", "gcc [condition]" = "test GCC with that condition", where the latter is more "restrictive" then the former. So gcc >=4.8 <7 could be read as either: "include versions from 4.8 to up to 6.x" or restrict the tested versions to the range from 4.8 to up to 6.x", i.e. don't test any other versions. That's what Python does with it's dependencies: Without a version range any version is accepted.

Flamefire avatar May 29 '24 10:05 Flamefire

Maybe gcc >=4.8 <8 || 8.1 || >=9 makes that more clear if you want to show how to include only a specific version of a major version.

Yes. I agree. gcc >=4.8 <8 || 8.1 || >=9 isolates what the text is about.

Or my idea of extending the previous example of >=4.8 <5 || >=10 to include a specific version where a bug was reported and referring to the versions used.

Yes. We can also include that example.

I also agree with everything else you said.

alandefreitas avatar May 29 '24 13:05 alandefreitas