4343 fetch-depth : 5
4444
4545 # Run initial format check
46- - name : Run python format and clang check
46+ - name : Run commit message, python format, and c++ clang format check
4747 uses : addnab/docker-run-action@v3
4848 with :
4949 image : ${{ env.DEFAULT_IMAGE }}
@@ -52,15 +52,41 @@ jobs:
5252 username : ${{ github.actor }}
5353 password : ${{ secrets.GITHUB_TOKEN }}
5454 # This step does two things
55- # 1. Check if Python files follow black format
56- # 2. Check if C++ files follow clang format
55+ # 1. Check if commit message is in the canonical format
56+ # 2. Check if Python files follow black format
57+ # 3. Check if C++ files follow clang format
5758 # NOTE: We are placed at the root directory ('/') inside the container.
5859 run : |
5960 cd tensorrt-incubator
6061 git config --global --add safe.directory /tensorrt-incubator
62+ cat > commit_message_checker.py <<EOF
63+ #!/usr/bin/python3
64+ import re
65+ import sys
66+ match = re.search(r"^(\[bot\].+|NFC: .+|(.+\n\n+.+\n+.+))$", sys.argv[1], re.DOTALL)
67+ if match:
68+ sys.exit(0)
69+ sys.exit(1)
70+ EOF
71+
6172 cat > run_format_check.sh <<EOF
6273 #!/bin/bash
6374 set -e
75+ head_commit_message=$(git rev-list --max-count=1 --format=%B --no-commit-header HEAD)
76+ python3 commit_message_checker.py "$head_commit_message"
77+ if [[ $? == 0 ]] ; then
78+ echo "Commit message is in the canonical form :)"
79+ else
80+ echo "Commit message is not in the canonical form!"
81+ echo "${head_commit_message}"
82+ echo ""
83+ echo "Expected format is, "
84+ echo "<subject>"
85+ echo ""
86+ echo "<body>"
87+ echo "body should be at least two lines."
88+ exit 1
89+ fi
6490 python3 -m black --check --exclude='.*\.pyi' mlir-tensorrt/test/
6591 python3 -m black --check --exclude='.*\.pyi' mlir-tensorrt/python/
6692 git clang-format HEAD~1 --diff
0 commit comments