Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 47 additions & 25 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,44 @@
---
# Common task configurations.
.unittests: &unittests
build_flags: ${{ test_flags }}
test_flags: ${{ test_flags }}
test_targets:
- "//src/..."
build_targets:
- "//src/..."

.integration_tests: &integration_tests
name: "Integration Tests"
platform: ${{ platform.name }}
environment:
ANDROID_NDK_HOME: ${{ platform.android_ndk_home }}
test_flags: ${{ integration_shard_flags }}
test_targets:
- //examples:all

# Common platform configurations.
.ubuntu2404: &ubuntu2404
platform: ubuntu2404
environment:
ANDROID_NDK_HOME: /opt/android-ndk-r25b

.ubuntu2204: &ubuntu2204
platform: ubuntu2204
environment:
ANDROID_NDK_HOME: /opt/android-ndk-r25b

.macos: &macos
platform: macos
environment:
ANDROID_NDK_HOME: /Users/buildkite/android-ndk-r25b

# bazelci pipeline
matrix:
unittest_platform:
- ubuntu2404
- ubuntu2204
integration_platform:
- ubuntu2404
- ubuntu2204
integration_shard_flags:
- ["--test_tag_filters=shard_0", "--config=rbe"]
- ["--test_tag_filters=shard_1", "--config=rbe"]
- ["--test_tag_filters=shard_2", "--config=rbe"]
# - macos
# - windows re-enable when rules_bazel_integration_test can support custom test runner on windows.
test_flags:
- ["--enable_bzlmod=true"]
validate_config: 1
Expand All @@ -22,21 +49,16 @@ buildifier:
# 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:
unittests:
name: "Unit Tests"
platform: ${{ unittest_platform }}
build_flags: ${{ test_flags }}
test_flags: ${{ test_flags }}
test_targets:
- "//src/..."
build_targets:
- "//src/..."
integration_tests:
name: "Integration Tests"
platform: ${{ integration_platform }}
test_flags: ${{ integration_shard_flags }}
test_targets:
- //examples:all
macos_unittests:
<<: [ *macos, *unittests ]
ubuntu2404_unittests:
<<: [*ubuntu2404, *unittests]
ubuntu2404_integration_tests:
<<: [*ubuntu2404, *integration_tests]
ubuntu2204_unittests:
<<: [*ubuntu2204, *unittests]
ubuntu2204_integration_tests:
<<: [*ubuntu2204, *integration_tests]
rbe_ubuntu1604:
test_targets:
- "--"
Expand All @@ -52,7 +74,7 @@ tasks:
- "--strategy=KotlinCompile=remote"
stardoc:
name: Stardoc api documentation
platform: ubuntu2404
<<: *ubuntu2404
build_flags:
- "--enable_bzlmod=true"
build_targets:
Expand All @@ -61,7 +83,7 @@ tasks:
- //docs:are_docs_up_to_date_test
ktlint:
name: KtLint
platform: ubuntu2404
<<: *ubuntu2404
test_targets:
- //...
test_flags:
Expand Down
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
common --enable_bzlmod=true
common --incompatible_use_plus_in_repo_names
common --incompatible_disallow_empty_glob=false

common --incompatible_disable_native_repo_rules=true
common:rbe --java_runtime_version=11
common:rbe --tool_java_runtime_version=11

Expand Down
3 changes: 0 additions & 3 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ test_suite(
# Release target.
release_archive(
name = "rules_kotlin_release",
srcs = [
"WORKSPACE.bzlmod",
],
src_map = {
"BUILD.release.bazel": "BUILD.bazel",
"MODULE.release.bazel": "MODULE.bazel",
Expand Down
14 changes: 13 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,19 @@ bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "rules_java", version = "8.9.0")
bazel_dep(name = "rules_python", version = "0.23.1")
bazel_dep(name = "rules_android", version = "0.6.4")
bazel_dep(name = "rules_android", version = "0.6.6")

remote_android_extensions = use_extension(
"@rules_android//bzlmod_extensions:android_extensions.bzl",
"remote_android_tools_extensions",
)
use_repo(remote_android_extensions, "android_tools")

android_sdk_repository_extension = use_extension("@rules_android//rules/android_sdk_repository:rule.bzl", "android_sdk_repository_extension")
use_repo(android_sdk_repository_extension, "androidsdk")

register_toolchains("@androidsdk//:all")

bazel_dep(name = "bazel_features", version = "1.25.0")
bazel_dep(name = "rules_shell", version = "0.4.1")

Expand Down
1 change: 0 additions & 1 deletion WORKSPACE.bzlmod

This file was deleted.

3 changes: 3 additions & 0 deletions examples/android/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ common --lockfile_mode=off
test --test_output=all
build --config=android_worker

common --incompatible_disable_native_repo_rules=true
common --incompatible_autoload_externally=

# Worker configuration
build:android_worker \
--worker_max_instances=auto \
Expand Down
7 changes: 7 additions & 0 deletions examples/android/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ use_repo(android_sdk_repository_extension, "androidsdk")

register_toolchains("@androidsdk//:sdk-toolchain", "@androidsdk//:all")

bazel_dep(name = "rules_android_ndk", version = "0.1.2")

android_ndk_repository_extension = use_extension("@rules_android_ndk//:extension.bzl", "android_ndk_repository_extension")
use_repo(android_ndk_repository_extension, "androidndk")

register_toolchains("@androidndk//:all")

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
name = "maven_rules_kotlin_example",
Expand Down
3 changes: 0 additions & 3 deletions examples/android/WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
android_sdk_repository(name = "androidsdk")

android_ndk_repository(name = "androidndk")
37 changes: 31 additions & 6 deletions src/test/starlark/core/plugin/kapt/kapt_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,51 @@ load("//kotlin/compiler:kapt.bzl", "kapt_compiler_plugin")
load("//src/test/starlark:case.bzl", "Want", "suite")
load("//src/test/starlark:truth.bzl", "flags_and_values_of")

def _normalize_path_with_cfg(file):
"""Attempts to normalize the file to standard configs.

This turns out to be necessary due to multiple transitions with testing.analysis_test.
"""
prefix = file.path.removesuffix(file.short_path)
segments = prefix.split("/")
if segments[0] == "bazel-out":
# not exactly reliable, but the current test rules perform several transitions making it
# difficult to validate if a file is actually where it should be.
if "exec" in segments[1]:
return "(exec) " + file.short_path
return "(target) " + file.short_path
if file.is_source:
return "(source) " + file.short_path

return file.path

def _action(env, got):
got_target = env.expect.that_target(got)

inputs = []
want_inputs = {}
for i in env.ctx.attr.exec_inputs:
if JavaInfo in i:
for jo in i[JavaInfo].java_outputs:
inputs.append(jo.compile_jar)
want_inputs[_normalize_path_with_cfg(jo.compile_jar)] = True
else:
inputs.extend(i[DefaultInfo].files.to_list())
for f in i[DefaultInfo].files.to_list():
want_inputs[_normalize_path_with_cfg(f)] = True
for i in env.ctx.attr.target_inputs:
if JavaInfo in i:
for jo in i[JavaInfo].java_outputs:
inputs.append(jo.compile_jar)
want_inputs[_normalize_path_with_cfg(jo.compile_jar)] = True
else:
inputs.extend(i[DefaultInfo].files.to_list())
for f in i[DefaultInfo].files.to_list():
want_inputs[_normalize_path_with_cfg(f)] = True

compile = got_target.action_named(env.ctx.attr.mnemonic)

compile.contains_at_least_inputs(inputs)
got_inputs = {
_normalize_path_with_cfg(f): True
for f in compile.actual.inputs.to_list()
}

env.expect.that_collection(got_inputs.keys()).contains_at_least(want_inputs.keys())

got_target.runfiles().contains_at_least([
"/".join((env.ctx.workspace_name, f.short_path))
Expand Down