Skip to content

Commit cff2e6f

Browse files
authored
[infra] Convert examples to bazel integration tests (#1183)
* [infra] Convert examples to bazel integration tests * exclude bazel 8 until android_local_test is finished
1 parent 6d30df2 commit cff2e6f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+697
-329
lines changed

.bazelci/presubmit.yml

+24-160
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,40 @@
11
---
2+
matrix:
3+
unittest_platform:
4+
- ubuntu2004
5+
- ubuntu1804
6+
integration_platform:
7+
- ubuntu2004
8+
- ubuntu1804
9+
# - macos
10+
# - windows re-enable when rules_bazel_integration_test can support custom test runner on windows.
11+
test_flags:
12+
- ["--enable_bzlmod=true"]
13+
- ["--enable_bzlmod=false"]
214
validate_config: 1
3-
bazel: 880c17c67a9b4e17e9753a5c6e2a759bff5a2cfe
15+
bazel: 7.1.1
416
buildifier:
517
version: 7.1.1
618
# no lint warnings for the moment. They are basically a smoke alarm in hell.
719
# keep this argument in sync with .pre-commit-config.yaml
820
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"
921
tasks:
10-
ubuntu1804:
11-
name: "Tests without Bzlmod (Ubuntu 18.04)"
12-
build_flags:
13-
- "--enable_bzlmod=false"
14-
test_flags:
15-
- "--enable_bzlmod=false"
22+
unittests:
23+
name: "Unit Tests"
24+
platform: ${{ unittest_platform }}
25+
build_flags: ${{ test_flags }}
26+
test_flags: ${{ test_flags }}
1627
test_targets:
1728
- "//:all_tests"
1829
build_targets:
1930
- "//:rules_kotlin_release"
20-
ubuntu2004_bzlmod:
21-
name: "Tests (Ubuntu 20.04)"
22-
platform: ubuntu2004
23-
test_targets:
24-
- "//:all_tests"
25-
build_targets:
26-
- "//:rules_kotlin_release"
27-
macos:
28-
name: "Tests (Latest Macos)"
31+
integration_tests:
32+
name: "Integration Tests"
33+
platform: ${{ integration_platform }}
34+
test_flags:
35+
- "--enable_bzlmod=true"
2936
test_targets:
30-
- "//:all_tests"
31-
build_targets:
32-
- "//:rules_kotlin_release"
37+
- //examples:all
3338
rbe_ubuntu1604:
3439
build_flags:
3540
- "--enable_bzlmod=false"
@@ -48,147 +53,6 @@ tasks:
4853
# cannot be used with remote builds)
4954
- "--strategy=KotlinCompile=remote"
5055
- "--config=rbe"
51-
# TODO: Enable these tests once this example is building against the release rules_kotlin binary
52-
# example-android-5.x:
53-
# name: "Example - Android using Bazel 5.x"
54-
# platform: ubuntu1804
55-
# working_directory: examples/android
56-
# bazel: 5.4.1
57-
# test_targets:
58-
# - //app:all
59-
example-android-6.x:
60-
name: "Example - Android using Bazel 6.x"
61-
platform: ubuntu1804
62-
working_directory: examples/android
63-
bazel: 6.4.0
64-
test_flags:
65-
- "--enable_bzlmod=false"
66-
test_targets:
67-
- //app:all
68-
example-android:
69-
name: "Example - Android"
70-
platform: ubuntu1804
71-
working_directory: examples/android
72-
bazel: 8.0.0-pre.20240206.3
73-
test_flags:
74-
- "--incompatible_enable_android_toolchain_resolution"
75-
- "--android_platforms=//:arm64-v8a"
76-
- "--enable_bzlmod=false"
77-
test_targets:
78-
- //app:all
79-
example-bzlmod-android:
80-
name: "Example Bzlmod - Android"
81-
platform: ubuntu1804
82-
working_directory: examples/android
83-
bazel: 8.0.0-pre.20240206.3
84-
test_flags:
85-
- "--incompatible_enable_android_toolchain_resolution"
86-
- "--android_platforms=//:arm64-v8a"
87-
- "--enable_bzlmod=true"
88-
test_targets:
89-
- //app:all
90-
example-ksp:
91-
name: "Example - Android KSP"
92-
platform: ubuntu1804
93-
working_directory: examples/ksp
94-
test_targets:
95-
- //...
96-
example-associates:
97-
name: "Example - Associates"
98-
platform: ubuntu1804
99-
working_directory: examples/associates
100-
test_targets:
101-
- //...
102-
example-anvil:
103-
name: "Example - Anvil"
104-
platform: ubuntu1804
105-
working_directory: examples/anvil
106-
bazel: 8.0.0-pre.20240206.3
107-
test_flags:
108-
- "--incompatible_enable_android_toolchain_resolution"
109-
- "--android_platforms=//:arm64-v8a"
110-
test_targets:
111-
- //app:all
112-
example-plugins:
113-
name: "Example - Plugins"
114-
platform: ubuntu1804
115-
working_directory: examples/plugin
116-
test_targets:
117-
- //...
118-
example-multiplex:
119-
name: "Example - Multiplex"
120-
platform: ubuntu1804
121-
working_directory: examples/multiplex
122-
build_flags:
123-
- "--enable_bzlmod=false"
124-
build_targets:
125-
- //...
126-
example-bzlmod-multiplex:
127-
name: "Example Bzlmod - Multiplex"
128-
platform: ubuntu1804
129-
working_directory: examples/multiplex
130-
build_flags:
131-
- "--enable_bzlmod=true"
132-
build_targets:
133-
- //...
134-
examples-trivial-ubuntu1804:
135-
name: "Example - Trivial (Ubuntu 18.04)"
136-
platform: ubuntu1804
137-
working_directory: examples/trivial
138-
include_json_profile:
139-
- build
140-
- test
141-
build_targets:
142-
- //...
143-
test_targets:
144-
- //...
145-
examples-trivial-bzlmod-ubuntu1804:
146-
name: "Example - Trivial Bzlmod (Ubuntu 18.04)"
147-
platform: ubuntu1804
148-
working_directory: examples/trivial
149-
build_flags:
150-
- "--enable_bzlmod=true"
151-
test_flags:
152-
- "--enable_bzlmod=true"
153-
include_json_profile:
154-
- build
155-
- test
156-
build_targets:
157-
- //...
158-
test_targets:
159-
- //...
160-
examples-trivial-windows:
161-
name: "Example - Trivial (Windows)"
162-
platform: windows
163-
working_directory: examples/trivial
164-
include_json_profile:
165-
- build
166-
- test
167-
build_targets:
168-
- //...
169-
test_flags:
170-
- "--enable_runfiles"
171-
test_targets:
172-
- //...
173-
examples-dagger:
174-
name: "Example - Dagger"
175-
platform: ubuntu1804
176-
working_directory: examples/dagger
177-
include_json_profile:
178-
- build
179-
- test
180-
build_targets:
181-
- //...
182-
example-jetpack-compose:
183-
name: "Example - Jetpack Compose"
184-
platform: ubuntu1804
185-
working_directory: examples/jetpack_compose
186-
bazel: 8.0.0-pre.20240206.3
187-
test_flags:
188-
- "--incompatible_enable_android_toolchain_resolution"
189-
- "--android_platforms=//:arm64-v8a"
190-
test_targets:
191-
- //app:all
19256
stardoc:
19357
name: Stardoc api documentation
19458
platform: ubuntu1804

.bazelignore

-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
# Exclude examples from //...:all
2-
examples

.bazelrc

+6
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,11 @@ build --strategy=KotlinCompile=worker
77
build --test_output=all
88
build --verbose_failures
99

10+
# Required for windows ci
11+
startup --windows_enable_symlinks
12+
common --enable_runfiles
13+
14+
try-import %workspace%/bit-ignore.bazelrc
15+
1016
# User-specific .bazelrc
1117
try-import %workspace%/user.bazelrc

BUILD

+10
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,13 @@ release_archive(
7575
"//third_party:pkg",
7676
],
7777
)
78+
79+
# This target collects all of the parent workspace files needed by the child workspaces.
80+
filegroup(
81+
name = "release_repositories",
82+
# Include every package that is required by the child workspaces.
83+
srcs = [
84+
":rules_kotlin_release",
85+
],
86+
visibility = ["//:__subpackages__"],
87+
)

MODULE.bazel

+19-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ bazel_dep(name = "platforms", version = "0.0.10")
99
bazel_dep(name = "bazel_skylib", version = "1.7.1")
1010
bazel_dep(name = "rules_java", version = "7.2.0")
1111
bazel_dep(name = "rules_python", version = "0.23.1")
12-
bazel_dep(name = "rules_cc", version = "0.0.8")
12+
bazel_dep(name = "rules_cc", version = "0.0.9")
1313
bazel_dep(name = "rules_android", version = "0.1.1")
1414

1515
rules_kotlin_extensions = use_extension("//src/main/starlark/core/repositories:bzlmod_setup.bzl", "rules_kotlin_extensions")
@@ -18,6 +18,7 @@ use_repo(
1818
"buildkite_config",
1919
"com_github_google_ksp",
2020
"com_github_jetbrains_kotlin",
21+
"com_github_jetbrains_kotlin_git",
2122
"com_github_pinterest_ktlint",
2223
"released_rules_kotlin",
2324
)
@@ -59,23 +60,23 @@ maven.install(
5960
"com.google.protobuf:protobuf-java-util:3.6.0",
6061
"com.google.guava:guava:27.1-jre",
6162
"com.google.truth:truth:0.45",
62-
"com.google.auto.service:auto-service:1.0.1",
63-
"com.google.auto.service:auto-service-annotations:1.0.1",
63+
"com.google.auto.service:auto-service:1.1.1",
64+
"com.google.auto.service:auto-service-annotations:1.1.1",
6465
"com.google.auto.value:auto-value:1.10.1",
6566
"com.google.auto.value:auto-value-annotations:1.10.1",
6667
"com.google.dagger:dagger:2.51",
6768
"com.google.dagger:dagger-compiler:2.51",
6869
"com.google.dagger:dagger-producers:2.51",
6970
"javax.annotation:javax.annotation-api:1.3.2",
7071
"javax.inject:javax.inject:1",
72+
"org.apache.commons:commons-compress:1.26.2",
7173
"org.pantsbuild:jarjar:1.7.2",
7274
"org.jetbrains.kotlinx:atomicfu-js:0.15.2",
7375
"org.jetbrains.kotlinx:kotlinx-serialization-runtime:1.0-M1-1.4.0-rc",
7476
"dev.zacsweers.autoservice:auto-service-ksp:jar:1.1.0",
7577
"com.squareup.moshi:moshi:1.15.0",
7678
"com.squareup.moshi:moshi-kotlin:1.15.0",
7779
"com.squareup.moshi:moshi-kotlin-codegen:1.15.0",
78-
"com.google.auto.service:auto-service-annotations:jar:1.1.1",
7980
],
8081
fail_if_repin_required = True,
8182
fetch_sources = True,
@@ -93,3 +94,17 @@ bazel_dep(name = "stardoc", version = "0.5.6", repo_name = "io_bazel_stardoc")
9394
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")
9495

9596
bazel_dep(name = "rules_testing", version = "0.5.0", dev_dependency = True)
97+
bazel_dep(name = "rules_bazel_integration_test", version = "0.25.0", dev_dependency = True)
98+
99+
bazel_binaries = use_extension("@rules_bazel_integration_test//:extensions.bzl", "bazel_binaries", dev_dependency = True)
100+
bazel_binaries.download(version_file = "//:.bazelversion")
101+
bazel_binaries.download(version = "6.4.0")
102+
bazel_binaries.download(version = "8.0.0-pre.20240206.3")
103+
use_repo(
104+
bazel_binaries,
105+
"bazel_binaries",
106+
"bazel_binaries_bazelisk",
107+
"build_bazel_bazel_.bazelversion",
108+
"build_bazel_bazel_6_4_0",
109+
"build_bazel_bazel_8_0_0-pre_20240206_3",
110+
)

0 commit comments

Comments
 (0)