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

Create Chocolatey packages for console #236

Merged
merged 6 commits into from
Jun 15, 2017
Merged

Create Chocolatey packages for console #236

merged 6 commits into from
Jun 15, 2017

Conversation

CharliePoole
Copy link
Member

@CharliePoole CharliePoole commented Jun 7, 2017

Fixes #207

This PR incorporates work from PR #234 by @Roemer and adds the following:

  • There are now two packages, one for console only and one with extensions
  • File names and package ids are changed
  • Creation of shims for the agent exes is suppressed - we don't want users to be executing them directly.

I marked this as "Do Not Merge" because I'd really prefer to see the extensions referenced as packages, the way we do for NuGet, rather than actually copied into the package with extensions. I can see the way to do that with Chocolatey, but it will take some more experimentation. Alternatively, we could release what we have and improve it later.

Improving would mean first trying to use the existing nuget packages for the extensions. I know chocolatey will install them, but I don't know how whether it will do so in a way that is useful for us. The fallback would be to modify the nuget packages, creating chocolatey packages. In either case, there would be a file installed with the engine, similar to nunit.nuget.addins, i.e. nunit.choco.addins, which would allow the engine to find the extensions.

So the question is whether to wait for the better solution or just go with what we have now. @rprouse what do you prefer?

@CharliePoole CharliePoole requested review from Roemer and rprouse June 7, 2017 16:16
@CharliePoole
Copy link
Member Author

Just to be clear... in my preferred solution, the user could type...

choco install nunit-console-runner nunit-teamcity-extension

and get the runner with that single extension installed.

@CharliePoole
Copy link
Member Author

Hey @ferventcoder we'd love to have your comments on this as well.

build.cake Outdated
// Copy the nuspec files
CopyFileToDirectory("choco/nunit-console-runner.nuspec", currentImageDir);
CopyFileToDirectory("choco/nunit-console-with-extensions.nuspec", currentImageDir);
CopyFileToDirectory("choco/nunit-agent.exe.ignore", currentImageDir + "bin/");
Copy link

Choose a reason for hiding this comment

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

Wouldn't it be better to just create those empty files here in cake instead of creating them in the solution and copying them here? Or at least just copy all files from the choco directory.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's clearer if they are in the same place as the agent exe and config files. If we do it all from the cake script, then I would favor what you are suggesting.

Copy link
Member

Choose a reason for hiding this comment

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

Personally, I'd agree it would be nice to create them in cake - purely because I'm not too familiar with choco, and just went to look them up, and find out what was in the .ignore files. 😆 That would be more explicit if they were created right here - I assumed files being copied had content.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll look at that change and see if I can fit it in relatively smoothly.

<tags>nunit console runner test testing tdd</tags>
<copyright>Copyright (c) 2017 Charlie Poole</copyright>
</metadata>
<files>
Copy link

Choose a reason for hiding this comment

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

The more I look at it the more i think it will be more maintainable if we have the entire content of the package build by the cake script. Now we have a mix of solution items, lines in nuspec, things copied and generated by cake...

Copy link
Member Author

Choose a reason for hiding this comment

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

That's the approach I favor too. 😄 Will do!

Copy link
Member Author

Choose a reason for hiding this comment

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

Part of the difficulty here is the use of the "Image" directory to build everything. This is a hold-over from when the framework and console were in the same repo and we built a complicated structure with various frameworks for different runtime versions. It serves little use here and was never removed purely out of laziness on my part. I may take a look at that, although it's probably better as a separate PR.

@CharliePoole
Copy link
Member Author

@rprouse I know it's easy to miss which issues require attention, so... THIS DOES. Your comment to question above is the only thing that is blocking it right now. 😸

Based on your input, I will either merge what we have or work toward the solution I prefer - described above. I also asked you a while back to tell me how you wanted this to relate to the release you are working on - i.e. does it need to be part of it or can it be done a bit later. The two questions are obviously related.

Copy link
Member

@rprouse rprouse left a comment

Choose a reason for hiding this comment

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

From what I know of Chocolatey, this looks good except for the version in the one file, unless you edit that in Cake and I missed it.

As for going with what you have, I think we should keep it simple for now and iterate if we have to.

<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>nunit-console-with-extensions</id>
<version>0.0.0</version>
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't the version need to be a variable here?

Copy link
Member

Choose a reason for hiding this comment

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

I see it gets injected in the Cake file, just thought it should be $version$ like NuGet does it. I could very easily be wrong though 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

This is how chocolatey generates templates, so it's at least their preferred approach. Don't know if they accept $version$ as well.

Choose a reason for hiding this comment

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

Not yet, but we do accept choco pack --version=1.2.3. See chocolatey/choco#1313

Choose a reason for hiding this comment

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

This is how chocolatey generates templates, so it's at least their preferred approach.

I'm not sure what version of Chocolatey you are on, but this hasn't been the way that Chocolatey generates templates for over a year. Current version is 0.10.7. and it separates package specifics from software specifics now in generation.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm on the latest... however I copied this from another project. 😊 Anyway, I'm running tests using this package, so we're good for now.

@CharliePoole
Copy link
Member Author

I'm taking "keep it simple" to mean "don't make changes" - what we have suffers precisely from not being simple. However, it's no worse than what we do in the distribution project. I'll take care of the review comments and merge.

In the longer (even medium) term, I'm convinced that this is not the right way to use chocolatey with self-contained packages. My experience, their docs and my discussions with @ferventcoder have convinced me that use of package references is a better path. Hopefully, whoever does that next iteration will bear it in mind.

Still waiting to here how you want this to fit in with the release. It makes a difference in how this is eventually merged.

@rprouse
Copy link
Member

rprouse commented Jun 10, 2017

I think we can merge this and we can try to work it into the release process, or at least right after the release. I will likely need your help uploading. We do NUnit distribution just after the initial release and amend the GitHub release, we could do the same with this. Let's see how it goes, document the process and then decide if it needs improvements.

@CharliePoole
Copy link
Member Author

Rebased on master

Copy link
Member

@ChrisMaddock ChrisMaddock left a comment

Choose a reason for hiding this comment

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

Looks good to me. I agree we should have separate packages with dependencies at some point, as NuGet, but don't see the harm in merging this for now, and releasing the latter later.

build.cake Outdated
"1.0.2",
"teamcity-event-listener.dll",
null
)
Copy link
Member

Choose a reason for hiding this comment

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

Hardcoded versions for the addins are an extra maintenance cost - the msi just pulls the latest version of the add-in. This could also mean the msi and choco end up containing different extensions for the same version number release - which I realise is possible, but should be avoided, in my opinion.

If no version is set on nugetInstallSettings, does it just fetch latest? Could we do that?

Copy link
Member Author

Choose a reason for hiding this comment

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

@ChrisMaddock This came out of my directions to @Roemer. To the extent that we might build and distribute extensions written by other people, I thought we needed to be able to specify the version we have tested. RIght now, the only such extension is teamcity, which we don't test in any version. Now that I write that, it sounds bad, doesn't it. 😟

build.cake Outdated
var primaryDllPath = System.IO.Path.Combine(addinToolsPath, addin.Item3);
CopyFileToDirectory(primaryDllPath, addinsDir);
// Copy additional files
if (addin.Item4 != null) {
Copy link
Member

Choose a reason for hiding this comment

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

This could be addin?.Item4 to remove the extra nesting? Only minor though. :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

That would guard against addin being null, not Item4. Currently, the code assumes that addin is not null, which is valid since we create the list here.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry - you're right.

build.cake Outdated
// Copy the nuspec files
CopyFileToDirectory("choco/nunit-console-runner.nuspec", currentImageDir);
CopyFileToDirectory("choco/nunit-console-with-extensions.nuspec", currentImageDir);
CopyFileToDirectory("choco/nunit-agent.exe.ignore", currentImageDir + "bin/");
Copy link
Member

Choose a reason for hiding this comment

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

Personally, I'd agree it would be nice to create them in cake - purely because I'm not too familiar with choco, and just went to look them up, and find out what was in the .ignore files. 😆 That would be more explicit if they were created right here - I assumed files being copied had content.

build.cake Outdated
// Write the primary dll to the addins file
FileAppendLines(System.IO.Path.Combine(currentImageDir, "nunit.engine.addins"), new[] {
System.IO.Path.Combine("addins", addin.Item3)
});
Copy link
Member

Choose a reason for hiding this comment

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

This is much better than the nunit-distribution handling. 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

@Roemer 's concept!

FYI - and not particularly to do with these lines of code - Because I can no longer build nunit-console without commenting out the line that detects .NET Core, I'm actually using CI as my primary test bed and making changes more incrementally than I would normally do. Each new commit gets in a bit more to fix the comments that have been made.

build.cake Outdated
@@ -402,6 +404,143 @@ Task("PackageConsole")
});
});

Task("PackageChocolatey")
.Description("Creates chocolate packages of the console runner")
Copy link
Member

Choose a reason for hiding this comment

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

chocolate -> Chocolatey. Although chocolate packages would be nice! 😄

build.cake Outdated
EnsureDirectoryExists(PACKAGE_DIR);

// Note: Since cake does not yet support a working directory and separate output directory for chocolatey, the following copying and hacks are needed.

Copy link
Member

Choose a reason for hiding this comment

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

Should this comment be attached to lines 480ish? I'm not sure what it's referring to.

Copy link
Member Author

Choose a reason for hiding this comment

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

@Roemer This came from your branch and I just kept it. I actually don't understand it either.

@CharliePoole
Copy link
Member Author

@Roemer @rprouse I think this is as good as it gets without doing some major reoranization on the build script. I'd actually like to do that, but not in this PR.

I'd also like to see a version with extensions that simply referenced them, but I think we should get this one out first.

There are some comments in the code that point out places where I left in duplication that should eventually be removed. That's because I think the script reorganization is needed first.

Please re-review for merging.

@CharliePoole CharliePoole merged commit a2c43d7 into master Jun 15, 2017
@ferventcoder
Copy link

Late to the conversation but I will reiterate what I mentioned to @CharliePoole in an email here.

When you implement plugins/exensions, you could do it in one of two ways. Either within Chocolatey's lib directory, or gather it together under $env:ChocolateyToolsLocation\nunit - this allows users to determine where that tools location is (defaults to c:\tools). Using the Tools Location does have some drawbacks and considerations, as you are responsible for setting the path and removing that, etc - much of that is currently documented at https://github.com/chocolatey/choco/issues/1303#issuecomment-303804561

I do prefer each plugin as a separate package, but as mentioned here that could be a major restructuring.

@@ -554,7 +669,8 @@ Task("Package")
.IsDependentOn("CheckForError")
.IsDependentOn("PackageEngine")
.IsDependentOn("PackageConsole")
.IsDependentOn("PackageNetStandardEngine");
.IsDependentOn("PackageNetStandardEngine")
.IsDependentOn("PackageChocolatey");

Choose a reason for hiding this comment

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

Small formatting issue.

@CharliePoole CharliePoole deleted the issue-207 branch June 15, 2017 13:59
@CharliePoole
Copy link
Member Author

Thanks @ferventcoder for chiming in. I'm going to continue on this and we'll do it in the preferred way when possible. Meanwhile, there may be a first release using what we have so far. Key question is can we rely on relative paths from our engine to any extensions remaining stable over time as Chocolatey develops. We use such paths extensively.

@ferventcoder
Copy link

Key question is can we rely on relative paths from our engine to any extensions remaining stable over time as Chocolatey develops. We use such paths extensively.

You can't go wrong with $env:ChocolateyInstall\lib\<id> - we have no plans to change it currently. If we ever did it would be a VERY long transition and deprecation before the change was made (with plenty of warnings). So very unlikely.

@CharliePoole
Copy link
Member Author

We can adapt. 😄 Here's how we handle both nuget 2 and 3 for example in our addins file:

../../NUnit.Extension.*/**/tools/     # nuget v2 layout
../../../NUnit.Extension.*/**/tools/  # nuget v3 layout

This works well because we actually don't want a copy of the NUnit engine installed with NuGet to be aware of any extensions except those also installed in the project with NuGet.

Similarly, I think an app installed via Chocolatey should only use extensions installed the same way. Eventually, I'd hope to see all of the following separate...

  • Console runner
  • Gui Runner
  • Engine
  • Each extension to the engine

That would give the two (or more) runners access to the same engine with that engine automatically using all the extensions. It's not something that's so easy to do otherwise.

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