|
37 | 37 | sudo apt-get autoremove -y |
38 | 38 | sudo apt-get autoclean -y |
39 | 39 |
|
40 | | - # Value of `github.workspace` is /home/runner/work/{repo_name}/{repo-name} |
41 | | - # i.e. /home/runner/work/TensorRT-Incubator/TensorRT-Incubator in our case. |
42 | | - # After this action, repo is cloned inside above path. |
43 | | - - uses: actions/checkout@v4 |
44 | | - with: |
45 | | - fetch-depth: 5 |
46 | | - |
47 | | - - name: Validate commit message |
48 | | - if: ${{ github.event_name == 'pull_request' }} |
49 | | - env: |
50 | | - PR_HEAD_COMMIT_SHA: ${{ github.event.pull_request.head.sha }} |
51 | | - run: | |
52 | | - cat > commit_message_checker.py <<EOF |
53 | | - #!/usr/bin/python3 |
54 | | - import re |
55 | | - import sys |
56 | | - import subprocess |
57 | | -
|
58 | | - git_cmd = f"git show -s --format=%B {sys.argv[1]}" |
59 | | - try: |
60 | | - commit_message_cmd = subprocess.run(git_cmd.split(' '), capture_output=True, text=True, check=True) |
61 | | - commit_message = commit_message_cmd.stdout.strip() |
62 | | - except subprocess.CalledProcessError as e: |
63 | | - print(f"Failed to get PR HEAD commit message with error: {e.stderr.strip()}") |
64 | | -
|
65 | | - match = re.search(r"^(\[bot\].+|NFC: .+|(.+\n\n+.+\n+.+))$", commit_message, re.DOTALL) |
66 | | - if match: |
67 | | - print("Commit message is in canonical form :)") |
68 | | - sys.exit(0) |
69 | | - print("Commit message is not in the canonical form!") |
70 | | - print(commit_message) |
71 | | - print("") |
72 | | - print("Expected format is, ") |
73 | | - print("<title>") |
74 | | - print("<body>") |
75 | | - print("NOTE: Body should start on new line. '2 spaces + enter' for new line!") |
76 | | - print("NOTE: Body should be at least two lines.") |
77 | | - sys.exit(1) |
78 | | - EOF |
79 | | -
|
80 | | - python3 commit_message_checker.py ${PR_HEAD_COMMIT_SHA} |
81 | | -
|
82 | 40 | # Run initial format check |
83 | 41 | - name: Run python format and clang check |
84 | 42 | uses: addnab/docker-run-action@v3 |
|
0 commit comments