Skip to content

Commit

Permalink
Bazel 6 JVM + Android (#391)
Browse files Browse the repository at this point in the history
* Merge branch 'main' into bazel-6

* wip reference assets cli plugin

* Saving progress. Split targets based on src folder

* Saving progress. Config loads

* Skip testing mocks for now

* Add cli-preset & generate xlrs for reference assets + types

* Update preset

* Add other asset types to plugin

* Use js_xlr_pipeline macro for ref assets & types

* set up maven

* kotlin serialization builds..

* jvm core building

* test running

* jvm building

* fix most of the tests

* target es5 for native build

* bundled reference assets mocks

* aggregate mocks into //tools/mocks

* build all the plugins

* playerui in packages

* grab bazel common works

* android player building

* android test building

* demo lib building

* android_ndk_respository cuz how can this NOT be needed for native android app build

* building reference assets android

* everything building

* revert some unneeded changes

* enabled and fixed most andriod reference asset tests

* fix a bunch more unit tests

* package apk properly

* latest rules_jvm before bazel7

* update rules jvm and tests

* replace local rules with git repos

* install android 33

* enable distribution + use original rules_jvm

* fix merge

* fix mocks

* remove aar

* updated docker

* update android image

* set android ndk home

* also add tools to ios build

* re-enable android script to enable workspace ndk config

* define android_home

* specify java environment

* log java env

* what am i doing..

* gotta install jdk first

* try 11

* and use it

* what is in here

* change java_home?

* apple silicon install location?

* correct location

* rosetta?

* install only ndk

* brew install on rosetta

* revert

* accept 1 less license

* skip license accept

* zulu

* don't tap

* @

* change java_home

* caskroom

* don't install anything just create folder

* back to 11

* revert script and install temurin8

* temurin requires rosetta

* install rosetta at teh top

* install rosetta at the top

* root installer

* proper JAVA_HOME maybe

* remove evals

* install sdk too

* remove duplicate classes

* change test to match bazel6

* change type-provider back

* remove all NATIVE_BUILD_DEPS

* Revert "remove all NATIVE_BUILD_DEPS"

This reverts commit a121305.

* Revert "change type-provider back"

This reverts commit 39db253.

* fix swift test check

* add choiceAsset and unify test framework versions

* lint

* try removing the directory from working directory to see impact on workspace

* git rm

* forget it, gitignore it is

* comment out non-existing things from rules_palyer

* remove jvm deps.bzl

* latest rules player with publishing

* embedded jdk

* remove debugger from j2v8 deps

* add debugger to demo

* attempt at solving lint issues

* remote jdk over embedded

* does this do anything

* set all java options

* jdk11

* java_language_version

* fix targets

* update release scripts to call proper js package target

* remove embedded jdk

* iOS - Use reference assets in swiftui tests (#368)

replace dummy assets and use reference assets in swiftui tests

Co-authored-by: nancywu1 <nancy_wu1@intuit.com>
Co-authored-by: Harris Borawski <harrisborawski@gmail.com>

* Ayncnode comments cleanup (#385)

Async node comments clean up

* update readme

use updated ios pipeline macro with uitest target

use updated ios pipeline macro with uitest target

use updated ios pipeline macro with uitest target

use updated ios pipeline macro with uitest target

use updated ios pipeline macro with uitest target

use updated ios pipeline macro with uitest target

* some clarification docs for binding classes

* enable ndk 23

* remove workspace ndk setup

* compile against kotlin 1.7 to be compatible with gradle 7

* remove grab db

* Revert "remove grab db"

This reverts commit be1b030.

* address most of the comments

* address some more comments

* add test back in

* more comments

* remove dummy API classes

* all targets except ios

* install tools

* doc builds working

* Fix storybook addons

* fix a bunch of tests and change test command

* super mocks bundle

* fix player test

* last test

---------

Co-authored-by: Jeremiah Zucker <zucker.jeremiah@gmail.com>
Co-authored-by: Adam Dierkens <Adam_Dierkens@intuit.com>
Co-authored-by: nancywu1 <zx3wu109@gmail.com>
Co-authored-by: Ketan Reddy <ketan@ketanreddy.com>
Co-authored-by: nancywu1 <66387473+nancywu1@users.noreply.github.com>
Co-authored-by: nancywu1 <nancy_wu1@intuit.com>
Co-authored-by: Harris Borawski <harrisborawski@gmail.com>
Co-authored-by: sakuntala-motukuri <sakuntala_motukuri@intuit.com>
  • Loading branch information
9 people authored Jul 9, 2024
1 parent 1f3b30a commit 0eca6b6
Show file tree
Hide file tree
Showing 166 changed files with 1,412 additions and 994 deletions.
2 changes: 2 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ plugins/meta-plugin/core/node_modules
plugins/partial-match-fingerprint/core/node_modules
plugins/pubsub/core/node_modules
plugins/reference-assets/components/node_modules
plugins/reference-assets/cli-preset/node_modules
plugins/reference-assets/core/node_modules
plugins/reference-assets/react/node_modules
plugins/shared-constants/core/node_modules
Expand All @@ -63,4 +64,5 @@ docs/storybook/node_modules
plugins/reference-assets/mocks/node_modules
tools/addon-storybook/node_modules
tools/components/node_modules
tools/mocks/node_modules
docs/site/node_modules
6 changes: 6 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
common --enable_bzlmod
test --test_output=errors
coverage --combined_report=lcov

# TODO: Custom compiler version breaks embedded jdeps generator plugin - enable when removing custom kotlinc
build --@rules_kotlin//kotlin/settings:jvm_emit_jdeps=False

# Android databinding flags
# TODO: Verify the follow doesn't break host compil
build --android_crosstool_top=@androidndk//:toolchain
build --experimental_android_databinding_v2
build --android_databinding_use_v3_4_args
build --android_databinding_use_androidx
Expand Down
83 changes: 77 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ orbs:
executors:
base:
docker:
- image: docker.io/playerui/bazel-docker:7
- image: docker.io/playerui/bazel-docker:10
working_directory: ~/player
resource_class: xlarge
environment:
Expand All @@ -30,7 +30,7 @@ executors:
TZ: "/usr/share/zoneinfo/America/Los_Angeles"
android:
machine:
image: android:202102-01
image: android:2024.04.1
working_directory: ~/player
resource_class: large
environment:
Expand Down Expand Up @@ -114,10 +114,34 @@ jobs:
- attach_workspace:
at: ~/player

- macos/install-rosetta

- run:
name: Homebrew Dependencies
command: |
HOMEBREW_NO_AUTO_UPDATE=1 brew install bazelisk lcov
brew install --cask temurin@8
sudo installer -pkg /opt/homebrew/Caskroom/temurin@8/8,412,08/OpenJDK8U-jdk_x64_mac_hotspot_8u412b08.pkg -target /
- restore_cache:
keys:
- android-tools-{{ arch }}-{{ checksum "scripts/install-android-tools.sh" }}

- run: echo 'export ANDROID_HOME=~/android-tools' >> $BASH_ENV

- run:
name: Install Android tools
command: |
sh scripts/install-android-tools.sh
echo 'export ANDROID_SDK_HOME=$ANDROID_HOME' >> $BASH_ENV
echo 'export ANDROID_NDK_HOME=$ANDROID_SDK_HOME/ndk/23.2.8568313' >> $BASH_ENV
echo 'export PATH=$ANDROID_SDK_HOME/tools/bin:$PATH' >> $BASH_ENV
echo 'export PATH=$ANDROID_SDK_HOME/tools:$PATH' >> $BASH_ENV
echo 'export PATH=$ANDROID_SDK_HOME/platform-tools:$PATH' >> $BASH_ENV
echo 'export PATH=$ANDROID_SDK_HOME/emulator:$PATH' >> $BASH_ENV
source $BASH_ENV
environment:
JAVA_HOME: /Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home

- macos/preboot-simulator:
version: "17.4"
Expand Down Expand Up @@ -181,6 +205,28 @@ jobs:
- store_test_results:
path: _test_results

test:
executor: base
steps:
- attach_workspace:
at: ~/player

- run: |
bazel test --config=ci -- $(bazel query 'kind(".*_test", //...) except filter("ios|swiftui", //...)') -//android/demo:android_instrumentation_test
- run:
when: always
command: |
RESULTS_DIR=_test_results
find -L ./bazel-testlogs -name test.xml | while read line
do
mkdir -p $RESULTS_DIR/$(dirname $line)
cp $line $RESULTS_DIR/$(dirname $line)
done
- store_test_results:
path: _test_results

android_test:
executor: android
steps:
Expand All @@ -199,10 +245,17 @@ jobs:
sudo ln -s /opt/bazelisk-v1.11.0/bazelisk /usr/local/bin/bazel
- run:
name: Create avd
name: Install Android tools
command: |
sdkmanager "system-images;android-29;default;x86"
echo "no" | avdmanager --verbose create avd -n test -k "system-images;android-29;default;x86"
rm -rf $ANDROID_HOME/build-tools/*
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 \
$ANDROID_HOME/tools/bin/sdkmanager "build-tools;33.0.1"\
"ndk;23.2.8568313" \
"system-images;android-33;default;x86_64"
echo "export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/23.2.8568313" >> $BASH_ENV
source $BASH_ENV
echo "no" | avdmanager --verbose create avd -n test -k "system-images;android-33;default;x86_64" -g default
source $BASH_ENV
- run:
name: Launch emulator
Expand Down Expand Up @@ -248,7 +301,7 @@ jobs:
# union the bundle targets until //... doesnt explode analyzing jvm/android targets
- run: |
BUNDLE_TARGETS=$(bazel query "kind(js_test, //plugins/...) union kind(js_test, //react/...) union kind(js_test, //core/...)" --output label 2>/dev/null | tr '\n' ' ')
bazel coverage --combined_report=lcov --config=ci -- $BUNDLE_TARGETS -//plugins/reference-assets/mocks:all_flows_test_binary
bazel coverage --combined_report=lcov --config=ci -- $BUNDLE_TARGETS
- run:
when: always
Expand Down Expand Up @@ -351,6 +404,24 @@ workflows:
- build-trunk
- build-ios-trunk

- test:
name: test-trunk
filters:
branches:
ignore:
- /pull\/.*/
requires:
- build-trunk

- test:
name: test-fork
filters:
branches:
only:
- /pull\/.*/
requires:
- build-fork

- android_test:
name: android-test-trunk
filters:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@ ios/*/*/Resources/**/*.js
.ios-build-number

.bazelrc.local
_ios_coverage/
27 changes: 25 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ load("@rules_player//ios:defs.bzl", "assemble_pod")
load("@rules_player//internal:defs.bzl", "stamp")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@bazel_gazelle//:def.bzl", "gazelle_binary")
load("@bazel_gazelle//:def.bzl", "gazelle_binary", "gazelle")
load("@rules_swift_package_manager//swiftpkg:defs.bzl", "swift_update_packages")
load("@bazel_tools//tools/jdk:default_java_toolchain.bzl", "default_java_toolchain")

package(default_visibility = ["//visibility:public"])

Expand Down Expand Up @@ -242,5 +243,27 @@ swift_update_packages(
update_bzlmod_stanzas = False,
)

# This target updates the Bazel build files for your project. Run this target
# whenever you add or remove source files from your project.
gazelle(
name = "update_build_files",
gazelle = ":gazelle_bin",
)

alias(
name = "android_tools",
actual = "@bazel_tools//src/tools/android/java/com/google/devtools/build/android:all_android_tools",
visibility = ["//visibility:public"],
)

java_plugin(
name = "compiler_annotation_processor",
generates_api = False,
processor_class = "android.databinding.annotationprocessor.ProcessDataBinding",
visibility = ["//visibility:public"],
deps = [
":android_tools",
],
)
#SwiftLint
exports_files([".swiftlint.yml"])
exports_files([".swiftlint.yml"])
Loading

0 comments on commit 0eca6b6

Please sign in to comment.