Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/bazel-6' into async-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
hborawski committed Apr 12, 2024
2 parents 5646741 + cdbff07 commit ac88f3d
Show file tree
Hide file tree
Showing 188 changed files with 8,794 additions and 10,339 deletions.
11 changes: 5 additions & 6 deletions .bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ profile
DerivedData
*.hmap
*.ipa
xcode/Pods/
CoverageData/
bep.json
xcui.json
ios/*/*/Resources/**/*.js

core/make-flow/node_modules
core/types/node_modules
Expand Down Expand Up @@ -63,4 +58,8 @@ plugins/reference-assets/core/node_modules
plugins/reference-assets/react/node_modules
plugins/shared-constants/core/node_modules
plugins/stage-revert-data/core/node_modules
tools/asset-testing-library/core/node_modules
tools/asset-testing-library/core/node_modules
docs/storybook/node_modules
plugins/reference-assets/mocks/node_modules
tools/addon-storybook/node_modules
tools/components/node_modules
13 changes: 1 addition & 12 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ mobile-install --start=warm

build:ci --build_metadata=ROLE=CI --workspace_status_command=./scripts/workspace-status.sh

# Circle large has 4 CPU cores/8GB mem
# Circle xlarge has 8 CPU cores/16GB mem
build:ci --local_cpu_resources=8
build:ci --local_ram_resources=15000
build:ci --config="release"
Expand All @@ -62,17 +62,6 @@ build:release --stamp --workspace_status_command=./scripts/workspace-status.sh
# Cache action outputs on disk so they persist across output_base and bazel shutdown (eg. changing branches)
# build --disk_cache=~/.cache/bazel-disk-cache

build:skip-ios -- \
-//:PlayerUI \
-//:PlayerUI_Pod \
-//:PlayerUI-Demo \
-//:PlayerUI-Unit-Unit \
-//:PlayerUI-Unit-Unit.__internal__.__test_bundle \
-//:PlayerUI-UI-ViewInspectorTests \
-//:PlayerUI-UI-ViewInspectorTests.__internal__.__test_bundle \
-//:PlayerUI-UI-XCUITests \
-//:PlayerUI-UI-XCUITests.__internal__.__test_bundle

# Support for debugging NodeJS tests
# Add the Bazel option `--config=debug` to enable this
# --test_output=streamed
Expand Down
108 changes: 44 additions & 64 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ executors:
TZ: "/usr/share/zoneinfo/America/Los_Angeles"
ios:
working_directory: ~/player
resource_class: macos.x86.medium.gen2
resource_class: macos.m1.large.gen1
macos:
xcode: 14.3
xcode: 15.3.0
environment:
TZ: "/usr/share/zoneinfo/America/Los_Angeles"
android:
Expand Down Expand Up @@ -93,8 +93,8 @@ jobs:
steps:
- attach_workspace:
at: ~/player

- run: bazel build --config=ci --config=skip-ios -- //...
- run: bazel query '//... except filter("ios|swiftui", //...)'
- run: bazel build --config=ci -- $(bazel query '//... except filter("ios|swiftui", //...)')

- save_cache:
paths:
Expand All @@ -115,70 +115,38 @@ jobs:
- run:
name: Homebrew Dependencies
command: |
HOMEBREW_NO_AUTO_UPDATE=1 brew install bazelisk maven openjdk@8
- run:
name: Set Ruby Version
command: |
rbenv install 2.6.10
rbenv global 2.6.10
rbenv rehash
- 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/21.4.7075529' >> $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: /usr/local/opt/openjdk@8

- save_cache:
key: android-tools-{{ arch }}-{{ checksum "scripts/install-android-tools.sh" }}
paths:
- ~/android-tools

- run: gem install bundler

- restore_cache:
keys:
- gem-v1-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
- gem-v1-{{ arch }}-main-{{ checksum "Gemfile.lock" }}

- run: bundle install

- save_cache:
key: gem-v1-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
paths:
- ~/.gem/ruby/2.7.5
HOMEBREW_NO_AUTO_UPDATE=1 brew install bazelisk maven openjdk@17 lcov
- macos/preboot-simulator:
version: "15.5"
version: "17.4"
platform: "iOS"
device: "iPhone 13"

- run: bazel sync
device: "iPhone 15"

- run: |
BUNDLE_TARGETS=$(bazel query "attr(name, '^.*_Bundles$', //...)" --output label 2>/dev/null | tr '\n' ' ')
bazel build --config=ci $BUNDLE_TARGETS
- run: bazel build --config=ci -- //ios/demo:PlayerUIDemo

- run: bazel shutdown
- run: cd xcode && bundle exec pod install
- run: bazel build --config=ci -- //:PlayerUI //:PlayerUI-Demo //:PlayerUI_Pod
# TODO: the timeout should be added to the test itself
- run: bazel test --test_env=APPLITOOLS_API_KEY=${APPLITOOLS_API_KEY} --test_env=APPLITOOLS_BATCH_ID=${CIRCLE_SHA1} --test_env=APPLITOOLS_PR_NUMBER=${CIRCLE_PULL_REQUEST##*/} --test_timeout=1200 --jobs=1 --verbose_failures --config=ci -- //:PlayerUI-Unit-Unit //:PlayerUI-UI-ViewInspectorTests //:PlayerUI-UI-XCUITests
- run:
name: Test Prebuild
command: |
bazel build \
--config=ci \
$(bazel query "kind(ios_unit_test, //ios/...)") \
$(bazel query "kind(ios_unit_test, //plugins/...)") \
$(bazel query "kind(ios_ui_test, //ios/...)") \
$(bazel query "kind(ios_ui_test, //plugins/...)")
- run:
name: Tests
command: |
bazel coverage \
--config=ci \
--jobs=2 \
--experimental_use_llvm_covmap \
--combined_report=lcov \
--test_output=all \
--test_timeout=1800 \
$(bazel query "kind(ios_unit_test, //ios/...)") \
$(bazel query "kind(ios_unit_test, //plugins/...)") \
$(bazel query "kind(ios_ui_test, //ios/...)") \
$(bazel query "kind(ios_ui_test, //plugins/...)")
- run:
when: always
Expand All @@ -189,6 +157,18 @@ jobs:
mkdir -p $RESULTS_DIR/$(dirname $line)
cp $line $RESULTS_DIR/$(dirname $line)
done
- run:
when: always
command: |
mkdir -p _coverage/lcov
mkdir -p _coverage/html
cp -r $(bazel info output_path)/_coverage/_coverage_report.dat _coverage/lcov/
genhtml --branch-coverage --output-directory=_coverage/html/ "$(bazel info output_path)/_coverage/_coverage_report.dat"
zip -r _coverage/html.zip _coverage/html/
rm -r _coverage/html/
- store_artifacts:
path: _coverage

- store_test_results:
path: _test_results
Expand All @@ -199,7 +179,7 @@ jobs:
- attach_workspace:
at: ~/player

- run: bazel test --config=skip-ios --config=ci -- //... -//docs/site -//android/demo:android_instrumentation_test
- run: bazel test --config=ci -- $(bazel query '//... except filter("ios|swiftui", //...)') -//docs/site -//android/demo:android_instrumentation_test

- run:
when: always
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ xcui.json
#SPM
.build
.swiftpm
ios/Player.xcodeproj
ios/PlayerUI.xcodeproj

# Bundles used by cocoapods for development
ios/*/*/Resources/**/*.js
Expand Down
15 changes: 5 additions & 10 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# load("@rules_player//cocoapods:cocoapod.bzl", "assemble_pod", "pod_push")
# load("@rules_player//cocoapods:cocoapod.bzl", "pod_push")
# load("@rules_player//internal:stamp.bzl", "stamp")
# load("//:generated.bzl", "PlayerUI", "PlayerUI_Demo", "ui_tests", "unit_tests")
load("//tools/ios:util.bzl", "assemble_pod")

load("@npm//:defs.bzl", "npm_link_all_packages")
Expand Down Expand Up @@ -77,16 +76,12 @@ js_library(

js_library(
name = "typings",
srcs = ["tsconfig.build.json"] + glob(["typings/*"]),
srcs = [
"tsconfig.build.json",
"tsconfig.json",
] + glob(["typings/*"]),
visibility = ["//visibility:public"],
)
# PlayerUI(deps = [])

# PlayerUI_Demo(deps = [])

# unit_tests()

# ui_tests()

# # Update the version in the podspec
# stamp(
Expand Down
35 changes: 15 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ If the changes are larger (API design, architecture, etc), [opening an issue](ht
* [Android NDK >= 19.2.5345600, <= 21](https://github.com/android/ndk/wiki/Unsupported-Downloads#r19c). Any version > 21 will not work, period. You'll need to add `ANDROID_NDK_HOME` to your environment manually.

## Building and Testing Locally (All platforms)
#### Presetup
For iOS builds, some pre-setup is required for `bazel` to generate BUILD files for dependent CocoaPods.

```bash
bundle install
```
CocoaPods does not directly integrate with `bazel`, when core targets are updated, the output bundles need to be copied to the location described in the `PlayerUI.podspec`, to do so run the script:
```bash
./tools/build_ios_bundles.sh
```
This will query `bazel` for dependent targets, copy their output and regenerate the `.xcworkspace`.
### Player
For speed and consistency, this repo leverages `bazel` as it's main build tool. Check out the [bazel](https://bazel.build/) docs for more info.

Expand All @@ -47,20 +36,26 @@ Tests can also be ran using:
bazel test //...
```

#### Skipping iOS builds
The `.bazelrc` contains a convenience to build everything but the iOS targets, as the toolchain for those is platform specific.

```bash
bazel build --config=skip-ios
```

## For Android Only builds
If you are interested in only contributing for android, follow our [android guide](https://github.com/player-ui/player/android/demo/README.md)
If you are interested in only contributing for android, follow our [android guide](https://github.com/player-ui/player/blob/main/android/demo/README.md)

## For iOS Only builds
If you are interested in only contributing for iOS, follow our [iOS guide](https://github.com/player-ui/player)
### Xcode Project generation
Generate the `.xcodeproj` to open and work in Xcode. Builds and tests will be executed through bazel, to ensure behavioral parity.

```bash
bazel run //ios:xcodeproj
open -a Xcode ios/PlayerUI.xcodeproj/
```
### Demo Application
#### Xcode
The first time the Xcode project is generated, the default selected target is `PlayerUI`, for a runnable target select `PlayerUIDemo` to run the demo application in the simulator.

#### Bazel
The demo app can also be built and launched in a simulator from the command line with bazel:
```bash
bazel run //ios/demo:PlayerUIDemo
```

## Docs Sites
These require the [Android NDK](https://developer.android.com/ndk).
Expand Down
24 changes: 13 additions & 11 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ bazel_dep(name = "rules_player")

git_override(
remote = "https://github.com/player-ui/rules_player.git",
commit = "a1626024afabb38b9aca9981cc0e76b704d4fd77",
# bazel-6 branch
commit = "e71339c96deeec1f4976fbc04815143ee23d8541",
module_name = "rules_player",
)
# local_path_override(module_name = "rules_player", path = "../rules_player")

bazel_dep(name = "aspect_bazel_lib", version = "1.32.0")
bazel_dep(name = "aspect_rules_js", version = "1.34.0")
bazel_dep(name = "aspect_rules_js", version = "1.34.1")
bazel_dep(name = "bazel_skylib", version = "1.4.1")
bazel_dep(name = "rules_pkg", version = "0.9.1")
bazel_dep(name = "aspect_rules_ts", version = "2.1.0")
Expand All @@ -21,18 +22,17 @@ node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
node.toolchain(node_version = "18.18.0")
#################################


# iOS

bazel_dep(name = "rules_swift", version = "1.13.0", repo_name = "build_bazel_rules_swift")
###### Start iOS ######
## Rule Dependencies
bazel_dep(name = "rules_swift", version = "1.14.0", repo_name = "build_bazel_rules_swift")
bazel_dep(name = "rules_apple", version = "3.1.1", repo_name = "build_bazel_rules_apple")
bazel_dep(name = "rules_ios", version = "3.1.4", repo_name = "build_bazel_rules_ios")
bazel_dep(name = "rules_xcodeproj", version = "1.13.0")

bazel_dep(name = "gazelle", version = "0.34.0", repo_name = "bazel_gazelle")
bazel_dep(name = "rules_swift_package_manager", version = "0.22.0")

# swift_deps START
## This section is handled by rules_swift_package_manager
swift_deps = use_extension(
"@rules_swift_package_manager//:extensions.bzl",
"swift_deps",
Expand All @@ -41,14 +41,16 @@ swift_deps.from_file(
deps_index = "//:swift_deps_index.json",
)

## SPM Dependencies
### need to be listed here to be available as a target in BUILD files
### Add dependency in xcode/Package.swift and then run `bazel run //:update_swift_pkgs`
### before adding it here
use_repo(
swift_deps,
"swiftpkg_swift_hooks",
"swiftpkg_viewinspector",
"swiftpkg_eyes_xcui_swift_package"
"swiftpkg_viewinspector"
)

# end iOS
###### End iOS ######
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")

npm.npm_translate_lock(
Expand Down
17 changes: 0 additions & 17 deletions babel.config.js

This file was deleted.

3 changes: 0 additions & 3 deletions core/player/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,5 @@
"@player-ui/partial-match-registry": "workspace:*",
"@player-ui/make-flow": "workspace:*",
"@player-ui/types": "workspace:*"
},
"devDependencies": {
"@player-ui/common-types-plugin": "workspace:*"
}
}
1 change: 0 additions & 1 deletion core/player/src/binding-grammar/custom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export const parse: Parser = (path) => {

ch = path.charAt(index);
index += 1;
// console.log(`Index: ${index} Char: ${ch}`);
return ch;
};

Expand Down
1 change: 0 additions & 1 deletion core/player/src/binding-grammar/ebnf/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ export const parse: Parser = (path) => {
}

if (ast.errors.length > 0) {
// console.log(ast.errors);
return {
status: false,
error: ast.errors[0].message,
Expand Down
Loading

0 comments on commit ac88f3d

Please sign in to comment.