-
-
Notifications
You must be signed in to change notification settings - Fork 731
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
GH472: Added OctoPack tool #1218
Conversation
Hi @cpx, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution! The agreement was validated by .NET Foundation and real humans are currently evaluating your PR. TTYL, DNFBOT; |
I'm trying your pull request in a custom build of Cake and run into an issue. In Edit: same goes for |
That does sound correct, I'll update the PR :) |
@trailmax How did your cakefile look, and what version of Octo.exe do you have? For me it worked with Octo 3.4.2 and the following cake script:
I'll change it anyway to DirectoryInfo since that is more correct - would just like to understand why there's a difference between our tests. |
2002cb9
to
d41005f
Compare
@cpx Octo.exe - the latest. Yes, what you have it there worked - when you specify the path as a |
@trailmax: Got it, that explains it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, I'm sorry for the delay in reviewing this PR.
I left some comments for you. Nothing major 😄
/// <summary> | ||
/// NuGet package | ||
/// </summary> | ||
NuPkg, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking if we should rename this to NuGet
. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NuPkg is the constant used by Octo.exe. From the help:
--format=VALUE Package format. Options are: NuPkg, Zip.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sounds good to me.
namespace Cake.Common.Tools.OctopusDeploy | ||
{ | ||
/// <summary> | ||
/// Represents the format of an Octopus package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing period after package
.
namespace Cake.Common.Tools.OctopusDeploy | ||
{ | ||
/// <summary> | ||
/// Contains the settings used by OctoPack |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing period after OctoPack
.
throw new ArgumentNullException(nameof(id)); | ||
} | ||
|
||
var builder = new OctopusPackArgumentBuilder(id, _environment, settings); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that familiar with the Octopus tool wrappers, but is there any specific reason that you put the argument building into it's own class? I'm not against it but it does break the convention we've used so far (to my knowledge at least) of putting the argument building together with the tool. Like I said, not against it since I like the separation, just a thought.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done the same with my PR - I just followed the pattern in already existing functionality for Octopus. Also a lot of Octopus's parameters for different commands are the same - it helps to extract these out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, wasn't aware of the existing functionality. I guess this can be left as it is then. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case though the argument builder isn't reusable for any other commands. Pack is a local command whereas all other commands work with a remote Octopus server. So it might make more sense to merge the OctopusPackArgumentBuilder into the tool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I leave this decision to you. If the other Octo tools does it like this, we can follow the convention and refactor this later if it makes sense, but if you want to change it, it's also fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to merge it into the tool then, since these arguments currently are not reusable for any other Octo command.
/// <returns>The name of the tool.</returns> | ||
protected override string GetToolName() | ||
{ | ||
return "Octo"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this should be OctopusDeploy Pack
or something similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the convention? Should the tool name match the associated Cake type/member names, or should it match the underlying tool (which is octo.exe in this case)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a human readable string just describing the tool in the log. For nuget.exe pack
tool we have NuGet Pack
if I remember correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, NuGet has the same tool name (NuGet) for all tools as well, coming from the NuGetTool base class.
/// <param name="id">The package ID.</param> | ||
/// <param name="settings">The settings</param> | ||
[CakeMethodAlias] | ||
public static void OctoPack(this ICakeContext context, string id, OctopusPackSettings settings = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we create an overload for this method (without the settings) instead of using default values. We've seen some funny things happening with older versions of Roslyn when doing this.
} | ||
|
||
/// <summary> | ||
/// Packs the specified folder into an Octopus Deploy package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing period after package
.
[Fact] | ||
public void Should_Throw_If_Id_Is_Null() | ||
{ | ||
var fixture = new OctopusDeployPackerFixture(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We normally divides the Arrange,Act,Assert in Given
/When
/Then
comments.
Would this be possible to change?
public void Test()
{
// Given
var fixture = new MagicFixture();
// When
var result = fixture.DoMagic();
// Then
Assert.Equal(42, result);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I prefer to skip the comments and just be strict in dividing the test using linebreaks :) But I'll change it so it matches the rest of the test suite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect :)
|
||
namespace Cake.Common.Tools.OctopusDeploy | ||
{ | ||
internal class OctopusPackArgumentBuilder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Class should be sealed.
/// <summary> | ||
/// The Octopus deploy package packer | ||
/// </summary> | ||
public class OctopusDeployPacker : Tool<OctopusPackSettings> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Class should be sealed.
d41005f
to
379a2d0
Compare
I've pushed the requested changes now :) Naming of the format enum values and whether to have a separate argument builder is still open for discussion though. |
Regarding enum naming I prefer to keep it |
379a2d0
to
81683e8
Compare
Merged the builder into the tool. I think the name should be kept as Octo since that seems to be the convention used by e.g. NuGet. |
@cpx Sorry for abandoning this PR. Life simply got in the way. I think this looks good for merging. Could you rebase this PR against develop? Thanks! |
@patriksvensson NP, it happens :) will rebase as soon as I'm at my machine. |
@patriksvensson Done! |
Merged! Thanks for this! 👍 |
See #472. Pretty much implemented in the exact same way as OctoPush.