-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[workflow] Add a workflow to enforce PR title format (#1219)
* [skip ci] [workflow] Add a workflow to enforce PR title format * [skip ci] fix yml syntax * [skip ci] fix typo * [skip ci] enforce code format * [skip ci] trig * [skip ci] bad * [skip ci] bad2 * [skip ci] good * [skip ci] Update contributor_guide * [skip ci] enforce code format * [skip ci] no duplicate uppercase tag like #1189 * [skip ci] Apply suggestions from code review Co-authored-by: Ye Kuang <k-ye@users.noreply.github.com> * [skip ci] * [skip ci] enforce code format * [skip ci] Apply suggestions from code review Co-authored-by: Chengchen(Rex) Wang <14366016+rexwangcc@users.noreply.github.com> * [skip ci] apply (json & exit) * [skip ci] enforce code format * [skip ci] Update .github/pull_request_template.md Co-authored-by: Chengchen(Rex) Wang <14366016+rexwangcc@users.noreply.github.com> * [skip ci] No colorama :( * [skip ci] enforce code format * [skip ci] Update docs/contributor_guide.rst Co-authored-by: Ye Kuang <k-ye@users.noreply.github.com> Co-authored-by: Taichi Gardener <taichigardener@gmail.com> Co-authored-by: Ye Kuang <k-ye@users.noreply.github.com> Co-authored-by: Chengchen(Rex) Wang <14366016+rexwangcc@users.noreply.github.com>
- Loading branch information
1 parent
434c5fa
commit c61c2c4
Showing
8 changed files
with
198 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,23 @@ | ||
<!-- Thank for your PR! If it's your first time contributing to Taichi, please make sure you have read Contributor Guideline(https://taichi.readthedocs.io/en/latest/contributor_guide.html) (last update: March 26, 2019). --> | ||
<!-- | ||
Thanks for your PR! | ||
If it's your first time contributing to Taichi, please make sure you have read our Contributor Guideline: | ||
https://taichi.readthedocs.io/en/latest/contributor_guide.html | ||
<!-- Please always prepend your PR title with tags such as [Metal], [CUDA], [Doc], [Example]. Use a lowercased tag (e.g. [cuda]), for PRs that are invisible to end-users (e.g. intermediate implementation). More details: http://taichi.readthedocs.io/en/latest/contributor_guide.html#prtags --> | ||
- Please always prepend your PR title with tags such as [CUDA], [Lang], [Doc], [Example], e.g.: | ||
[Lang] Add ti.Complex as Taichi class | ||
- Use a lowercased tag for PRs that are invisible to end-users, i.e., won't be highlighted in changelog: | ||
[cuda] [test] Fix out-of-memory error while running test | ||
- More details: http://taichi.readthedocs.io/en/latest/contributor_guide.html#prtags | ||
Related issue = #... (if any) | ||
- Please fill the following blank with the issue number this PR related to (if any): | ||
Related issue = #2345 | ||
- If your PR will fix the issue **completely**, use the `close` or `fixes` keyword: | ||
Related issue = close #2345 | ||
- So that when the PR gets merged, GitHub will **automatically** close the issue #2345 for you :) | ||
- If the PR doesn't belong to any existing issue, and this is a trivial change, feel free to leave it blank :) | ||
--> | ||
Related issue = # | ||
|
||
- [[Click here for the format server]](http://kun.csail.mit.edu:31415/) | ||
- [[Click here for coverage report]](http://codecov.io/gh/taichi-dev/taichi/) | ||
[[Click here for the format server]](http://kun.csail.mit.edu:31415/) | ||
|
||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
===== | ||
@ti.kernel | ||
def func(): pass | ||
|
||
|
||
===== | ||
func() | ||
|
||
===== | ||
func() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import sys, os, json | ||
|
||
title = sys.argv[1] | ||
print(f'Checking PR title: {title}') | ||
|
||
this_dir = os.path.dirname(os.path.abspath(__file__)) | ||
json_path = os.path.join(this_dir, 'prtags.json') | ||
with open(json_path) as f: | ||
prtags = json.load(f) | ||
|
||
if not title.startswith('['): | ||
exit(f'PR title does not start with any tag: {title}') | ||
|
||
if title.endswith(' '): | ||
exit(f'PR title should not end with a space: {title}') | ||
|
||
if title.endswith(']'): | ||
exit(f'PR title should have bodies regardless tags: {title}') | ||
|
||
if '`' in title: | ||
exit(f'PR title should not contain backquotes (`): {title}') | ||
|
||
for x in title.split(']')[1:]: | ||
if x[0] != ' ': | ||
exit(f'No space before: {x}') | ||
if x[1] == ' ': | ||
exit(f'Extra space before: {x[2:]}') | ||
|
||
x = title.split(']')[-1].strip() | ||
if x[0].islower(): | ||
exit(f'PR title should be uppercase at: {x}') | ||
|
||
had_upper = False | ||
for x in title.split('] ')[:-1]: | ||
if x[0] != '[': | ||
exit(f'No starting [ for tag: {x}]') | ||
if x[1:].lower() not in prtags.keys(): | ||
exit(f'Unrecognized PR tag: [{x[1:]}]') | ||
# 'Misc'.islower() -> False, 'Misc'.isupper() -> False | ||
# 'misc'.islower() -> True, 'misc'.isupper() -> False | ||
if not x[1:].islower(): | ||
if had_upper: | ||
exit(f'At most 1 uppercase tag expected, got: [{x[1:]}]') | ||
had_upper = True | ||
|
||
print('OK!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import sys, os | ||
from git import Repo | ||
|
||
commits = list(Repo('.').iter_commits('master')) | ||
|
||
authors = {} | ||
notable = {} | ||
changelog = {} | ||
|
||
for i, c in enumerate(commits): | ||
s = c.summary | ||
|
||
tags = [] | ||
while s[0] == '[': | ||
r = s.find(']') | ||
tag = s[1:r] | ||
tags.append(tag) | ||
s = s[r + 1:] | ||
s = s.strip() | ||
|
||
for tag in tags: | ||
if tag[0].isupper(): | ||
tag = tag.lower() | ||
notable[tag] = notable.get(tag, 0) + 1 | ||
changelog[tag] = changelog.get(tag, 0) + 1 | ||
|
||
a = str(c.author).split(' <')[0] | ||
authors[a] = authors.get(a, 0) + 1 | ||
|
||
|
||
def print_table(tab, name=''): | ||
print('') | ||
print(f' | {name} | counts |') | ||
print(' | :--- | ---: |') | ||
tab = sorted(tab.items(), key=lambda x: x[1], reverse=True) | ||
for a, n in tab: | ||
print(f' | {a} | {n} |') | ||
return tab | ||
|
||
|
||
print('Authors:') | ||
print_table(authors, 'author') | ||
print('') | ||
print('Highlights:') | ||
print_table(notable, 'tag') | ||
print('') | ||
print('Full changelog:') | ||
print_table(changelog, 'tag') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"cpu" : "CPU backends", | ||
"cuda" : "CUDA backend", | ||
"doc" : "Documentation", | ||
"infra" : "Infrastructure", | ||
"cli" : "Command line interface", | ||
"ir" : "Intermediate representation", | ||
"lang" : "Language and syntax", | ||
"metal" : "Metal backend", | ||
"opengl" : "OpenGL backend", | ||
"misc" : "Miscellaneous", | ||
"std" : "Standard library", | ||
"opt" : "IR optimization passes", | ||
"example" : "Examples", | ||
"pypi" : "PyPI package", | ||
"autodiff" : "Automatic differentiation", | ||
"sparse" : "Sparse computation", | ||
"gui" : "GUI", | ||
"llvm" : "LLVM backend (CPU and CUDA)", | ||
"refactor" : "Refactor", | ||
"bug" : "Bug fixes", | ||
"test" : "Tests", | ||
"benchmark" : "Benchmarking", | ||
"async" : "AsyncEngine", | ||
"workflow" : "GitHub Actions/Workflows", | ||
"linux" : "Linux", | ||
"mac" : "Mac OS X", | ||
"windows" : "Windows", | ||
"perf" : "Performance improvements", | ||
"release" : "Release" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters