aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ci.yml5
-rw-r--r--Makefile7
-rw-r--r--docs/contributing.md11
-rwxr-xr-xtools/check-commits.sh42
-rwxr-xr-xtools/syz-env1
5 files changed, 64 insertions, 2 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e9c332cf9..0b4119e33 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -15,6 +15,9 @@ jobs:
uses: actions/checkout@v2
with:
path: gopath/src/github.com/google/syzkaller
+ # This is needed for tools/check-commits.sh
+ ref: ${{ github.event.pull_request.head.sha }}
+ fetch-depth: 100
# Caches everything in .cache dir, in partiuclar we want to cache go-build and golangci-lint stuff.
# For reference see:
# https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows#using-the-cache-action
@@ -25,6 +28,8 @@ jobs:
key: cache
# Run make presubmit_smoke.
- name: run
+ env:
+ GITHUB_PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: gopath/src/github.com/google/syzkaller/.github/workflows/run.sh syz-env make presubmit_smoke
# Upload coverage report to codecov.io. For reference see:
# https://github.com/codecov/codecov-action/blob/master/README.md
diff --git a/Makefile b/Makefile
index 19a40345b..1543b81e2 100644
--- a/Makefile
+++ b/Makefile
@@ -102,7 +102,7 @@ endif
bin/syz-extract bin/syz-fmt \
extract generate generate_go generate_sys \
format format_go format_cpp format_sys \
- tidy test test_race check_copyright check_language check_links check_diff \
+ tidy test test_race check_copyright check_language check_links check_diff check_commits \
presubmit presubmit_parallel clean
all: host target
@@ -265,7 +265,7 @@ presubmit:
presubmit_smoke:
$(MAKE) generate
- $(MAKE) -j100 check_diff check_copyright check_language check_links presubmit_build
+ $(MAKE) -j100 check_commits check_diff check_copyright check_language check_links presubmit_build
$(MAKE) test
presubmit_build:
@@ -342,6 +342,9 @@ check_copyright:
check_language:
./tools/check-language.sh
+check_commits:
+ ./tools/check-commits.sh
+
check_links:
python ./tools/check_links.py $$(pwd) $$(ls ./*.md; find ./docs/ -name '*.md')
diff --git a/docs/contributing.md b/docs/contributing.md
index 82453f790..164af916d 100644
--- a/docs/contributing.md
+++ b/docs/contributing.md
@@ -33,6 +33,15 @@ the problem you are solving and how it is solved.
`dir/path` is a relative path to the main dir this commit changes
(look at examples in the [commit history](https://github.com/google/syzkaller/commits/master)).
+If several packages/dirs are significantly affected, then the following format is allowed:
+```
+dir1/path1, dir2/path2: one-line description
+```
+Though, dirs should not be included if they have only minor changes.
+For pervasive changes the following format is allowed:
+```
+all: one-line description
+```
Please pay attention to punctuation. In particular:
@@ -40,6 +49,8 @@ Please pay attention to punctuation. In particular:
- There is *no dot* at the end of `one-line description`.
- `Extended multi-line description` is full English sentences with Capital letters and dots.
+Commit message line length is limited to 120 characters.
+
Also:
- If you commit fixes an issue, please include `Fixes #NNN` line into commit message
diff --git a/tools/check-commits.sh b/tools/check-commits.sh
new file mode 100755
index 000000000..e2734d3dd
--- /dev/null
+++ b/tools/check-commits.sh
@@ -0,0 +1,42 @@
+#!/usr/bin/env bash
+# Copyright 2020 syzkaller project authors. All rights reserved.
+# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+set -e
+
+# GITHUB_PR_BASE_SHA is exported in .github/workflows/ci.yml for pull requests.
+# If it is not set, check against refs/heads/master (presumably a local run),
+# otherwise skip the checks (presumably CI run on a fork commit).
+if [ "${GITHUB_PR_BASE_SHA}" == "" ]; then
+ GITHUB_PR_BASE_SHA="refs/heads/master"
+ HAVE_MASTER=0
+ git show-ref ${GITHUB_PR_BASE_SHA} 1>/dev/null 2>&1 || HAVE_MASTER=$?
+ if [[ HAVE_MASTER -ne 0 ]]; then
+ echo "skipping commit checks: GITHUB_PR_BASE_SHA is not set and ${GITHUB_PR_BASE_SHA} does not exist"
+ exit 0
+ fi
+fi
+
+COMMITS=0
+FAILED=""
+HASHES=$(git log --format="%h" ${GITHUB_PR_BASE_SHA}..HEAD)
+for HASH in ${HASHES}; do
+ ((COMMITS+=1))
+ SUBJECT=$(git show --format="%s" --no-patch ${HASH})
+ BODY=$(git show --format="%B" --no-patch ${HASH})
+ if ! [[ ${SUBJECT} =~ ^(([a-z0-9/_.-]+|Makefile|CONTRIBUTORS|README.md)(, )?)+:\ [a-z].+[^.]$ ]]; then
+ echo "##[error]Wrong commit subject format: '${SUBJECT}'.\
+ Please use 'main/affected/package: short change description'.\
+ See docs/contributing.md for details."
+ FAILED="1"
+ fi
+ LONGLINE='[^\
+]{121}'
+ if [[ ${BODY} =~ ${LONGLINE} ]]; then
+ echo "##[error]Please limit commit description line length to 120 characters."
+ echo "${BODY}"
+ FAILED="1"
+ fi
+done
+if [ "$FAILED" != "" ]; then exit 1; fi
+echo "$COMMITS commits checked for format style"
diff --git a/tools/syz-env b/tools/syz-env
index 182db8752..a6ffd0877 100755
--- a/tools/syz-env
+++ b/tools/syz-env
@@ -64,6 +64,7 @@ docker run \
--env FUZZIT_API_KEY \
--env GITHUB_REF \
--env GITHUB_SHA \
+ --env GITHUB_PR_BASE_SHA \
--env CI \
${DOCKERARGS[@]} \
gcr.io/syzkaller/${IMAGE} -c "$COMMAND"