git - 如何知道受 git commit 影响的所有 Bazel 目标?

标签 git bazel

git commit 可能会改变一些 workspace rules ,一些源文件,.bazelrc 等。如何让所有 Bazel 目标受到影响,从而需要在此类更改后重建和测试?

在 Buck 中,我们可以运行 buck targets --show-rulekey //...查看两个 Git 修订版之间的所有规则键更改。 Bazel 中是否有任何等效的命令?

最佳答案

here :

# Under Apache 2.0 licence
COMMIT_RANGE=${COMMIT_RANGE:-$(git merge-base origin/master HEAD)".."}

# Go to the root of the repo
cd "$(git rev-parse --show-toplevel)"

# Get a list of the current files in package form by querying Bazel.
files=()
for file in $(git diff --name-only ${COMMIT_RANGE} ); do
  files+=($(bazel query $file))
  echo $(bazel query $file)
done

# Query for the associated buildables
buildables=$(bazel query \
    --keep_going \
    --noshow_progress \
    "kind(.*_binary, rdeps(//..., set(${files[*]})))")
# Run the tests if there were results
if [[ ! -z $buildables ]]; then
  echo "Building binaries"
  bazel build $buildables
fi

tests=$(bazel query \
    --keep_going \
    --noshow_progress \
    "kind(test, rdeps(//..., set(${files[*]}))) except attr('tags', 'manual', //...)")
# Run the tests if there were results
if [[ ! -z $tests ]]; then
  echo "Running tests"
  bazel test $tests
fi
也看看 bazel-diff .

关于git - 如何知道受 git commit 影响的所有 Bazel 目标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55578905/

相关文章:

c++ - 如何在 bazel 中同时处理外部依赖项和我的项目?

java - 如何让 Bazel 包含与主机不同架构的 JRE?

java - bazel:sema注释和子目录

kubernetes - rules_k8s - k8s_deploy 模板离开图像

git - 我的 commit-msg Hook - 使用完整编辑器时,注释会添加到提交消息中

git - 如何使用 GIT 自动跟踪文件名更改?

git - 如何在 cygwin 上构建和使用最新版本的 git?

Tensorflow 构建错误

windows - Windows 版 Git 不执行我的 .bashrc 文件

git - 如何在 Groovyscript 中导入 Jenkins 插件?