Compare commits

...

23 Commits

Author SHA1 Message Date
Yanqin Jin
e03d17b766 Address comments 2020-04-30 14:15:57 -07:00
Yanqin Jin
4f805963f7 Cleanup more 2020-04-29 20:39:00 -07:00
Yanqin Jin
bef206613a Remove tmate debugging session 2020-04-29 20:27:49 -07:00
Yanqin Jin
64b3bbf1c9 Cleanup 2020-04-29 20:21:18 -07:00
Yanqin Jin
cf23a7cd16 Fix typo 2020-04-29 15:15:24 -07:00
Yanqin Jin
3c570016cd Fetch all history 2020-04-29 15:10:40 -07:00
Yanqin Jin
fcc66154fa Try to debug with tmate 2020-04-29 14:57:32 -07:00
Yanqin Jin
f03d14b000 Fetch origin 2020-04-29 11:34:17 -07:00
Yanqin Jin
ad71ee3c42 Change tracking 2020-04-29 11:32:23 -07:00
Yanqin Jin
e10008f339 More verbose 2020-04-29 11:17:38 -07:00
Yanqin Jin
2b8a4125c6 Git merge 2020-04-29 11:12:56 -07:00
Yanqin Jin
3a2b72ab07 Add more git print 2020-04-29 11:00:58 -07:00
Yanqin Jin
cccd1d6ef3 Print merge base 2020-04-29 10:57:38 -07:00
Yanqin Jin
6218435b37 Add debug 2020-04-29 10:51:06 -07:00
Yanqin Jin
927f3e0b47 Add a debug step 2020-04-29 10:46:45 -07:00
Yanqin Jin
3e4d51953a Fix typo 2020-04-29 10:41:54 -07:00
Yanqin Jin
513297ecb8 Add more debug 2020-04-29 10:39:16 -07:00
Yanqin Jin
af12dc0839 Add more debug print 2020-04-29 10:25:56 -07:00
Yanqin Jin
f646eb00e8 Fix typo 2020-04-29 09:57:02 -07:00
Yanqin Jin
7dc4c2c7ea Update GH Action config 2020-04-29 08:02:16 -07:00
Yanqin Jin
f0e3ed6e88 Add format-check and buckifier check to make check 2020-04-29 08:02:16 -07:00
Yanqin Jin
4f017d8944 Update format-diff.sh 2020-04-29 07:57:26 -07:00
Yanqin Jin
65af81b6cb Add Github Action for some basic sanity test of PR
Summary:
Add Github Action to perform some basic sanity check for PR, inclding the
following.
1) Buck TARGETS file.
On the one hand, The TARGETS file is used for internal buck, and we do not
manually update it. On the other hand, we need to run the buckifier scripts to
update TARGETS whenever new files are added, etc. With this Github Action, we
make sure that every PR does not forget this step. The GH Action uses
a Makefile target called check-buck-targets. Users can manually run `make
check-buck-targets` on local machine.

2) Code format
We use clang-format-diff.py to format our code. The GH Action in this PR makes
sure this step is not skipped. This GH Action does not use the Makefile target
called "make format" because "make format" currently runs
build_tools/format-diff.sh which requires clang-format-diff.py to be
executable. The clang-format-diff.py on our dev servers are not python3
compatible either.
On host running GH Action, it is difficult to download a file and make it
executable. Modifying build_tools/format-diff.sh is less necessary, especially
since the command we actually use for format checking is quite simple, as
illustrated in the workflow definition.

Test Plan:
Watch for Github Action result.
2020-04-27 10:52:24 -07:00
4 changed files with 130 additions and 12 deletions

41
.github/workflows/sanity_check.yml vendored Normal file
View File

@ -0,0 +1,41 @@
name: Check buck targets and code format
on: [push, pull_request]
jobs:
check:
name: Check TARGETS file and code format
runs-on: ubuntu-latest
steps:
- name: Checkout feature branch
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Fetch from upstream
run: |
git remote add upstream https://github.com/facebook/rocksdb.git && git fetch upstream
- name: Where am I
run: |
echo git status && git status
echo "git remote -v" && git remote -v
echo git branch && git branch
- name: Setup Python
uses: actions/setup-python@v1
- name: Install Dependencies
run: python -m pip install --upgrade pip
- name: Install argparse
run: pip install argparse
- name: Download clang-format-diff.py
uses: wei/wget@v1
with:
args: https://raw.githubusercontent.com/llvm-mirror/clang/master/tools/clang-format/clang-format-diff.py
- name: Check format
run: make check-format
- name: Compare buckify output
run: make check-buck-targets

View File

@ -967,6 +967,8 @@ ifeq ($(filter -DROCKSDB_LITE,$(OPT)),)
sh tools/rocksdb_dump_test.sh
endif
endif
$(MAKE) check-format
$(MAKE) check-buck-targets
# TODO add ldb_tests
check_some: $(SUBSET)
@ -1187,6 +1189,12 @@ tags0:
format:
build_tools/format-diff.sh
check-format:
build_tools/format-diff.sh -c
check-buck-targets:
buckifier/check_buck_targets.sh
package:
bash build_tools/make_package.sh $(SHARED_MAJOR).$(SHARED_MINOR)

31
buckifier/check_buck_targets.sh Executable file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env bash
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# If clang_format_diff.py command is not specfied, we assume we are able to
# access directly without any path.
TGT_DIFF=`git diff TARGETS | head -n 1`
if [ ! -z "$TGT_DIFF" ]
then
echo "TARGETS file has uncommitted changes. Skip this check."
exit 0
fi
echo Backup original TARGETS file.
cp TARGETS TARGETS.bkp
python buckifier/buckify_rocksdb.py
TGT_DIFF=`git diff TARGETS | head -n 1`
if [ -z "$TGT_DIFF" ]
then
mv TARGETS.bkp TARGETS
exit 0
else
echo "Please run 'python buckifier/buckify_rocksdb.py' to update TARGETS file."
echo "Do not manually update TARGETS file."
mv TARGETS.bkp TARGETS
exit 1
fi

View File

@ -2,6 +2,30 @@
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# If clang_format_diff.py command is not specfied, we assume we are able to
# access directly without any path.
print_usage () {
echo "Usage:"
echo "format-diff.sh [OPTIONS]"
echo "-c: check only."
echo "-h: print this message."
}
while getopts ':ch' OPTION; do
case "$OPTION" in
c)
CHECK_ONLY=1
;;
h)
print_usage
exit 1
;;
?)
print_usage
exit 1
;;
esac
done
if [ -z $CLANG_FORMAT_DIFF ]
then
CLANG_FORMAT_DIFF="clang-format-diff.py"
@ -10,18 +34,28 @@ fi
# Check clang-format-diff.py
if ! which $CLANG_FORMAT_DIFF &> /dev/null
then
echo "You didn't have clang-format-diff.py and/or clang-format available in your computer!"
echo "You can download clang-format-diff.py by running: "
echo " curl --location http://goo.gl/iUW1u2 -o ${CLANG_FORMAT_DIFF}"
echo "You can download clang-format by running:"
echo " brew install clang-format"
echo " Or"
echo " apt install clang-format"
echo " This might work too:"
echo " yum install git-clang-format"
echo "Then, move both files (i.e. ${CLANG_FORMAT_DIFF} and clang-format) to some directory within PATH=${PATH}"
echo "and make sure ${CLANG_FORMAT_DIFF} is executable."
exit 128
if [ ! -f ./clang-format-diff.py ]
then
echo "You didn't have clang-format-diff.py and/or clang-format available in your computer!"
echo "You can download clang-format-diff.py by running: "
echo " curl --location http://goo.gl/iUW1u2 -o ${CLANG_FORMAT_DIFF}"
echo "You can download clang-format by running:"
echo " brew install clang-format"
echo " Or"
echo " apt install clang-format"
echo " This might work too:"
echo " yum install git-clang-format"
echo "Then, move both files (i.e. ${CLANG_FORMAT_DIFF} and clang-format) to some directory within PATH=${PATH}"
echo "and make sure ${CLANG_FORMAT_DIFF} is executable."
exit 128
else
if [ -x ./clang-format-diff.py ]
then
PATH=$PATH:.
else
CLANG_FORMAT_DIFF="python ./clang-format-diff.py"
fi
fi
fi
# Check argparse, a library that clang-format-diff.py requires.
@ -87,6 +121,10 @@ if [ -z "$diffs" ]
then
echo "Nothing needs to be reformatted!"
exit 0
elif [ $CHECK_ONLY ]
then
echo "Your change has unformatted code. Please run make format!"
exit 1
fi
# Highlight the insertion/deletion from the clang-format-diff.py's output