]> git.apps.os.sepia.ceph.com Git - ceph-build.git/commitdiff
ceph-pr-commits: add a doc_test checking title of commit message 1680/head
authorKefu Chai <kchai@redhat.com>
Tue, 6 Oct 2020 16:14:15 +0000 (00:14 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 6 Oct 2020 16:39:46 +0000 (00:39 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
ceph-pr-commits/build/build
ceph-pr-commits/build/conftest.py
ceph-pr-commits/build/test_commits.py

index 326791a65cfe9b76dc0f400f176e769083113d55..504b7bcaa34e69807d7762f601c0d69065e480ab 100644 (file)
@@ -14,7 +14,7 @@ if git rev-parse --verify ${GIT_COMMIT}^2; then
          pytest_mark="code_test"
      else
          echo "Only the doc/ dir changed.  No need to check for signed commits."
-         pytest_mark="not code_test"
+         pytest_mark="doc_test"
      fi
 fi
 popd
index 5ec09260e7d1132b359996dfd2efd51cc7730854..f5feed0c7cc7fd7976820c5d744754d8633349d3 100644 (file)
@@ -5,6 +5,9 @@ def pytest_configure(config):
     config.addinivalue_line(
         "markers", "code_test: mark test to run against code related changes"
     )
+    config.addinivalue_line(
+        "markers", "doc_test: mark test to run against doc only changes"
+    )
 
 
 def pytest_addoption(parser):
index b23988f27e264693b38ea961435c3d750ff7a956..315a80024ea227134f2e85eec131391a378b542f 100644 (file)
@@ -35,6 +35,23 @@ class TestCommits(object):
             'git fetch origin +refs/heads/{target_branch}:refs/remotes/origin/{target_branch}'.format(
                 target_branch=cls.target_branch))
 
+    @pytest.mark.doc_test
+    def test_doc_title(self):
+        doc_regex = '\nDate:[^\n]+\n\n    doc'
+        all_commits = 'git log -z --no-merges origin/%s..%s' % (
+            self.target_branch, self.source_branch)
+        wrong_commits = list(filterfalse(
+            re.compile(doc_regex).search,
+            self.command(all_commits).split('\0')))
+        if wrong_commits:
+            raise AssertionError("\n".join([
+                "The title/s of following commit/s is/are not started with 'doc', but they only touch files under 'doc/'. Please make sure the commit titles",
+                "are started with 'doc'. See the 'Submitting Patches' guide:",
+                "https://github.com/ceph/ceph/blob/master/SubmittingPatches.rst#commit-title",
+                ""] +
+                wrong_commits
+            ))
+
     @pytest.mark.code_test
     def test_signed_off_by(self):
         signed_off_regex = r'Signed-off-by: \S.* <[^@]+@[^@]+\.[^@]+>'