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

dotnet-script use local tool #1231

Merged
merged 37 commits into from May 2, 2024
Merged

Conversation

IsaacCalligeros95
Copy link
Contributor

@IsaacCalligeros95 IsaacCalligeros95 commented Feb 23, 2024

This change adds support for using a locally installed version of dotnet-script. Execution uses in order:

  • Check if dotnet-script is on path with where/which
  • Fall back to the bundled version

Deprecation warning
image

Note logs include additional logging for debugging purposes these lines are not included in the final PR.
dotnet-script tool installed on WSL Bash script
image

WSL container without dotnet-script on path
image

WSL executing dotnet-script file
image

dotnet-script tool installed on Windows .cmd on path
image

dotnet-script tool installed on Windows .exe on path
image

No dotnet-script tool installed on Windows (bundled)
image

@@ -21,7 +22,8 @@ public void DotnetScript_CSharpDecryptsVariables()
var variables = GetVariables();
variables.Add(ScriptVariables.UseDotnetScript, bool.TrueString);
File.WriteAllText(scriptFile.FilePath, "System.Console.WriteLine(OctopusParameters[\"mysecrect\"]);");
var result = ExecuteScript(new DotnetScriptExecutor(), scriptFile.FilePath, variables);
var commandLineRunner = new TestCommandLineRunner(new InMemoryLog(), new CalamariVariables());
var result = ExecuteScript(new DotnetScriptExecutor(commandLineRunner), scriptFile.FilePath, variables);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried testing this, including a bundled dotnet-script package, extracting that to a path, and adding that path to the environment variables. In the test context this was not retrieving the executable path on the where/which commands. I sunk a lot of time into this and couldn't work out why this wasn't working.

Copy link
Contributor

@hnrkndrssn hnrkndrssn left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@IsaacCalligeros95 IsaacCalligeros95 changed the title Isaac/dotnet script local tool dotnet-script use local tool Apr 30, 2024
@@ -67,7 +67,8 @@ public async Task InstallTerraform()

await DownloadTerraform(fileName, client, tuple.data, destinationDirectoryName);

var terraformExecutable = Directory.EnumerateFiles(destinationDirectoryName).FirstOrDefault();
var terraformExecutable = Directory.EnumerateFiles(destinationDirectoryName)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixes test issues

@IsaacCalligeros95 IsaacCalligeros95 marked this pull request as ready for review April 30, 2024 06:06
Copy link
Contributor

@hnrkndrssn hnrkndrssn left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Initialize-AzureRmContext
}
else {
if($OctopusAzureRMIsDepreciated -like [Boolean]::TrueString) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rain-on I've inverted the check here for the sake of the tests. I can't see this changing any other behaviour but just wanted to raise this incase.

@IsaacCalligeros95 IsaacCalligeros95 merged commit 2339e24 into master May 2, 2024
21 checks passed
@IsaacCalligeros95 IsaacCalligeros95 deleted the isaac/dotnet-script-local-tool branch May 2, 2024 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants