Skip to content

Integrate intellij scala aspect integration testing into rules_scala #309

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

Merged

Conversation

greggdonovan
Copy link
Contributor

Related to #308

As we want to test multiple versions of the intellij plugin (master and a release tag) we are managing a manual clone of intellij instead of using a git submodule. I'm not sure how to get submodules to handle a test matrix of intellij versions reasonably.

@bazel-io
Copy link

Can one of the admins verify this patch?

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

@greggdonovan greggdonovan force-pushed the intellij_integration_via_manual_clone branch from 3aa1605 to 1068af6 Compare October 17, 2017 01:00
@googlebot
Copy link

CLAs look good, thanks!

@johnynek
Copy link
Contributor

test this please

@greggdonovan
Copy link
Contributor Author

Sorry -- the git clone failed. PR updated.

I'll try setting up my own travis account to iterate on this tomorrow.

@ittaiz
Copy link
Contributor

ittaiz commented Oct 17, 2017

Looks good now!
I looked at only one cell in the matrix and it's currently broken because our integration is broken :)
I think we'll need to keep this PR open until we have another PR which branched out of this branch and fixes the current tests.
Thanks Gregg!

test_run.sh Outdated
cd intellij && git fetch && git pull
fi
git checkout "${intellij_git_tag}"
bazel test --test_output=errors --incompatible_disallow_set_constructor=false --override_repository io_bazel_rules_scala=${rules_scala_dir} //aspect/testing/tests/src/com/google/idea/blaze/aspect/scala/...
Copy link
Contributor

Choose a reason for hiding this comment

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

you should quote ${rules_scala_dir} in case it has whitespace

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, I'll update the PR.

test_run.sh Outdated
intellij_git_tag=$1
rules_scala_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

if [[ "$runner" == "run_test_ci" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

this feels brittle. can you detect CI another way? maybe test -d intellij?

Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't rely on any Travis specific env variables, ci is passed to the script and then runner is set based upon that value so I can't see a situation where it would break nor be able to be handled across multiple ci environments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kevingessner How about:

if [[ "$1" == "ci" ]]; then

That is one fewer level of indirection, at least.

Copy link
Contributor

Choose a reason for hiding this comment

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

"brittle" in that, if someone changes the name of the run_test_ci runner function, this will not error but will start behaving badly -- it'd be better if this was a reference to the function that was safe against changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh yeah, missed that. thanks!
I think @greggdonovan's latest is better.

Copy link
Contributor

Choose a reason for hiding this comment

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

@greggdonovan can you change the above to if [[ "$1" == "ci" ]]; then like you suggested?

@ittaiz
Copy link
Contributor

ittaiz commented Oct 17, 2017 via email

@johnynek
Copy link
Contributor

johnynek commented Nov 9, 2017

@greggdonovan I want to merge this, but it is still red on travis. Any ideas on how to get it green?

@greggdonovan greggdonovan force-pushed the intellij_integration_via_manual_clone branch from 2133722 to 50b898b Compare November 9, 2017 01:30
@greggdonovan
Copy link
Contributor Author

@johnynek Thanks! It seems like we have to understand the exact nature of the failures and resolve them to make this green.

For example, testScalaLibrary expects both a JAR and an ijar but the test failure claims we're only supplying the JAR. My understanding is that we supplied both JAR and ijar for libraries, so this is surprising to me. I'll take a deeper look and see if I can provide more context.

@greggdonovan
Copy link
Contributor Author

The remaining test failure appears to be due to a transient failure to connect to Maven Central.

Otherwise, everything else is green. As long as we're happy with the ijar change and a re-run on CI passes, I think this should be OK to commit.

As far as the transient failure goes, I'll open a separate ticket to switch native.maven_jar usage to java_import_external or see if it makes sense to incorporate it into the scala_import PR.

@ittaiz
Copy link
Contributor

ittaiz commented Nov 12, 2017 via email

test_run.sh Outdated
intellij_git_tag=$1
rules_scala_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

if [[ "$runner" == "run_test_ci" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

@greggdonovan can you change the above to if [[ "$1" == "ci" ]]; then like you suggested?

test_run.sh Outdated
@@ -604,3 +621,5 @@ $runner test_scala_library_expect_failure_on_missing_direct_java
$runner bazel run test:test_scala_proto_server
$runner test_scala_library_expect_failure_on_missing_direct_deps_warn_mode_java
$runner test_scala_library_expect_better_failure_message_on_missing_transitive_dependency_labels_from_other_jvm_rules
$runner test_intellij_aspect ac2bb7 # TODO(https://github.com/bazelbuild/intellij/issues/146): replace with release tag when fixed.
Copy link
Contributor

Choose a reason for hiding this comment

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

should we remove this? IIRC intellij team said they're not going to have tags any time soon

scala/scala.bzl Outdated
def _format_full_jars_for_intellij_plugin(full_jars):
return [struct (class_jar = jar, ijar = None) for jar in full_jars]
def _format_full_jars_for_intellij_plugin(full_jars, ijar):
return [struct (class_jar = jar, ijar = ijar) for jar in full_jars]
Copy link
Contributor

Choose a reason for hiding this comment

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

@chaoren what does the plugin do with the ijar field?
I set it to None since I didn't see any drawbacks from setting it to None and on the other hand it becomes a bit more tricky to match the java-code ijar to the java-code full jar and the scala-code ijar to the scala-code full jar. It's not rocket science but a bit more cumbersome than I want and without any value I can see.

@greggdonovan the above implementation might be a problem since it passes the scala-code ijar for the java-code full jar. Depending on @chaoren's response we'll need to:

  1. Change the intellij tests to expect None (if he agrees we don't need it).
  2. Change our code to pass the right tuples so that we pass the right ijar to the full jar (if he surfaces reasons to using the ijar).

Copy link
Contributor

Choose a reason for hiding this comment

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

btw, if @chaoren says this can be ignored we can merge this PR and later remove it once he fixes the test

Copy link
Contributor

Choose a reason for hiding this comment

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

We actually just use the class_jar if the ijar is not available, so you might see some performance hits.

Copy link
Contributor

Choose a reason for hiding this comment

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

What performance hit? In loading bigger jars to memory?
@greggdonovan this sounds like the current change pleases the test but will break the actual production

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah pretty much. class_jar can always replace ijar, except it's much larger.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see.
@greggdonovan do you want to take a crack at passing the matching ijar to the relevant full jar?

@ittaiz
Copy link
Contributor

ittaiz commented Nov 15, 2017 via email

@ittaiz
Copy link
Contributor

ittaiz commented Nov 27, 2017

@greggdonovan I think this fell off of your radar. Any chance you can carry it through?

@greggdonovan
Copy link
Contributor Author

@ittaiz Yes, sorry about that! I'll take a look this week. Thanks for catching the green test not being the whole story. ;-)

Can you give me more details on the difference between the Scala JARs and the Java JARs? I'm a bit fuzzy on the distinction. Thanks!

@ittaiz
Copy link
Contributor

ittaiz commented Nov 27, 2017

Sure no problem.
Essentially a scala_library can generate either a jar for the scala sources, a jar for the java sources or both. If we supply intellij with the ijars we need to propagate both ijars and pass the full with the ijar of each language. Alternatively we can just decide to punt on this for now, change the intellij tests to not expect the ijar for the time being and continue to pass None

@ittaiz
Copy link
Contributor

ittaiz commented Dec 13, 2017

Hi,
I know you're swamped but just another (hopefully) friendly ping

@greggdonovan greggdonovan force-pushed the intellij_integration_via_manual_clone branch from 7c0c0ce to f82563b Compare December 18, 2017 19:28
@greggdonovan
Copy link
Contributor Author

Good news, bad news. With the ijar .bzl changes reverted, the build passes without any runtime changes.

However, on the OSX Travis builders, we're hitting the travis.org timeout of 50 minutes with the added time for this test. The test downloads about ~800mb of IntelliJ IDEs and other artifacts and spends ~3 minutes compiling protoc, so there may not be much to do to speed it up.

I can think of a few options to work around this:

  • We can add rows in the build matrix just for this test, keeping us under 50 minutes.
  • We can kick off this test at the beginning of the build in parallel.
  • Just run this test periodically via a Travis cron.

@ittaiz
Copy link
Contributor

ittaiz commented Dec 20, 2017 via email

…by manually cloning intellij.

As we want to test multiple versions of the intellij plugin (master and a release tag) we are managing a manual clone of intellij instead of using a git submodule.
@greggdonovan greggdonovan force-pushed the intellij_integration_via_manual_clone branch from 320632b to 917411d Compare December 26, 2017 02:32
@greggdonovan
Copy link
Contributor Author

I think this is ready for another look, @ittaiz. The Travis build matrix now has separate rows for the IntelliJ aspect test.

Copy link
Contributor

@ittaiz ittaiz 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, thanks!
Can you please remind me how come the tests now pass?

@greggdonovan
Copy link
Contributor Author

Thanks, @ittaiz!

This now passes because intellij stopped expecting the ijars here.

We can revisit re-adding them to the intellij tests and scala.bzl if we feel the ijars are useful for the Intellij plugin.

@ittaiz ittaiz merged commit 7104a0e into bazel-contrib:master Dec 27, 2017
@ittaiz
Copy link
Contributor

ittaiz commented Dec 27, 2017

Well done!
Important contribution in intellij scala stability :)
I think next step should probably be to add a few tests over in the intellij plugin repo for covering scala_import
The current implementation is untested with respect to the plugin.
I actually think we can simplify it somewhat.
@hmemcpy the intellij plugin now supports the option of having only java provider, right?
maybe we should remove the "intellij metadata" from scala_import and manually test it.

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

Successfully merging this pull request may close these issues.

8 participants