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

Exported XML should contain version of abandon #112

Merged
merged 8 commits into from
Nov 3, 2016
Merged

Exported XML should contain version of abandon #112

merged 8 commits into from
Nov 3, 2016

Conversation

z4f1r0v
Copy link
Contributor

@z4f1r0v z4f1r0v commented Oct 23, 2016

Closes #105
Update sbt to incorporate sbt-buildinfo plugin
Move generated BuildInfo.scala to co.uproot.abandon
Add version xml elements to Journal and Balance exports with the version from BuildInfo.scala

Move generated BuildInfo.scala to co.uproot.abandon
Add version xml elements to Journal and Balance exports with the version from BuildInfo.scala
@z4f1r0v
Copy link
Contributor Author

z4f1r0v commented Oct 23, 2016

HI @hrj! I did some work on #105. As you suggested I add the sbt-buildinfo to the general build.sbt of the project. Please take a look and let me know what you think.

Copy link
Owner

@hrj hrj left a comment

Choose a reason for hiding this comment

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

Nice work @alexanderzafirov, thanks!

Have a couple of comments.


import scala.Predef._

/** This object was generated by sbt-buildinfo. */
Copy link
Owner

Choose a reason for hiding this comment

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

@alexanderzafirov This generated file should not be checked in to the repository.

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'm a bit confused. How are we going to reference the file when it is not being tracked by Git?

Copy link
Owner

Choose a reason for hiding this comment

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

Isn't it generated automatically on compilation? I thought that is how the plugin worked but I maybe wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is. The problem is that I manually moved it from the main target folder to where it resides now.

Copy link
Owner

Choose a reason for hiding this comment

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

Umm.. the point of this issue is to automate the version numbering. Developers will only update the sbt file when the version number increases, and the application will automatically pick up the version number when emitting to the XML file, etc.

If there is any manual step, then it defeats the purpose.

I suggest you verify whether the manual step is necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood.

@@ -252,6 +252,9 @@ object Reports {

def xmlBalanceExport(state: AppState, exportSettings: XmlExportSettings): xml.Node = {
<abandon>
<version>
{ BuildInfo.version }
</version>
Copy link
Owner

Choose a reason for hiding this comment

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

Would be better to keep it on one line and no extra spaces, for example:

<version>{BuildInfo.version}</version>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. I just followed the "convention" from the lines below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we keep the spaces. For readability's sake?

Copy link
Owner

Choose a reason for hiding this comment

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

If it's a leaf node, then it is better to not have spaces. It will be easy for the application which is reading the XML file to parse the text content.

Actually, you could even make version an attribute of the abandon node. No need for a separate node.

If a node is a "structural node" with child nodes, then spacing and indentation makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, sorry, I didn't realize that the spaces in the curly braces are actual spaces in the generated xml.
I actually though of landing version as an attribute to abandon but for some reason decided to be more straightforward.

Copy link
Owner

Choose a reason for hiding this comment

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

I didn't realize that the spaces in the curly braces are actual spaces in the generated xml.

They are not; you can keep them. I thought you were referring to spaces between the XML tag and the scala code; those are significant; hence need to be removed.

Sorry for the confusion.

👍 for attribute.

@@ -260,6 +263,9 @@ object Reports {

def xmlJournalExport(state: AppState, exportSettings: XmlExportSettings): xml.Node = {
<abandon>
<version>
{ BuildInfo.version }
</version>
Copy link
Owner

Choose a reason for hiding this comment

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

Same here: would be better to keep it on one line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

fork in run := true
fork in run := true,
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
buildInfoPackage := "build.info"
Copy link
Owner

Choose a reason for hiding this comment

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

By looking at the rest of the code, shouldn't buildInfoPackage be co.uproot.abandon?

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 guess it makes sense. I just want to note that BuildInfo is generated in the target folder.

@hrj
Copy link
Owner

hrj commented Oct 24, 2016

@alexanderzafirov the tests are failing. This is probably because they are checking for an exact match of the generated xml. We need to either:

  • change the expected output files to include the version (problem is, they will need to be changed with every release)
  • change the test code so that it ignores the version node
  • add a config option to not emit the version number in the emitted XML (just for testing).

I think last option (config property) is best.

@z4f1r0v
Copy link
Contributor Author

z4f1r0v commented Oct 24, 2016

Thanks for the comments, @hrj!
I agree that it is best to make this configurable. Just to be clear - you mean as a parameter to the methods?

@hrj
Copy link
Owner

hrj commented Oct 24, 2016

I agree that it is best to make this configurable. Just to be clear - you mean as a parameter to the methods?

The CLI tests (which are failing) run the whole application. They don't call the internal methods directly.

So the parameter has to be either a command line option (passed via args to the main function) or as a property in the configuration file for that test. Either approach is fine with me, with a slight preference towards "command line option" because it will be easier.

@z4f1r0v
Copy link
Contributor Author

z4f1r0v commented Oct 24, 2016

Got it. I will implement the necessary fixes and ping you for review later!

Add new command line parameter
Add parameter to differentiate between versioned xml and nonversioned one
Start to fix tests
Make client xml code compile
</balance>
</abandon>
def xmlBalanceExport(state: AppState, exportSettings: XmlExportSettings, withVersion: Boolean): xml.Node = {
if (withVersion) {
Copy link
Owner

Choose a reason for hiding this comment

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

To avoid duplicating the code, you can add the version attribute after creating the abandon node normally.

Example code to add an attribute to an Element:

def addAttrib(n: Elem, k: String, v: String) = n % new xml.UnprefixedAttribute(k, v, xml.Null)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @hrj. I was away for a couple of days and didn't want to have the changes laying around so I pushed them to the branch. I was definitely looking for a better implementation and your suggestion is great.

Copy link
Owner

Choose a reason for hiding this comment

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

Looks good, except for the default.

thanks 👍

</journal>
</abandon>
def xmlJournalExport(state: AppState, exportSettings: XmlExportSettings, withVersion: Boolean): xml.Node = {
if (withVersion) {
Copy link
Owner

Choose a reason for hiding this comment

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

Same comment as before: avoid duplicating the code.

@@ -36,9 +36,10 @@ object SettingsHelper {
val cliConf = new AbandonCLIConf(args)
cliConf.verify()
val configOpt = cliConf.config.toOption
val withVersion = cliConf.version.getOrElse(false)
Copy link
Owner

Choose a reason for hiding this comment

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

The default here should be true I think.

That is, for normal usage, the version should be shown in the output. It is only the tests that have a problem with it, and hence they should explicitly disable it.

Alexander Zafirov added 4 commits November 1, 2016 10:47
Set default value of versioned to be true
Set the versioned value for cli test to false
@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 67.977% when pulling 11090c9 on alexanderzafirov:master into b95601b on hrj:master.

@z4f1r0v
Copy link
Contributor Author

z4f1r0v commented Nov 1, 2016

@hrj Tests are happy now. I did a bit of rewording of the variables since the Boolean switches give you true if added. At the same time we want to have version added by default. Please let me know if you are happy with the outcome.

Copy link
Owner

@hrj hrj left a comment

Choose a reason for hiding this comment

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

Awesome!

@hrj hrj merged commit e3b1d40 into hrj:master Nov 3, 2016
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.

None yet

3 participants