Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(bazel): simplify scripts and configuration in advance of additions #2918

Merged
merged 2 commits into from
Nov 21, 2024
Merged
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
12 changes: 9 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,21 @@ build --cxxopt -std=c++17
build --copt -Werror

# Common options for --config=ci
build:ci --action_env=CC=clang
build:ci --action_env=CXX=clang++
build:ci --curses=no
build:ci --color=no
build:ci --noshow_progress
build:ci --noshow_loading_progress
build:ci --show_timestamps
build:ci --terminal_columns=0
build:ci --verbose_failures
build:ci --test_output=errors

# When building with the address sanitizer
# E.g., bazel build --config asan
build:asan --repo_env CC=clang
build:asan --action_env=CC=clang
build:asan --action_env=CXX=clang++
build:asan --strip=never
build:asan --copt -fsanitize=address
build:asan --copt -DADDRESS_SANITIZER
Expand All @@ -55,7 +59,8 @@ build:asan --linkopt -fsanitize=address

# When building with the memory sanitizer
# E.g., bazel build --config msan
build:msan --repo_env CC=clang
build:msan --action_env=CC=clang
build:msan --action_env=CXX=clang++
build:msan --strip=never
build:msan --copt -fsanitize=memory
build:msan --copt -DADDRESS_SANITIZER
Expand All @@ -66,7 +71,8 @@ build:msan --linkopt -fsanitize=memory

# When building with the undefined behavior sanitizer
# E.g., bazel build --config ubsan
build:ubsan --repo_env CC=clang
build:ubsan --action_env=CC=clang
build:ubsan --action_env=CXX=clang++
build:ubsan --strip=never
build:ubsan --copt -fsanitize=undefined
build:ubsan --copt -g
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,32 @@ jobs:
run: |
tensorflow/lite/micro/tools/ci_build/test_bazel_asan.sh

# TODO(b/178621680): enable ubsan once bazel + clang + ubsan errors are fixed.
# bazel_ubsan:
# runs-on: ubuntu-latest
#
# name: Bazel ubsan (presubmit)
# steps:
# - uses: actions/setup-python@v4
# with:
# python-version: '3.10'
# - uses: actions/checkout@v3
# with:
# ref: ${{ inputs.trigger-sha }}
# - name: Install dependencies
# run: |
# sudo ci/install_bazelisk.sh
# pip3 install Pillow
# pip3 install numpy
# - name: Fix kernel mmap rnd bits
# # Asan in llvm 14 provided in ubuntu 22.04 is incompatible with
# # high-entropy ASLR in much newer kernels that GitHub runners are
# # using leading to random crashes: https://reviews.llvm.org/D148280
# run: sudo sysctl vm.mmap_rnd_bits=28
# - name: Test
# run: |
# tensorflow/lite/micro/tools/ci_build/test_bazel_ubsan.sh

cortex_m_bluepill_release:
runs-on: ubuntu-latest

Expand Down
3 changes: 3 additions & 0 deletions python/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ cc_test(
srcs = [
"cc_deps_link_test.cc",
],
tags = [
"nomsan", # avoid, because tensorflow library fails msan
],
deps = [
"@tensorflow_cc_deps//:cc_library",
],
Expand Down
3 changes: 3 additions & 0 deletions python/tflite_micro/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ sh_test(
":whl",
],
tags = [
"noasan",
"nomsan",
"notap", # See http://b/294278650#comment4 for more details.
"noubsan",
],
)
40 changes: 40 additions & 0 deletions python/tflite_micro/signal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ py_test(
srcs = ["ops/delay_op_test.py"],
python_version = "PY3",
srcs_version = "PY3",
tags = [
"noasan",
"nomsan",
"noubsan",
],
deps = [
":delay_op",
requirement("numpy"),
Expand Down Expand Up @@ -96,6 +101,11 @@ py_test(
],
python_version = "PY3",
srcs_version = "PY3",
tags = [
"noasan",
"nomsan",
"noubsan",
],
deps = [
":energy_op",
requirement("numpy"),
Expand Down Expand Up @@ -124,6 +134,11 @@ py_test(
],
python_version = "PY3",
srcs_version = "PY3",
tags = [
"noasan",
"nomsan",
"noubsan",
],
deps = [
":fft_ops",
requirement("numpy"),
Expand Down Expand Up @@ -158,6 +173,11 @@ py_test(
],
python_version = "PY3",
srcs_version = "PY3",
tags = [
"noasan",
"nomsan",
"noubsan",
],
deps = [
":filter_bank_ops",
requirement("numpy"),
Expand Down Expand Up @@ -186,6 +206,11 @@ py_test(
],
python_version = "PY3",
srcs_version = "PY3",
tags = [
"noasan",
"nomsan",
"noubsan",
],
deps = [
":framer_op",
requirement("numpy"),
Expand All @@ -211,6 +236,11 @@ py_test(
srcs = ["ops/overlap_add_op_test.py"],
python_version = "PY3",
srcs_version = "PY3",
tags = [
"noasan",
"nomsan",
"noubsan",
],
deps = [
":overlap_add_op",
"@absl_py//absl/testing:parameterized",
Expand Down Expand Up @@ -273,6 +303,11 @@ py_test(
],
python_version = "PY3",
srcs_version = "PY3",
tags = [
"noasan",
"nomsan",
"noubsan",
],
deps = [
":stacker_op",
requirement("numpy"),
Expand Down Expand Up @@ -300,6 +335,11 @@ py_test(
],
python_version = "PY3",
srcs_version = "PY3",
tags = [
"noasan",
"nomsan",
"noubsan",
],
deps = [
":window_op",
requirement("numpy"),
Expand Down
5 changes: 5 additions & 0 deletions python/tflite_micro/signal/utils/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ py_test(
],
python_version = "PY3",
srcs_version = "PY3",
tags = [
"noasan",
"nomsan",
"noubsan",
],
)

py_library(
Expand Down
19 changes: 2 additions & 17 deletions tensorflow/lite/micro/tools/ci_build/test_bazel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,5 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR=${SCRIPT_DIR}/../../../../..
cd "${ROOT_DIR}"

source tensorflow/lite/micro/tools/ci_build/helper_functions.sh

# We are using a bazel build followed by bazel test to make sure that the CI
# covers non-test binary targets as well. These were previousbly covered by
# having build_test but that was removed with #194.

CC=clang readable_run bazel build ... \
--config=ci \
--build_tag_filters=-no_oss
CC=clang readable_run bazel test ... \
--config=ci \
--test_tag_filters=-no_oss --build_tag_filters=-no_oss \
--test_output=errors

# TODO(b/178621680): enable ubsan once bazel + clang + ubsan errors are fixed.
#CC=clang readable_run bazel test tensorflow/lite/micro/... --config=ubsan --test_tag_filters=-no_oss,-noubsan --build_tag_filters=-no_oss,-noubsan

bazel test //... \
--config=ci
16 changes: 3 additions & 13 deletions tensorflow/lite/micro/tools/ci_build/test_bazel_asan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,8 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR=${SCRIPT_DIR}/../../../../..
cd "${ROOT_DIR}"

source tensorflow/lite/micro/tools/ci_build/helper_functions.sh

# We are using a bazel build followed by bazel test to make sure that the CI
# covers non-test binary targets as well. These were previousbly covered by
# having build_test but that was removed with #194.

CC=clang readable_run bazel build tensorflow/lite/micro/... \
--config=ci \
--config=asan --build_tag_filters=-no_oss,-noasan

CC=clang readable_run bazel test tensorflow/lite/micro/... \
bazel test //... \
--config=ci \
--config=asan \
--test_tag_filters=-no_oss,-noasan --build_tag_filters=-no_oss,-noasan \
--test_output=errors
--build_tag_filters=-noasan \
--test_tag_filters=-noasan
16 changes: 3 additions & 13 deletions tensorflow/lite/micro/tools/ci_build/test_bazel_msan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,8 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR=${SCRIPT_DIR}/../../../../..
cd "${ROOT_DIR}"

source tensorflow/lite/micro/tools/ci_build/helper_functions.sh

# We are using a bazel build followed by bazel test to make sure that the CI
# covers non-test binary targets as well. These were previousbly covered by
# having build_test but that was removed with #194.

CC=clang readable_run bazel build tensorflow/lite/micro/... \
--config=ci \
--config=msan --build_tag_filters=-no_oss,-nomsan

CC=clang readable_run bazel test tensorflow/lite/micro/... \
bazel test //... \
--config=ci \
--config=msan \
--test_tag_filters=-no_oss,-nomsan --build_tag_filters=-no_oss,-nomsan \
--test_output=errors
--build_tag_filters=-nomsan \
--test_tag_filters=-nomsan
Loading