Skip to content

Commit

Permalink
[infra] Convert examples to bazel integration tests (#1183)
Browse files Browse the repository at this point in the history
* [infra] Convert examples to bazel integration tests
* exclude bazel 8 until android_local_test is finished
  • Loading branch information
restingbull authored Sep 7, 2024
1 parent 6d30df2 commit cff2e6f
Show file tree
Hide file tree
Showing 47 changed files with 697 additions and 329 deletions.
184 changes: 24 additions & 160 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
---
matrix:
unittest_platform:
- ubuntu2004
- ubuntu1804
integration_platform:
- ubuntu2004
- ubuntu1804
# - macos
# - windows re-enable when rules_bazel_integration_test can support custom test runner on windows.
test_flags:
- ["--enable_bzlmod=true"]
- ["--enable_bzlmod=false"]
validate_config: 1
bazel: 880c17c67a9b4e17e9753a5c6e2a759bff5a2cfe
bazel: 7.1.1
buildifier:
version: 7.1.1
# no lint warnings for the moment. They are basically a smoke alarm in hell.
# keep this argument in sync with .pre-commit-config.yaml
warnings: "-confusing-name,-constant-glob,-duplicated-name,-function-docstring,-function-docstring-args,-function-docstring-header,-module-docstring,-name-conventions,-no-effect,-constant-glob,-provider-params,-print,-rule-impl-return,-bzl-visibility,-unnamed-macro,-uninitialized,-unreachable"
tasks:
ubuntu1804:
name: "Tests without Bzlmod (Ubuntu 18.04)"
build_flags:
- "--enable_bzlmod=false"
test_flags:
- "--enable_bzlmod=false"
unittests:
name: "Unit Tests"
platform: ${{ unittest_platform }}
build_flags: ${{ test_flags }}
test_flags: ${{ test_flags }}
test_targets:
- "//:all_tests"
build_targets:
- "//:rules_kotlin_release"
ubuntu2004_bzlmod:
name: "Tests (Ubuntu 20.04)"
platform: ubuntu2004
test_targets:
- "//:all_tests"
build_targets:
- "//:rules_kotlin_release"
macos:
name: "Tests (Latest Macos)"
integration_tests:
name: "Integration Tests"
platform: ${{ integration_platform }}
test_flags:
- "--enable_bzlmod=true"
test_targets:
- "//:all_tests"
build_targets:
- "//:rules_kotlin_release"
- //examples:all
rbe_ubuntu1604:
build_flags:
- "--enable_bzlmod=false"
Expand All @@ -48,147 +53,6 @@ tasks:
# cannot be used with remote builds)
- "--strategy=KotlinCompile=remote"
- "--config=rbe"
# TODO: Enable these tests once this example is building against the release rules_kotlin binary
# example-android-5.x:
# name: "Example - Android using Bazel 5.x"
# platform: ubuntu1804
# working_directory: examples/android
# bazel: 5.4.1
# test_targets:
# - //app:all
example-android-6.x:
name: "Example - Android using Bazel 6.x"
platform: ubuntu1804
working_directory: examples/android
bazel: 6.4.0
test_flags:
- "--enable_bzlmod=false"
test_targets:
- //app:all
example-android:
name: "Example - Android"
platform: ubuntu1804
working_directory: examples/android
bazel: 8.0.0-pre.20240206.3
test_flags:
- "--incompatible_enable_android_toolchain_resolution"
- "--android_platforms=//:arm64-v8a"
- "--enable_bzlmod=false"
test_targets:
- //app:all
example-bzlmod-android:
name: "Example Bzlmod - Android"
platform: ubuntu1804
working_directory: examples/android
bazel: 8.0.0-pre.20240206.3
test_flags:
- "--incompatible_enable_android_toolchain_resolution"
- "--android_platforms=//:arm64-v8a"
- "--enable_bzlmod=true"
test_targets:
- //app:all
example-ksp:
name: "Example - Android KSP"
platform: ubuntu1804
working_directory: examples/ksp
test_targets:
- //...
example-associates:
name: "Example - Associates"
platform: ubuntu1804
working_directory: examples/associates
test_targets:
- //...
example-anvil:
name: "Example - Anvil"
platform: ubuntu1804
working_directory: examples/anvil
bazel: 8.0.0-pre.20240206.3
test_flags:
- "--incompatible_enable_android_toolchain_resolution"
- "--android_platforms=//:arm64-v8a"
test_targets:
- //app:all
example-plugins:
name: "Example - Plugins"
platform: ubuntu1804
working_directory: examples/plugin
test_targets:
- //...
example-multiplex:
name: "Example - Multiplex"
platform: ubuntu1804
working_directory: examples/multiplex
build_flags:
- "--enable_bzlmod=false"
build_targets:
- //...
example-bzlmod-multiplex:
name: "Example Bzlmod - Multiplex"
platform: ubuntu1804
working_directory: examples/multiplex
build_flags:
- "--enable_bzlmod=true"
build_targets:
- //...
examples-trivial-ubuntu1804:
name: "Example - Trivial (Ubuntu 18.04)"
platform: ubuntu1804
working_directory: examples/trivial
include_json_profile:
- build
- test
build_targets:
- //...
test_targets:
- //...
examples-trivial-bzlmod-ubuntu1804:
name: "Example - Trivial Bzlmod (Ubuntu 18.04)"
platform: ubuntu1804
working_directory: examples/trivial
build_flags:
- "--enable_bzlmod=true"
test_flags:
- "--enable_bzlmod=true"
include_json_profile:
- build
- test
build_targets:
- //...
test_targets:
- //...
examples-trivial-windows:
name: "Example - Trivial (Windows)"
platform: windows
working_directory: examples/trivial
include_json_profile:
- build
- test
build_targets:
- //...
test_flags:
- "--enable_runfiles"
test_targets:
- //...
examples-dagger:
name: "Example - Dagger"
platform: ubuntu1804
working_directory: examples/dagger
include_json_profile:
- build
- test
build_targets:
- //...
example-jetpack-compose:
name: "Example - Jetpack Compose"
platform: ubuntu1804
working_directory: examples/jetpack_compose
bazel: 8.0.0-pre.20240206.3
test_flags:
- "--incompatible_enable_android_toolchain_resolution"
- "--android_platforms=//:arm64-v8a"
test_targets:
- //app:all
stardoc:
name: Stardoc api documentation
platform: ubuntu1804
Expand Down
2 changes: 0 additions & 2 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
# Exclude examples from //...:all
examples
6 changes: 6 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ build --strategy=KotlinCompile=worker
build --test_output=all
build --verbose_failures

# Required for windows ci
startup --windows_enable_symlinks
common --enable_runfiles

try-import %workspace%/bit-ignore.bazelrc

# User-specific .bazelrc
try-import %workspace%/user.bazelrc
10 changes: 10 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,13 @@ release_archive(
"//third_party:pkg",
],
)

# This target collects all of the parent workspace files needed by the child workspaces.
filegroup(
name = "release_repositories",
# Include every package that is required by the child workspaces.
srcs = [
":rules_kotlin_release",
],
visibility = ["//:__subpackages__"],
)
23 changes: 19 additions & 4 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "rules_java", version = "7.2.0")
bazel_dep(name = "rules_python", version = "0.23.1")
bazel_dep(name = "rules_cc", version = "0.0.8")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_android", version = "0.1.1")

rules_kotlin_extensions = use_extension("//src/main/starlark/core/repositories:bzlmod_setup.bzl", "rules_kotlin_extensions")
Expand All @@ -18,6 +18,7 @@ use_repo(
"buildkite_config",
"com_github_google_ksp",
"com_github_jetbrains_kotlin",
"com_github_jetbrains_kotlin_git",
"com_github_pinterest_ktlint",
"released_rules_kotlin",
)
Expand Down Expand Up @@ -59,23 +60,23 @@ maven.install(
"com.google.protobuf:protobuf-java-util:3.6.0",
"com.google.guava:guava:27.1-jre",
"com.google.truth:truth:0.45",
"com.google.auto.service:auto-service:1.0.1",
"com.google.auto.service:auto-service-annotations:1.0.1",
"com.google.auto.service:auto-service:1.1.1",
"com.google.auto.service:auto-service-annotations:1.1.1",
"com.google.auto.value:auto-value:1.10.1",
"com.google.auto.value:auto-value-annotations:1.10.1",
"com.google.dagger:dagger:2.51",
"com.google.dagger:dagger-compiler:2.51",
"com.google.dagger:dagger-producers:2.51",
"javax.annotation:javax.annotation-api:1.3.2",
"javax.inject:javax.inject:1",
"org.apache.commons:commons-compress:1.26.2",
"org.pantsbuild:jarjar:1.7.2",
"org.jetbrains.kotlinx:atomicfu-js:0.15.2",
"org.jetbrains.kotlinx:kotlinx-serialization-runtime:1.0-M1-1.4.0-rc",
"dev.zacsweers.autoservice:auto-service-ksp:jar:1.1.0",
"com.squareup.moshi:moshi:1.15.0",
"com.squareup.moshi:moshi-kotlin:1.15.0",
"com.squareup.moshi:moshi-kotlin-codegen:1.15.0",
"com.google.auto.service:auto-service-annotations:jar:1.1.1",
],
fail_if_repin_required = True,
fetch_sources = True,
Expand All @@ -93,3 +94,17 @@ bazel_dep(name = "stardoc", version = "0.5.6", repo_name = "io_bazel_stardoc")
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")

bazel_dep(name = "rules_testing", version = "0.5.0", dev_dependency = True)
bazel_dep(name = "rules_bazel_integration_test", version = "0.25.0", dev_dependency = True)

bazel_binaries = use_extension("@rules_bazel_integration_test//:extensions.bzl", "bazel_binaries", dev_dependency = True)
bazel_binaries.download(version_file = "//:.bazelversion")
bazel_binaries.download(version = "6.4.0")
bazel_binaries.download(version = "8.0.0-pre.20240206.3")
use_repo(
bazel_binaries,
"bazel_binaries",
"bazel_binaries_bazelisk",
"build_bazel_bazel_.bazelversion",
"build_bazel_bazel_6_4_0",
"build_bazel_bazel_8_0_0-pre_20240206_3",
)
Loading

0 comments on commit cff2e6f

Please sign in to comment.