Skip to content
This repository has been archived by the owner on Jul 27, 2019. It is now read-only.

Initial use of GitVersion #226

Merged
merged 13 commits into from
Sep 8, 2017
Merged

Initial use of GitVersion #226

merged 13 commits into from
Sep 8, 2017

Conversation

CharliePoole
Copy link
Collaborator

@CharliePoole CharliePoole commented Sep 1, 2017

Fixes #206

This is initial implementation of the use of GitVersion to determine the correct version for each build. When complete, it will no longer be necessary to track and update the version of the GUI in the source code or scripts.

The initial commit calculates and displays the version info that would be used but doesn't actually use it. By creating a PR, I'll be able to see how the pre-release tag portion of the version is set for PRs, but the PR should not be merged by anyone but me, after it's working correctly.

Please review and comment on the versioning scheme anyway!

@CharliePoole CharliePoole force-pushed the issue-206 branch 3 times, most recently from b9d9052 to 5576afa Compare September 2, 2017 17:40
@CharliePoole CharliePoole force-pushed the issue-206 branch 4 times, most recently from 76aafa6 to c6dbe5c Compare September 3, 2017 02:59
Copy link
Contributor

@mikkelbu mikkelbu left a comment

Choose a reason for hiding this comment

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

I'm not sure that I get all the implications of using GitVersion (actually, I'm quite sure that I do not all of it). But so I sounds quite reasonable to me.

build.cake Outdated
@@ -2,6 +2,8 @@
#tool nuget:?package=GitVersion.CommandLine
#addin "Cake.Incubator"

using System.Text.RegularExpressions;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this necessary ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had a regular expression at one point but it's gone now.

build.cake Outdated
@@ -1,4 +1,8 @@
#tool nuget:?package=NUnit.ConsoleRunner&version=3.6.1
Copy link
Contributor

Choose a reason for hiding this comment

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

We are back to using both tabs and spaces for indention in this file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. I should try to tell VS how to handle this file.

@CharliePoole
Copy link
Collaborator Author

@NUnitSoftware/gui-team @ChrisMaddock @rprouse
I think this is in it's final form as far as coding. If you reviewed it earlier, it may be worth another look.

That said, it's still not doing anything but merely displaying what it would do. Next commits will actually begin to impact the packaging.

I'm saving modification of the AssemblyInfo for last. 😃

@immeraufdemhund
Copy link
Contributor

pardon if this is a dumb question but is this changing how we do our branching and do our pull requests??? or just how the CI's handle our PR's and branches?

@CharliePoole
Copy link
Collaborator Author

It's changing how we version. Normally, when you do a branch and PR, you don't set the version. Our script handles it. But the script depends on the version being coded in it somewhere - as well as in the AssemblyInfo files.

Once we implement this, I'd hope to end up where we no longer have the version in any of our source code and therefore don't need to update it. GitVersion can examine the repository history and decide what version we want, based on some conventions and the settings we establish.

Currently, we create automatic pre-release suffixes for our versions on AppVeyor only, using environment variables they provide. Once this is in place, we'll have a consistent automatic method that works on AppVeyor, Travis and locally.

Initially, final (non-preview) releases will continue to be done manually. But this will enable a later change to do them automatically as well. All that adds up to more frequent automated releases, which has to be a good thing!

@CharliePoole
Copy link
Collaborator Author

With the latest commits, we are now using the info from GitVersion to do packaging. The hard-coded version in the script is no longer used.

There is still quite a lot of debug info in the script, which I will remove when it's no longer needed. I'll reformat using spaces everywhere before merge as well.

Note that we can't do a chocolatey package on Linux without a bunch of work, so I'm simply not creating one.

Next step is to deal with the AssemblyInfo files.

@CharliePoole
Copy link
Collaborator Author

This is ready for review and merge once CI passes.

@mikkelbu
Copy link
Contributor

mikkelbu commented Sep 7, 2017

I'll take a look at it tonight (in approx. 3 hours)

Copy link
Contributor

@mikkelbu mikkelbu left a comment

Choose a reason for hiding this comment

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

I only have very minor nitpick and some comments.

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this file included on purpose? I can google that it defines a vscode task, but I cannot find the script Package that is mentioned.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's because I executed tasks in the script under VsCode. File should be in .gitignore.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The script is build.cake, Package is a target.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. The "script": "Package" was a bit misleading 😄

build.cake Outdated
#tool nuget:?package=GitVersion.CommandLine
#addin "Cake.Incubator"

using System.Text.RegularExpressions;
Copy link
Contributor

Choose a reason for hiding this comment

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

The regex is back for parsing whether it is a PR or not, so we should keep this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Exactly.

@@ -167,9 +144,7 @@ Task("PackageZip")
BIN_DIR + "CHANGES.txt",
BIN_DIR + "nunit-gui.exe",
BIN_DIR + "nunit-gui.exe.config",
BIN_DIR + "nunit-gui.pdb",
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the motivation for not providing pdbs ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They break the build under Mono 4.6.2, which doesn't produce them. We could put them back if we used logic to include them only when they actually are present.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. Let us just leave them out to begin with. Then we can always include them later.

.travis.yml Outdated
- ./build.sh -target="Travis" -configuration="Release" -verbosity="verbose"
- git fetch --unshallow
- ./build.sh --target "Travis"
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 pushed a commit b758c79 to correct the error from the merge (the error made Travis fail every time).

@mikkelbu
Copy link
Contributor

mikkelbu commented Sep 8, 2017

@CharliePoole .tavis.yml should contain something like
- ./build.sh -target="Travis" -configuration="Release" -verbosity="verbose"
See e.g. b758c79 that made Travis succeed (and sorry for stepping on your toes in this PR, but I did not think you were online)

@CharliePoole
Copy link
Collaborator Author

Can you explain further? Is the problem the dash, the missing config, the need for verbosity? Is this because of merging the new Cake bootstrap script? Seems like, if it messes us up, we might not want it.

@CharliePoole
Copy link
Collaborator Author

Going to bed... I'll look at this in the morning.

@mikkelbu
Copy link
Contributor

mikkelbu commented Sep 8, 2017

When you merged master to this branch no change was made to .tavis.yml (as far as I can tell), even though it was changed on master (I don't know much about GIT merges, but I guess that there must have been a conflict since you had made changes to the file on this branch). So we lost the changes done to .tavis.yml. So I made the commit b758c79 (on this branch) to solve the problem, but I think that you concurrently also tried to solve the problem (see ae9e7a3) and as a result overwrote my change when the to commits were merged in b813c78.

.tavis.yml on master
- ./build.sh -target="Travis" -configuration="Release" -verbosity="verbose"
.tavis.yml on this branch
- ./build.sh -t "Travis"
So -t should be replaced with -target=. The part about configuration and verbosity is just to keep the old behaviour as these are not the default anymore.

You can also see the diff between master and this branch here
https://github.com/NUnitSoftware/nunit-gui/pull/226/files#diff-354f30a63fb0907d4ad57269548329e3

And yes, it is because of the new bootstrap script, but I don't think that it is more problematic than other changes we do (and since we change .travis.yml quite rarely I don't think that it will effect us much).

@CharliePoole
Copy link
Collaborator Author

I understand that it would probably work if I put it back to how it was in master. It would also probably work if I backed out the upgraded build.sh script. I'm trying to figure out which is the best course of action.

I take it you are saying you merely used the args from master, and they work. But those args are wrong in several senses. We don't want verbose output. We shouldn't have to specify the configuration, since it is supposed to use our default in build.cake - although specifying it here is no big deal.

@jnm2 Is this related to the changes you made to Cake? If so can you give us info about exactly what changed in the command-line args or point to same?

@jnm2
Copy link
Contributor

jnm2 commented Sep 8, 2017

@CharliePoole I put all the details in cake-build/resources#33. I was just on Gitter earlier bugging them again to get cake-build/resources#34 validated and merged.

@CharliePoole
Copy link
Collaborator Author

@jnm2 The command that was failing for me most recently was

./build.sh -t "Travis"

before that this was failing:

./build.sh --target "Travis"

Is it the quotation marks?

@jnm2
Copy link
Contributor

jnm2 commented Sep 8, 2017

@CharliePoole nothing has changed WRT quotation marks, thankfully! The issue is that right now the only format build.sh understands is the format Cake.exe understands, which is --target="Foo" and --target=Foo. Note the =.

From the page I linked, this is what you can do right now:

build.sh
-t foo
-t=foo
-t:foo
-target foo
-target:foo
--target foo
--target=foo ✔️

This is what you used to be able to do:

build.sh
-t foo ✔️
-t=foo
-t:foo
-target foo
-target:foo
--target foo ✔️
--target=foo ✔️

Hopefully the PR is merged soon and you can go back to separating with a space. :-/

@CharliePoole
Copy link
Collaborator Author

It's the =! Now I get it. 😀

@mikkelbu
Copy link
Contributor

mikkelbu commented Sep 9, 2017

I take it you are saying you merely used the args from master, and they work. But those args are wrong in several senses. We don't want verbose output. We shouldn't have to specify the configuration, since it is supposed to use our default in build.cake - although specifying it here is no big deal.

The reason for why I chose set -configuration="Release" -verbosity="verbose" was to keep the old behaviour. The old version of build.sh contained defaults which set configuration=Release and verbosity=verbose, if no arguments were given to build.sh (and we only supplied target).
(see e.g. here https://github.com/NUnitSoftware/nunit-gui/blob/a78c5bf8d240214b55283e25edc5b11f139b4313/build.sh#L13-L19)

@jnm2
Copy link
Contributor

jnm2 commented Sep 9, 2017

This is the best place to keep defaults:
https://github.com/NUnitSoftware/nunit-gui/blob/e0699e256f7ce72b23c4cb2561122f2ce7199654/build.cake#L10-L11

Cake's template has Release which means someone changed it, even though the change never worked due to the design fault in the the bootstrappers. If you ever customize these, rather than editing in each bootstrapper, it would seem to make the most sense to put your argument defaults in the build script.
Not in the bootstrappers and not in CI server config files. I'd only put argument overrides in CI server configs where the overrides would be relevant and keep defaults in build.cake where they are most relevant.

@CharliePoole
Copy link
Collaborator Author

@mikkelbu Yes, I now understand that. It's a breaking change on the part of the Cake folks. I agree with how you compensated and put back in the configuration arg. Problem is, these updates come out without any release info on the part of Cake.

@jnm2 Wrong. 😄 We got Debug as a default when we ran Cake directly and Release when we ran build.ps1 or build.sh. I worked for quite a while using Cake directly locally and only using the bootstrap scripts in CI. I always thought it was weird that we defaulted to Release in one case and Debug in the other, but I got used to it and our CI scripts came to depend on it.

I agree it makes the most sense for the bootstrap scripts to be neutral in terms of defaults that are passed to Cake. It's just a change from the past and not one that's easy to notice in all cases.

@jnm2
Copy link
Contributor

jnm2 commented Sep 9, 2017

My bad. Thanks for filling me in on the history behind it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants