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

Add problem filtering capability to cli frontend. #30

Merged
merged 5 commits into from
Feb 21, 2013

Conversation

gkossakowski
Copy link
Contributor

This pull request introduces a way to configure MiMa to filter out
reported binary incompatibilities. Configuration is done in by defining
filtering rules in configuration file that is handled by Typesafe
Config library. Path to configuration file is set with --filters command
line option.

The resulting syntax is a bit verbose but we get future configuration
extensibility for free. We also get a way to put comments in configuration
file which is very important if we want to document why given problem can
be safely ignored.

The other command line option this commit introduces is
--generate-filters that generates configuration for filters to ignore
all of currently reported problems. It can be combined with --filters
option.

The two additional highlights of this pull request:

  • Add factory method to ProblemFilters that creates problem filter
    out of string definition using reflection.
  • Add dependency on Typesafe Config library

NOTE: This pull request does not introduce filtering by packages but only by
specific problems. However, most of the necessary functionality to
implement that feature is being introduced by this pull request so it should be
relatively easy to add it if needed.

NOTE: This pull request does not come with tests. There are no tests for CLI
and I tried to introduce but it turned out to be too hard. The basic
problem is that we have to operate on paths because CLI takes paths
to files as arguments but there's no easy way to do that in traditional
tests. Probably the best way would be to write custom test interfaces
where we have access to all necessary paths but that's beyond this
contribution.

Fixes #13.

paulp and others added 4 commits February 2, 2013 09:26
Normalized the repos, otherwise my patches will be sprinkled
with whitespace noise.
This commit introduces a way to configure MiMa to filter out
reported binary incompatibilities. Configuration is done in by defining
filtering rules in configuration file that is handled by Typesafe
Config library. Path to configuration file is set with `--filters` command
line option.

The resulting syntax is a bit verbose but we get future configuration
extensibility for free. We also get a way to put comments in configuration
file which is very important if we want to document why given problem can
be safely ignored.

The other command line option this commit introduces is
`--generate-filters` that generates configuration for filters to ignore
all of currently reported problems. It can be combined with `--filters`
option.

The two additional highlights of this change:
  * Add factory method to `ProblemFilters` that creates problem filter
    out of string definition using reflection.
  * Add dependency on Typesafe Config library

NOTE: This change does not introduce filtering by packages but only by
specific problems. However, most of the necessary functionality to
implement that feature is being introduced by this change so it should be
relatively easy to add it if needed.

NOTE: This change does not come with tests. There are no tests for CLI
and I tried to introduce but it turned out to be too hard. The basic
problem is that we have to operate on paths because CLI takes paths
to files as arguments but there's no easy way to do that in traditional
tests. Probably the best way would be to write custom test interfaces
where we have access to all necessary paths but that's beyond this
contribution.

Fixes lightbend-labs#13.
By calling Config.resolve we enable substitution mechanism from
Typesafe Config library. This is handy if one wants to break long
list of filters into smaller variables (e.g. focused on one
package) and concatenate them into one big list.
@gkossakowski
Copy link
Contributor Author

Please review my 3 commits individually, as the overall diff is big due to whitespace normalization.

@adriaanm
Copy link
Contributor

awesome -- this is crucial for maintaining binary compatibility in scala

@gkossakowski
Copy link
Contributor Author

pinging @dotta. We need to get this through ASAP.

@jsuereth
Copy link
Contributor

LGTM - Should still check with @dotta

@dotta
Copy link
Contributor

dotta commented Feb 12, 2013

WIll look at it by tomorrow. Unless this is dead-or-alive urgent. If that's the case, I'll do it tonight.

@gkossakowski
Copy link
Contributor Author

@dotta: tomorrow is fine.

@dotta
Copy link
Contributor

dotta commented Feb 12, 2013

Cool! :)

@dotta
Copy link
Contributor

dotta commented Feb 13, 2013

Am I right to think that the sbt-plugin and the CLI will have two different ways for filtering? If yes, what's the rationale?

@gkossakowski
Copy link
Contributor Author

@dotta: there's already a split, so there are options that are available through plugin and are not available through CLI. I looked into unifying those things but the code is rathe messy. There are at least 3 ways to configure/setup mima internally and they override each other. I think that it requires major effort to clean it up and I wasn't feeling like doing that at the moment. Also, my changes do not make situation that much worse.

There's also more fundamental problem. With sbt plugin, you configure filters by passing lambdas. Until we have eval mechanism in Scala this technique cannot be used to configure filters from a text file. Even if we have eval, I don't think using lambdas for configuration is a good idea.

@dotta
Copy link
Contributor

dotta commented Feb 15, 2013

Adding yet another way of configuring things is not making the codebase any simpler to maintain. So, if before there were already 2 ways to configure MiMa, now they are 3, which is not an improvement. That being said, I think that using the Typesafe Config library is a good idea, so I'd say that your solution is superior to the others, which is why I'm ok in merging this even without cleaning up the rest.

However, before merging, I would like to see tests for avoiding breakages wrt the filter configuration file. In fact, it relies on the problems' classname to 1) not change, and 2) not be moved in a different package. What you could do is extracting the logic that loads the filters and returns the sequence of ProblemFilter, and then have tests for each of the classes in Problems.scala. I don't think this is much work, and it would also be valuble documentation for anyone working on the project.

By the way, we also need to document the new features. (I know the wiki is empty at the moment, but I'll work on it right away)

@dotta
Copy link
Contributor

dotta commented Feb 15, 2013

By the way, we also need to document the new features. (I know the wiki is empty at the moment, but I'll work on it right away)

Done. https://github.com/typesafehub/migration-manager/wiki

@adriaanm
Copy link
Contributor

Given the urgency of BC testing for the 2.10.1 release, I would really like to see this merged and a new version of MiMa published. I agree we should do testing on our testing infrastructure, but let's first get the actual testing done so we can efficiently ensure binary compatibility of our releases.

/cc @gkossakowski and @dotta

@dotta
Copy link
Contributor

dotta commented Feb 21, 2013

@adriaanm My last comment was made 6 days ago, and I believe I've been very reasonable, i.e., I'm happy to merge this PR the moment the few comments I made are adressed.

@gkossakowski
Copy link
Contributor Author

@dotta: First of all, problems cannot be moved because they are part of sbt plugin's api: https://github.com/typesafehub/migration-manager/blob/master/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/Keys.scala#L13

That's the reason I decided that reflection is ok because those classes are being exposed externally anyway. I forgot to note that in a commit. Sorry.

When it comes to testing I tried to write tests for cli but there are none so far and it's actually non-trivial to introduce. There are no existing tests for CLI that I could follow for testing those changes. The problem I faced is that you need to pass full paths to cli as arguments and I don't know how to resolve them in a test. I spent some time poking around but I couldn't find any good way around that so I gave up. If you have specific suggestion how to overcome that problem I'm all ears.

/**
* Parses Config definition into sequence of problem filters.
*
* @exception ConfigException
Copy link
Contributor

Choose a reason for hiding this comment

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

@throws

@dotta
Copy link
Contributor

dotta commented Feb 21, 2013

You have missed a couple of places where you should replace @exception with @throws. And, what about the indentation in the help message? I understand you guys don't have time for this, but it looks pretty terrible.

Anyway, amends commits as needed and I'll merge the PR. Next week I'll have a look at how to write tests for the CLI, and if I have a practical way to do so, I'll ask you to create tests for this PR. Ok?

One more thing, could you update https://github.com/typesafehub/migration-manager/wiki/MiMa-Command-Line-Tool and shortly explain how the new options are supposed to be used (also show how a filter file looks like). The moment this is done I'll do the merge.

As @dotta suggested, it should be `@throws` and not `@exception`.
@gkossakowski
Copy link
Contributor Author

Sorry for letting this hang for so long.

To sum it up:

  • I fixed the documentation problem (this time for real, I verified by grepping)
  • the command line indentation problem is indeed problem with cmd line options parsing library cli uses; this library is part of Scala compiler but Scala compiler does not use it. It's a bad idea to depend on this unmaintained and very hard to understand (I still don't understand what causes this problem with indentation). I filed a ticket for that, see CLI shouldn't depend on scala.tools.cmd package from the compiler #31.
  • I honestly don't know how to write tests for cli.

@gkossakowski
Copy link
Contributor Author

@dotta: oh, I missed your latest comment. Yes, if you figure out how to write tests for cli I'm happy to write for filters.

I'll update wiki page tomorrow.

@dotta
Copy link
Contributor

dotta commented Feb 21, 2013

Awesome. Thanks a lot Greg for your good will, appreciate it.

dotta added a commit that referenced this pull request Feb 21, 2013
Add problem filtering capability to cli frontend.
@dotta dotta merged commit 6db4e86 into lightbend-labs:master Feb 21, 2013
@gkossakowski gkossakowski deleted the 13-cli-filters branch February 21, 2013 08:37
@adriaanm
Copy link
Contributor

Thanks, Mirco! Who can release version 0.1.5? It's blocking the 2.10.1-RC2 release, which is scheduled for Feb 22nd.

@dotta
Copy link
Contributor

dotta commented Feb 22, 2013

Today I'm busy with IDE stuff. Since the fix is in the CLI tool, can't you just build master and use the SNAPSHOT? I know it's not ideal, but I think it's practical for everyone. Also, doing a full release for just this additional fix looks like a bit of a overhead to me.

@adriaanm
Copy link
Contributor

We unfortunately can't use snapshot as this runs as part of our PR-validation, checkin and nightly builds on jenkins.

@adriaanm
Copy link
Contributor

As we are coordinating 2.10.1-RC2 with your RC1, this can wait until then. Have a nice weekend!

(A compromise would be to have nightly builds of projects like this, so that we can at least use them. It's not practical to use manual builds as we have jenkins slaves all over who need to be able to get the artifact. However, nightly builds are still not ideal because you lose repeatability of your build when it relies on SNAPSHOT builds of other tools (as pointed out by @retronym).)

@gkossakowski
Copy link
Contributor Author

Yes, using nightly builds is a bad idea. Is realasing mima hard? I thought it would be just one command sbt publish, no?

@jsuereth
Copy link
Contributor

It goes to maven central. Let's chat release when I'm in SF
On Feb 22, 2013 1:04 PM, "Grzegorz Kossakowski" notifications@github.com
wrote:

Yes, using nightly builds is a bad idea. Is realasing mima hard? I thought
it would be just one command sbt publish, no?


Reply to this email directly or view it on GitHubhttps://github.com//pull/30#issuecomment-13959382.

@jsuereth
Copy link
Contributor

Oh, also you should update the Typesafe website, and all that annoyance.
Its not really just sbt publish.
On Feb 22, 2013 1:04 PM, "Grzegorz Kossakowski" notifications@github.com
wrote:

Yes, using nightly builds is a bad idea. Is realasing mima hard? I thought
it would be just one command sbt publish, no?


Reply to this email directly or view it on GitHubhttps://github.com//pull/30#issuecomment-13959382.

@gkossakowski
Copy link
Contributor Author

@jsuereth: sure but this can be done as a second step of a release. The most important thing is that we shouldn't be blocked by lack of mima release.

@dotta
Copy link
Contributor

dotta commented Feb 25, 2013

@gkossakowski I can't currently do it myself because I lack the credentials (I just found out about this ;-)). Hence, I need @jsuereth to do it this time. I've already done the tagging and created a PR for bumping the version number for releasing (the 0.1.5 tag includes all commits in that PR).

Getting back to your point about releasing, it's not hard, but it does require someone (currently Josh or myself) to take the time to make sure it is properly done. As you know, we are involved in other tasks as well, so it is not always desiderable to context switch. To shorten reaction time in the future, how would you feel about becoming responsible of releasing MiMa whenever you, Compiler Team, need a new release of MiMa?

By the way, thanks a lot for editing the Wiki!

@adriaanm
Copy link
Contributor

I think it's good to rotate responsibilities for this so more people know how to do it. In order to enable rotation, we'll need docs. Ideally, those docs would be in the form of a jenkins job so that can just push the button. /cc @jsuereth

@adriaanm
Copy link
Contributor

ping @jsuereth -- could we please do the minimal sbt publish so that we can use our build automation to stay on top of binary compatibility? the rest of the announcement can come later

@jsuereth
Copy link
Contributor

jsuereth commented Mar 1, 2013

Yeah, done now.

On Thu, Feb 28, 2013 at 1:25 PM, Adriaan Moors notifications@github.comwrote:

ping @jsuereth https://github.com/jsuereth -- could we please do the
minimal sbt publish so that we can use our build automation to stay on top
of binary compatibility? the rest of the announcement can come later


Reply to this email directly or view it on GitHubhttps://github.com//pull/30#issuecomment-14248530
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Support filters in UI and CLI
5 participants