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

The latest Cake version is not always honoured #55

Open
ecampidoglio opened this issue Apr 26, 2024 · 2 comments · May be fixed by #56
Open

The latest Cake version is not always honoured #55

ecampidoglio opened this issue Apr 26, 2024 · 2 comments · May be fixed by #56
Assignees
Labels
bug Something isn't working
Milestone

Comments

@ecampidoglio
Copy link
Member

Background

Running the action without specifying the --cake-version input parameter implies installing the latest version of the Cake.Tool package. This is achieved by running dotnet tool install without the --version parameter.

The Problem

While this approach works fine in most cases, there's one scenario where it falls short: when the action runs on an agent where a different version of the Cake.Tool package is already installed.

Here's an example workflow:

  1. The Cake action runs with the --cake-version set to x.y.z
  2. Version x.y.z of the Cake.Tool is installed in the tools directory
  3. The Cake action runs again, only this time without the --cake-version input parameter implying that the latest version of Cake should be used
  4. The action sees that the Cake.Tool is already present in the tools directory; however, without a specific version number to compare with, it determines that it shouldn't install any new version of the Cake.Tool and runs with it
  5. The user thinks that the action is running with the latest version of Cake, while in reality it's running with whatever version was alreaady installed in the tools directory

Proposed Solution

When running the action without the --cake-version input parameter, the action should go out and fetch the latest version of the Cake.Tool from the Cake releases on GitHub and use that as the version number.

This way, there will always be a version number to compare with when determining whether any existing installation of the Cake.Tool can be used.

Risks

In the case when fetching the latest version from GitHub fails for some reason (e.g. due to a network error), the action should simply fall back to the previous behavior of installing the Cake.Tool without a version number.

@ecampidoglio ecampidoglio changed the title Latest Cake version not always honored The latest Cake version is not always honoured Apr 26, 2024
@ecampidoglio ecampidoglio added this to the 3.0.0 milestone Apr 26, 2024
@ecampidoglio ecampidoglio added the bug Something isn't working label Apr 26, 2024
@ecampidoglio ecampidoglio self-assigned this Apr 26, 2024
ecampidoglio added a commit that referenced this issue Apr 26, 2024
Earlier, not providing an argument for the `cake-version` input
parameter resulted in the Cake.Tool being installed without the
`--version` parameter. This is fine in most cases, since in practice it
translates into installing the latest version.

The case when it stops being fine is when an earlier version of the
Cake.Tool is already installed in the tools directory and you're running
the action without a version number.

In that case, you would expect the action to uninstall the existing
version of the Cake.Tool and install the latest one, but what used to
happen instead is that the action wouldn't even check what version
was installed, since it had no version number to compare with, and it
would just use whatever version of the tool was already installed.

This commit addresses this corner case by explicitly fetching the latest
version of the Cake.Tool from GitHub when no version number is specified
by the user. This way, the action is able to compare that version number
with whatever may already be installed and act appropriately.
@ecampidoglio ecampidoglio linked a pull request Apr 26, 2024 that will close this issue
ecampidoglio added a commit that referenced this issue Apr 26, 2024
Earlier, not providing an argument for the `cake-version` input
parameter resulted in the Cake.Tool being installed without the
`--version` parameter. This is fine in most cases, since in practice it
translates into installing the latest version.

The case when it stops being fine is when an earlier version of the
Cake.Tool is already installed in the tools directory and you're running
the action without a version number.

In that case, you would expect the action to uninstall the existing
version of the Cake.Tool and install the latest one, but what used to
happen instead is that the action wouldn't even check what version
was installed, since it had no version number to compare with, and it
would just use whatever version of the tool was already installed.

This commit addresses this corner case by explicitly fetching the latest
version of the Cake.Tool from GitHub when no version number is specified
by the user. This way, the action is able to compare that version number
with whatever may already be installed and act appropriately.
ecampidoglio added a commit that referenced this issue Apr 26, 2024
Earlier, not providing an argument for the `cake-version` input
parameter resulted in the Cake.Tool being installed without the
`--version` parameter. This is fine in most cases, since in practice it
translates into installing the latest version.

The case when it stops being fine is when an earlier version of the
Cake.Tool is already installed in the tools directory and you're running
the action without a version number.

In that case, you would expect the action to uninstall the existing
version of the Cake.Tool and install the latest one, but what used to
happen instead is that the action wouldn't even check what version
was installed, since it had no version number to compare with, and it
would just use whatever version of the tool was already installed.

This commit addresses this corner case by explicitly fetching the latest
version of the Cake.Tool from GitHub when no version number is specified
by the user. This way, the action is able to compare that version number
with whatever may already be installed and act appropriately.
@baynezy
Copy link
Contributor

baynezy commented Aug 20, 2024

@ecampidoglio

In the case when fetching the latest version from GitHub fails for some reason (e.g. due to a network error), the action should simply fall back to the previous behavior of installing the Cake.Tool without a version number.

I am not sure I agree with it silently falling back to the installed verrsion. If you consider the current behaviour a bug, then I don't think you can make the fallback behaviour of this change the same behaviour.

ecampidoglio added a commit that referenced this issue Aug 23, 2024
Earlier, not providing an argument for the `cake-version` input
parameter resulted in the Cake.Tool being installed without the
`--version` parameter. This is fine in most cases, since in practice it
translates into installing the latest version.

The case when it stops being fine is when an earlier version of the
Cake.Tool is already installed in the tools directory and you're running
the action without a version number.

In that case, you would expect the action to uninstall the existing
version of the Cake.Tool and install the latest one, but what used to
happen instead is that the action wouldn't even check what version
was installed, since it had no version number to compare with, and it
would just use whatever version of the tool was already installed.

This commit addresses this corner case by explicitly fetching the latest
version of the Cake.Tool from GitHub when no version number is specified
by the user. This way, the action is able to compare that version number
with whatever may already be installed and act appropriately.
ecampidoglio added a commit that referenced this issue Aug 23, 2024
Earlier, not providing an argument for the `cake-version` input
parameter resulted in the Cake.Tool being installed without the
`--version` parameter. This is fine in most cases, since in practice it
translates into installing the latest version.

The case when it stops being fine is when an earlier version of the
Cake.Tool is already installed in the tools directory and you're running
the action without a version number.

In that case, you would expect the action to uninstall the existing
version of the Cake.Tool and install the latest one, but what used to
happen instead is that the action wouldn't even check what version
was installed, since it had no version number to compare with, and it
would just use whatever version of the tool was already installed.

This commit addresses this corner case by explicitly fetching the latest
version of the Cake.Tool from GitHub when no version number is specified
by the user. This way, the action is able to compare that version number
with whatever may already be installed and act appropriately.
@ecampidoglio
Copy link
Member Author

@baynezy I agree with you in principle. However, there are a few things to consider here:

  1. The original behavior is only problematic in a specific fairly uncommon scenario
  2. The vast majority of GitHub Actions workflows run on GitHub's own servers, so not being able to retrieve the latest Cake release would be a pretty rare occurrence

Given these two premises, I think that, from a practical standpoint, falling back on the original behavior is a better alternative than completely failing the build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants