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

Fixes part of #59: Testing module builds with both Bazel + Gradle [BLOCKED: #1482] #1488

Merged
merged 142 commits into from
Aug 9, 2020

Conversation

miaboloix
Copy link
Contributor

@miaboloix miaboloix commented Jul 17, 2020

Explanation

Fixes part of #59: Testing module builds with both Bazel + Gradle
I added the /testing module BUILD file and wrote a kt_android_library() rule that builds the source files in /testing. I also configured Robolectric testing for this module using custom macros oppia_android_testing() and testing_tests().

To build the /testing app module in Bazel: bazel build //testing
To run all tests in the module: bazel test //testing/...

Notes:

  1. Gradle seems to fail when Bazel build artifacts are present. Be sure to remove them before building Gradle by running bazel clean
  2. This PR depends on Fixes part of #59: Utility module source files build with both Bazel + Gradle [BLOCKED: #1481] #1482

Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The PR explanation includes the words "Fixes #bugnum: ..." (or "Fixes part of #bugnum" if the PR only partially fixes an issue).
  • The PR follows the style guide.
  • The PR does not contain any unnecessary auto-generated code from Android Studio.
  • The PR is made from a branch that's not called "develop".
  • The PR is made from a branch that is up-to-date with "develop".
  • The PR's branch is based on "develop" and not on any other branch.
  • The PR is assigned to an appropriate reviewer in both the Assignees and the Reviewers sections.

Copy link
Sponsor Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @miaboloix! Does this build without issues? I realized that this module doesn't actually have any UI resources unfortunately, so the potential Android resource building issues will need to wait until we start building the app module.

@BenHenning BenHenning assigned miaboloix and unassigned BenHenning Jul 18, 2020
Copy link
Sponsor Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @miaboloix --generally LGTM, but I have some concerns about the min version issue. Let's make sure that gets resolved before merging this PR in.

WORKSPACE Show resolved Hide resolved
utility/src/main/AndroidManifest.xml Outdated Show resolved Hide resolved
@BenHenning BenHenning assigned miaboloix and unassigned BenHenning Aug 3, 2020
Copy link
Contributor

@anandwana001 anandwana001 left a comment

Choose a reason for hiding this comment

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

LGTM
Thanks @miaboloix

@anandwana001
Copy link
Contributor

@miaboloix I tried again and getting a bit difficulty in a successful build with the below error

 @robolectric//bazel:android-all-jars depends on @org_robolectric_android_all_6_0_1_r3_robolectric_r1//jar:jar in repository @org_robolectric_android_all_6_0_1_r3_robolectric_r1 which failed to fetch. no such package '@org_robolectric_android_all_6_0_1_r3_robolectric_r1//jar': java.io.IOException: Error downloading [https://repo1.maven.org/maven2/org/robolectric/android-all/6.0.1_r3-robolectric-r1/android-all-6.0.1_r3-robolectric-r1.jar, https://jcenter.bintray.com/org/robolectric/android-all/6.0.1_r3-robolectric-r1/android-all-6.0.1_r3-robolectric-r1.jar] to /private/var/tmp/_bazel_akshaynandwana/86e7652338e118cae6d5283ced282727/external/org_robolectric_android_all_6_0_1_r3_robolectric_r1/android-all-6.0.1_r3-robolectric-r1.jar: Unknown host: jcenter.bintray.com

What exactly were you building? testing_main_lib or testing_test_lib? I haven't been able to reproduce this error.
I just pushed a change that removed one of the unused robolectric dependencies from testing_main_lib -- can you see if that did anything? Also, if it is still failing, you may be able to get a more in-depth error message by building testing_main_lib_kt or testing_test_lib_kt.

Could you please add How to build description in PR description on the basis of oppia_android_test.bzl?

What do you mean? Whenever you run a test in this module, you are calling the custom macro testing_test (implemented in testing_test.bzl) which calls oppia_android_test (implemented in oppia_android_test.bazl). So in order to invoke oppia_android_test.bzl you just need to build a test :) The commands you would need are in the description of the PR. Please let me know if I misunderstood your question!

Yes, you are correct. Earlier I think I am missing some file from my side, not fetched properly I guess. It's perfect now. Tried building and running test cases, all are working perfectly correct now.
Thank you :)

@anandwana001 anandwana001 removed their assignment Aug 4, 2020
@miaboloix miaboloix removed their assignment Aug 6, 2020
Copy link
Sponsor Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks!

@BenHenning BenHenning assigned miaboloix and unassigned BenHenning Aug 6, 2020
Base automatically changed from stage1_bazel_utility to develop August 9, 2020 16:23
@miaboloix miaboloix merged commit 681616a into develop Aug 9, 2020
@miaboloix miaboloix deleted the stage1_bazel_testing branch August 9, 2020 16:53
miaboloix added a commit that referenced this pull request Aug 9, 2020
…y module [BLOCKED: #1488] (#1495)

* Working on having one module build with bazel

* Created initial app-level WORKSPACE file

* Added proto_library rule to build model app module

* Added newline at end of WORKSPACE file

* Created macro to process proto files

* Both Bazel and Gradle now build /model successfully

* Fixed typo in BUILD

* Added missing end of file empty lines

* Added Robolectric dependencies and general build rule

* Source files building in both systems - added a TODO for test files

* Turned two kt_android_library rules into one

* Added dependencies for test files

* Created kt_android_library rule for source files

* Add TODO for android_local_test rule

* Added a test manifest for android_local_test()

* Added Firebase dependencies and git_repository for tools_android

* Refactored google-services.json, imported new dependencies

* Fixed Bens nits

* Fixed space in WORKSPACE comment

* Got a demo test working in both Java and Kotlin

* Added rules_java dependencies for protocol buffers

* Added java_proto_library rules, each proto file now has its own rule

* Remove unnecessary srcs attribute for android_library

* Rename bzl file macro

* Added Robolectric dependencies and general build rule

* Source files building in both systems - added a TODO for test files

* Turned two kt_android_library rules into one

* Added dependencies for test files

* Created kt_android_library rule for source files

* Add TODO for android_local_test rule

* Changed model visability, added model and util dependencies to testing

* Added dependencies to testing_main_lib

* Testing source files now build

* Test files are building

* Changed to java_lite

* Added EOF newlines

* Each library now has its own build rule

* Utility is now one rule

* Changed visibility for utility_lib

* Added duplicate google-services.json file to please Gradle

* Utility tests are building and passing (except in_memory_blocking_cache_test)

* Added android_local_test() rules for testing, building but not passing

* Added a test manifest for testing module

* Oppia_android_test is working

* Utility_test is now working

* Testing_test.bzl is now working

* changed all android_local_test rules to utility_test rules

* Named test rules correctly

* Added missing dependency, all tests now pass

* Removed all unused dependencies

* Changed event_logger.proto to oppia_logger.proto

* Added missing EOF newlines

* Fixed visibility

* Remove addressed TODOs

* Fixed bug in import statements for exploration.proto, topic.proto, and question.proto

* Deleted DemoJava

* CHanged rules_kotlin version

* Added Firebase dependencies

* Removed AsyncResultTest example

* Removed AsynchResultTest example

* Firebase dependencies added

* Removed unnecessary comments in WORKSPACE and moved rules_kotlin

* Added re-naming TODOs

* Renamed java_proto rules java_proto_lite

* Added doc comments to model/BUILD.bazel and format_import_proto_library

* Added comments to WORKSPACE file

* Fixed nits

* Added comment to kt_android_library() rule

* Fixed more nits

* Added Firebase comment

* Fixed merge conflicts and nits

* Deleted unused dependencies from testing_main_lib

* Fixed nits and error with testing lib dependencies

* Changed library name to model

* Formatted WORKSPACE comment

* Formatted TODO statement

* Changed format_import_proto_library comment

* Added EOF newline

* Created Issue and linked TODO in WORKSPACE

* Edited model BUILD file top comment

* Addressed nits

* Fixed nits and added comments

* Fixing nits

* Deleted unnecessary dependencies and testing example file

* Fixed manifest issues

* Move google json file

* Restore app version of json

* Edit TODO

* Deleted TODO

* Changed Firebase comment

* Added testing functionality from later PR

* Added comments to bzl files

* Added targetSDK to manifests

* Changed crashlytics_lib to crashlytics

* Changed testing_tests visibility

* Added comment to utility_test.bzl

* Changed type of comment ticks

* Fixed typos and all tests pass

* Removed empty line

* Fixed nits and added TODOs

* Added Args to document comment

* Changed targetSDK to 29

* Formatted TODO

* Added root BUILD file

* Moved google-services.json

* Added gogle-services.json back to app

* Trying to remove combined testing library

* Changed targetSDK to 29

* Tests pass now with deps passed in.

* Created TEST_DEPS list to avoid duplicate list of dependencies

* Removed unused resources and manifest

* Updated comments to reflect changes

* Changed deps to be a parameter, changed targetSDK back to 28 because tests do not pass at 29

* Fixed indentation in utility/BUILD

* Updated comment for utility_test.bzl

* Updated comment for testing_test

* Formatted dependencies and removed unused dependency

* Updated dependency list

* Header for oppia_android_test now fits on one line

* Edited documentation for oppia_android_test

* Updated documentation for utility and testing BUILD files

* Changed src to srcs

* Changed src to srcs

* Fixed the duplicate google-services.json issue

* Created Issue and added TODO

* Added minSDK back

* Alphabetized dependencies

* Fixed firebase target

* Changed targetSdk to 28
@miaboloix miaboloix added this to Done in Bazel Migration Aug 10, 2020
miaboloix added a commit that referenced this pull request Aug 17, 2020
…ting [BLOCKED: #1488] (#1514)

* Working on having one module build with bazel

* Created initial app-level WORKSPACE file

* Added proto_library rule to build model app module

* Added newline at end of WORKSPACE file

* Created macro to process proto files

* Both Bazel and Gradle now build /model successfully

* Fixed typo in BUILD

* Added missing end of file empty lines

* Added Robolectric dependencies and general build rule

* Source files building in both systems - added a TODO for test files

* Turned two kt_android_library rules into one

* Added dependencies for test files

* Created kt_android_library rule for source files

* Add TODO for android_local_test rule

* Added a test manifest for android_local_test()

* Added Firebase dependencies and git_repository for tools_android

* Refactored google-services.json, imported new dependencies

* Fixed Bens nits

* Fixed space in WORKSPACE comment

* Got a demo test working in both Java and Kotlin

* Added rules_java dependencies for protocol buffers

* Added java_proto_library rules, each proto file now has its own rule

* Remove unnecessary srcs attribute for android_library

* Rename bzl file macro

* Added Robolectric dependencies and general build rule

* Source files building in both systems - added a TODO for test files

* Turned two kt_android_library rules into one

* Added dependencies for test files

* Created kt_android_library rule for source files

* Add TODO for android_local_test rule

* Changed model visability, added model and util dependencies to testing

* Added dependencies to testing_main_lib

* Testing source files now build

* Test files are building

* Changed to java_lite

* Added EOF newlines

* Each library now has its own build rule

* Utility is now one rule

* Changed visibility for utility_lib

* Added duplicate google-services.json file to please Gradle

* Utility tests are building and passing (except in_memory_blocking_cache_test)

* Added android_local_test() rules for testing, building but not passing

* Added a test manifest for testing module

* Oppia_android_test is working

* Utility_test is now working

* Testing_test.bzl is now working

* changed all android_local_test rules to utility_test rules

* Named test rules correctly

* Added missing dependency, all tests now pass

* Removed all unused dependencies

* Changed event_logger.proto to oppia_logger.proto

* Added missing EOF newlines

* Fixed visibility

* Initial BUILD file added

* Remove addressed TODOs

* Started writing build rule

* Fixed bug in import statements for exploration.proto, topic.proto, and question.proto

* Deleted DemoJava

* Removed unused dependencies in domain_lib

* Working on building domain test files

* Added a test manifest

* Test files now build

* Added test rules, some tests not building or passing

* Added data attribute to test macros

* All tests now build, some do not pass

* CHanged rules_kotlin version

* All tests now pass

* Firebase dependency errors have been resolved

* Save firebase dependency fixes for new PR

* Fixed typo

* Added Firebase dependencies

* Removed AsyncResultTest example

* Removed AsynchResultTest example

* Firebase dependencies added

* Removed unnecessary comments in WORKSPACE and moved rules_kotlin

* Added re-naming TODOs

* Renamed java_proto rules java_proto_lite

* Added doc comments to model/BUILD.bazel and format_import_proto_library

* Added comments to WORKSPACE file

* Fixed nits

* Added comment to kt_android_library() rule

* Fixed more nits

* Added Firebase comment

* Fixed merge conflicts and nits

* Deleted unused dependencies from testing_main_lib

* Fixed nits and error with testing lib dependencies

* Removed printStackTrace()

* Removed addressed TODOs, all tests pass

* Removed redundant public modifier

* Changed library name to model

* Formatted WORKSPACE comment

* Formatted TODO statement

* Changed format_import_proto_library comment

* Added EOF newline

* Created Issue and linked TODO in WORKSPACE

* Edited model BUILD file top comment

* Addressed nits

* Fixed nits and added comments

* Fixing nits

* Deleted unnecessary dependencies and testing example file

* Fixed manifest issues

* Move google json file

* Restore app version of json

* Edit TODO

* Deleted TODO

* Changed Firebase comment

* Added testing functionality from later PR

* Added comments to bzl files

* Added targetSDK to manifests

* Changed crashlytics_lib to crashlytics

* Changed testing_tests visibility

* Added comment to utility_test.bzl

* Changed type of comment ticks

* Fixed typos and all tests pass

* Removed empty line

* Fixed errors from merge

* Added comments to data and domain BUILD files

* Fixed indentation in domain_test

* Removed commented-out dependencies

* Fixed nits and added TODOs

* Added Args to document comment

* Changed targetSDK to 29

* Formatted TODO

* Added root BUILD file

* Moved google-services.json

* Added gogle-services.json back to app

* Trying to remove combined testing library

* Changed targetSDK to 29

* Tests pass now with deps passed in.

* Created TEST_DEPS list to avoid duplicate list of dependencies

* Removed unused resources and manifest

* Updated comments to reflect changes

* Changed deps to be a parameter, changed targetSDK back to 28 because tests do not pass at 29

* Fixed indentation in utility/BUILD

* Updated comment for utility_test.bzl

* Updated comment for testing_test

* Formatted dependencies and removed unused dependency

* Updated dependency list

* Header for oppia_android_test now fits on one line

* Simplifies comment on domain/BUILD file

* Changed cache_store to persistent_cache_store

* Removed glob() from data BUILD file

* Edited documentation for oppia_android_test

* Updated documentation for utility and testing BUILD files

* Changed src to srcs

* Changed src to srcs

* All dragAndDrop tests now pass, stateRetreiverTest fails

* Fixed the duplicate google-services.json issue

* Created Issue and added TODO

* Added minSDK back

* Alphabetized dependencies

* Fixed firebase target

* Trying to fix StateRetreiverTest

* Fixed ktlint violation

* Changed targetSdk to 28

* Created Issue and added TODOs for re-restricitng access

* Added min and target SDK to domain manifest

* Removed unused domain)tests library

* Added documentation, created an issue, added a TODO

* Added assets

* Testing module tests now pass, all domain tests pass except StateRetreiver

* Added TODO for StateRetreiver Tes

* Removed unnecessary data attribute

* StateRetrieverTest now passes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants