Skip to content

Commit

Permalink
ci, Makefile: add make rule to check bazel prepare (#38818)
Browse files Browse the repository at this point in the history
close #38817
  • Loading branch information
YangKeao authored Nov 2, 2022
1 parent e1b2f7c commit 8db7c3b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

include Makefile.common

.PHONY: all clean test server dev benchkv benchraw check checklist parser tidy ddltest build_br build_lightning build_lightning-ctl build_dumpling ut bazel_build bazel_prepare bazel_test check-file-perm bazel_lint
.PHONY: all clean test server dev benchkv benchraw check checklist parser tidy ddltest build_br build_lightning build_lightning-ctl build_dumpling ut bazel_build bazel_prepare bazel_test check-file-perm check-bazel-prepare bazel_lint

default: server buildsucc

Expand All @@ -31,7 +31,7 @@ dev: checklist check explaintest gogenerate br_unit_test test_part_parser_dev ut
# Install the check tools.
check-setup:tools/bin/revive

check: parser_yacc check-parallel lint tidy testSuite errdoc
check: parser_yacc check-parallel lint tidy testSuite errdoc check-bazel-prepare

fmt:
@echo "gofmt (simplify)"
Expand Down Expand Up @@ -393,6 +393,10 @@ bazel_prepare:
bazel run //:gazelle
bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro DEPS.bzl%go_deps -build_file_proto_mode=disable

check-bazel-prepare:
@echo "make bazel_prepare"
./tools/check/check-bazel-prepare.sh

bazel_test: failpoint-enable bazel_ci_prepare
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) \
-- //... -//cmd/... -//tests/graceshutdown/... \
Expand Down
31 changes: 31 additions & 0 deletions tools/check/check-bazel-prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# Copyright 2022 PingCAP, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# set is used to set the environment variables.
# -e: exit immediately when a command returning a non-zero exit code.
# -u: treat unset variables as an error.
# -o pipefail: sets the exit code of a pipeline to that of the rightmost command to exit with a non-zero status,
# or to zero if all commands of the pipeline exit successfully.
set -euo pipefail

before_checksum=`find . -type f \( -name *.bazel -o -name *.bzl \) -exec md5sum {} \;| sort -k 2`
make bazel_prepare
after_checksum=`find . -type f \( -name *.bazel -o -name *.bzl \) -exec md5sum {} \;| sort -k 2`
if [ "$before_checksum" != "$after_checksum" ]
then
echo "Please run \`make bazel_prepare\` to update \`.bazel\` files"
diff <(echo "$before_checksum") <(echo "$after_checksum")
exit 1
fi

0 comments on commit 8db7c3b

Please sign in to comment.