git - 如何知道受 git commit 影响的所有 Bazel 目标?
问题描述
一次 git commit 可能会更改一些工作空间规则、一些源文件、.bazelrc 等。如何让所有 Bazel 目标受到影响,因此需要在更改后重新构建和测试?
在 Buck 中,我们可以运行buck targets --show-rulekey //...
以查看两个 Git 修订版之间的所有规则键更改。Bazel中是否有任何等效命令?
解决方案
见这里:
# 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。
推荐阅读
- sql - 删除具有 1 个 ID 的多个 DAT 值的“全部”DAT 值行,其中一个为“全部”
- import - 如何修复 Laravel Excel Reader 内存泄漏?
- html - 如何制作具有水平溢出的 CSS 网格?
- flutter - ExpandedPanelList 内部带有扩展小部件
- aws-lambda - 将 SES 交付、退回日志存储到 DynamoDB
- konvajs - Konva.js - 在时间间隔循环中绘制舞台
- reactjs - 登录后 Firebase 将文档存储到变量
- python - 多个数据框,具有不同的名称,使用 for 循环
- server - Laravel Session 未在实时服务器上设置,在本地工作正常
- python - 使用实际文件从 s3 模拟下载文件