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

GH472: Added OctoPack tool #1218

Merged
merged 1 commit into from
Oct 16, 2016
Merged

Conversation

cpx86
Copy link
Contributor

@cpx86 cpx86 commented Sep 10, 2016

See #472. Pretty much implemented in the exact same way as OctoPush.

@dnfclas
Copy link

dnfclas commented Sep 10, 2016

Hi @cpx, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by .NET Foundation and real humans are currently evaluating your PR.

TTYL, DNFBOT;

@trailmax
Copy link
Contributor

trailmax commented Sep 19, 2016

I'm trying your pull request in a custom build of Cake and run into an issue. In OctopusPackSettings property BasePath should really be DirectoryPath, not a FilePath. Unless I'm missing something.

Edit: same goes for OutFolder property.

@gep13
Copy link
Member

gep13 commented Sep 19, 2016

@trailmax said...
I'm trying your pull request in a custom build of Cake and run into an issue. In OctopusPackSettings property BasePath should really be DirectoryPath, not a FilePath. Unless I'm missing something.

@cpx is the same not also true for OutputFolder?

@cpx86
Copy link
Contributor Author

cpx86 commented Sep 20, 2016

That does sound correct, I'll update the PR :)

@cpx86
Copy link
Contributor Author

cpx86 commented Sep 20, 2016

@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:

Task("Pack")
        .Does(() => {
                OctoPack("MyPackage", new OctopusPackSettings {
                        Version = "1.0.0",
                        BasePath = "./bin",
                        OutFolder = "./out",
                        Overwrite = true
                });
        });

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.

@cpx86 cpx86 force-pushed the feature/GH-472 branch 2 times, most recently from 2002cb9 to d41005f Compare September 20, 2016 13:20
@trailmax
Copy link
Contributor

@cpx Octo.exe - the latest. Yes, what you have it there worked - when you specify the path as a String it is fine. But I had a Parameters class with all the directories listed and my directories were recorded as DirectoryPath objects. And conversion from FilePath to DirectoryPath failed on compile time.

@cpx86
Copy link
Contributor Author

cpx86 commented Sep 21, 2016

@trailmax: Got it, that explains it.

Copy link
Member

@patriksvensson patriksvensson left a 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,
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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
Copy link
Member

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
Copy link
Member

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);
Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Member

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. 😄

Copy link
Contributor Author

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.

Copy link
Member

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.

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'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";
Copy link
Member

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?

Copy link
Contributor Author

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)?

Copy link
Member

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.

Copy link
Contributor Author

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)
Copy link
Member

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
Copy link
Member

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();
Copy link
Member

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);
}

Copy link
Contributor Author

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

Copy link
Member

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
Copy link
Member

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>
Copy link
Member

Choose a reason for hiding this comment

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

Class should be sealed.

@cpx86
Copy link
Contributor Author

cpx86 commented Sep 28, 2016

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.

@trailmax
Copy link
Contributor

Regarding enum naming I prefer to keep it NuPkg because that's what the underlying tool is using. This way there is no divergence between Cake API and octo.exe API.

@cpx86
Copy link
Contributor Author

cpx86 commented Sep 29, 2016

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.

@gep13 gep13 changed the title Added OctoPack tool GH472: Added OctoPack tool Oct 12, 2016
@patriksvensson
Copy link
Member

@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!

@cpx86
Copy link
Contributor Author

cpx86 commented Oct 16, 2016

@patriksvensson NP, it happens :) will rebase as soon as I'm at my machine.

@cpx86
Copy link
Contributor Author

cpx86 commented Oct 16, 2016

@patriksvensson Done!

@patriksvensson patriksvensson merged commit 089d546 into cake-build:develop Oct 16, 2016
@patriksvensson
Copy link
Member

Merged! Thanks for this! 👍

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.

5 participants