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.
This commit is contained in:
parent
3b2f2719eb
commit
65af81b6cb
48
.github/workflows/sanity_check.yml
vendored
Normal file
48
.github/workflows/sanity_check.yml
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
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
|
||||
|
||||
- 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
|
||||
|
||||
- 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: Compute merge base between PR and upstream/master
|
||||
id: merge_base
|
||||
run: |
|
||||
echo "::set-output name=MERGE_BASE::$(git merge-base upstream/master HEAD)"
|
||||
|
||||
- name: Format diff
|
||||
id: format_diff
|
||||
run: |
|
||||
echo "::set-output name=FORMAT_DIFF_OUTPUT::$(git diff -U0 ${{steps.merge_base.outputs.MERGE_BASE}} | python clang-format-diff.py -p 1 | head -n 1)"
|
||||
|
||||
- name: Check format
|
||||
run: |
|
||||
if [ -z "${{steps.format_diff.outputs.FORMAT_DIFF_OUTPUT}}" ]; then exit 0; else exit 1; fi
|
||||
|
||||
- name: Compare buckify output
|
||||
run: make check-buck-targets
|
13
Makefile
13
Makefile
@ -1187,6 +1187,19 @@ tags0:
|
||||
format:
|
||||
build_tools/format-diff.sh
|
||||
|
||||
buck-targets:
|
||||
python buckifier/buckify_rocksdb.py
|
||||
|
||||
check-buck-targets: buck-targets
|
||||
$(eval TMP=$(shell bash -c "git diff TARGETS | head -n 1"))
|
||||
@echo Running git diff on TARGETS, and the first line of output is...
|
||||
@echo $(TMP)
|
||||
@if [ -z "$(TMP)" ]; then \
|
||||
exit 0; \
|
||||
else \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
package:
|
||||
bash build_tools/make_package.sh $(SHARED_MAJOR).$(SHARED_MINOR)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user