Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb48324c

Browse files
hvadehracopybara-github
authored andcommitted
Run some Bazel tests onrules_java presubmits
This should help catch (most) issues sooner and hopefully obviate the need to make Bazel PRs with unreleased `rules_java` archives.This will also come in handy when migrating the rules out of `@builtins`.For now, this is only for linux. I'll add testing on other platforms as a followup.PiperOrigin-RevId: 595654881Change-Id: I71d98e94921996155a3d9c68d89df2c1ab938409
1 parent3abfbb8 commitb48324c

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

‎.bazel_checkout/__README‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This directory exists just so we can clone Bazel sources and run tests on presubmit
2+
3+
At some point, we should migrate the tests we care about, out of Bazel and into
4+
rules_java.

‎.bazel_checkout/setup.sh‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
set -x
4+
5+
FAKE_BCR_ROOT=$(mktemp -d --tmpdir fake-bcr.XXX)
6+
FAKE_RULES_JAVA_ROOT=${FAKE_BCR_ROOT}/modules/rules_java
7+
FAKE_MODULE_VERSION=9999
8+
FAKE_MODULE_ROOT=${FAKE_RULES_JAVA_ROOT}/${FAKE_MODULE_VERSION}
9+
FAKE_ARCHIVE=${FAKE_MODULE_ROOT}/rules_java.tar.gz
10+
mkdir -p${FAKE_MODULE_ROOT}
11+
12+
# relying on the line number is not great, but :shrugs:
13+
sed -e"3 c version =\"${FAKE_MODULE_VERSION}\"," ../MODULE.bazel>${FAKE_MODULE_ROOT}/MODULE.bazel
14+
15+
tar zcf${FAKE_ARCHIVE} ../
16+
RULES_JAVA_INTEGRITY_SHA256=`cat${FAKE_ARCHIVE}| openssl dgst -sha256 -binary| base64`
17+
cat<<EOF >${FAKE_MODULE_ROOT}/source.json
18+
{
19+
"integrity": "sha256-${RULES_JAVA_INTEGRITY_SHA256}",
20+
"strip_prefix": "",
21+
"url": "file://${FAKE_ARCHIVE}"
22+
}
23+
EOF
24+
25+
# fetch and setup bazel sources
26+
git init
27+
git remote add origin https://github.com/bazelbuild/bazel.git
28+
git pull origin master
29+
sed -i.bak -e's/^# android_sdk_repository/android_sdk_repository/' \
30+
-e's/^# android_ndk_repository/android_ndk_repository/' \
31+
WORKSPACE.bzlmod
32+
rm -f WORKSPACE.bzlmod.bak
33+
rm -rf$HOME/bazeltest
34+
mkdir$HOME/bazeltest
35+
36+
echo"common --registry=https://bcr.bazel.build">> .bazelrc
37+
echo"common --registry=file://${FAKE_BCR_ROOT}">> .bazelrc
38+
echo"add_to_bazelrc\"common --registry=https://bcr.bazel.build\"">> src/test/shell/testenv.sh.tmpl
39+
echo"add_to_bazelrc\"common --registry=file://${FAKE_BCR_ROOT}\"">> src/test/shell/testenv.sh.tmpl
40+
41+
SED_CMD="s/bazel_dep(name =\"rules_java\".*/bazel_dep(name =\"rules_java\", version =\"${FAKE_MODULE_VERSION}\")/"
42+
sed -i"${SED_CMD}" MODULE.bazel
43+
sed -i"${SED_CMD}" src/MODULE.tools
44+
45+
BAZEL_QUIET_MODE_ARGS="--ui_event_filters=error,fail"
46+
47+
bazel run${BAZEL_QUIET_MODE_ARGS} //src/test/tools/bzlmod:update_default_lock_file -- \
48+
--registry="https://bcr.bazel.build" --registry="file://${FAKE_BCR_ROOT}"${BAZEL_QUIET_MODE_ARGS}
49+
bazel mod deps --lockfile_mode=update
50+
# populate repo cache so tests don't need to access network
51+
bazel fetch --config=ci-linux --all${BAZEL_QUIET_MODE_ARGS}

‎.bazelci/presubmit.yml‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,30 @@ tasks:
4949
build_flags:
5050
-"--config=bzlmod"
5151
build_targets:*build_targets_bzlmod
52+
ubuntu2004_bazel_tests:
53+
environment:
54+
USE_BAZEL_DIFF:""
55+
platform:ubuntu2004
56+
working_directory:.bazel_checkout
57+
shell_commands:
58+
-sh setup.sh
59+
build_flags:
60+
-"--config=ci-linux"
61+
test_flags:
62+
-"--config=ci-linux"
63+
build_targets:
64+
-"//:bazel-distfile.zip"
65+
-"//scripts/packages/debian:bazel-debian.deb"
66+
-"//scripts/packages:with-jdk/install.sh"
67+
-"//src:bazel"
68+
-"//src:bazel_jdk_minimal"
69+
-"//src:test_repos"
70+
-"//src/main/java/..."
71+
test_targets:
72+
-"//src/java_tools/..."
73+
-"//src/test/java/com/google/devtools/build/lib/rules/java/..."
74+
-"//src/test/java/com/google/devtools/build/lib/view/java/..."
75+
-"//src/test/shell/bazel:bazel_java_test"
76+
-"//src/test/shell/bazel:bazel_coverage_java_test"
77+
# Re-enable once fixed: https://github.com/bazelbuild/bazel/issues/8162
78+
-"-//src/java_tools/import_deps_checker/..."

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp