diff --git a/.github/workflows/labeler.yaml b/.github/workflows/labeler.yaml new file mode 100644 index 0000000..4330491 --- /dev/null +++ b/.github/workflows/labeler.yaml @@ -0,0 +1,81 @@ +name: PR Labeler + +on: + pull_request: + types: [opened, synchronize] + branches: + - develop + +jobs: + labeler: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Fetch all branches + run: git fetch --all + + - name: Extract commit messages + run: | + COMMITS=$(git log --format=%B origin/develop..HEAD) + echo "$COMMITS" + echo "$COMMITS" > commits.txt + + - name: Debug - Print commits + run: cat commits.txt + + - name: Set labels based on commit messages + id: set-labels + run: | + labels=() + while IFS= read -r commit; do + echo "Processing commit: $commit" + if [[ $commit =~ ^feat ]]; then + labels+=("feature") + elif [[ $commit =~ ^fix ]]; then + labels+=("bugfix") + elif [[ $commit =~ ^docs ]]; then + labels+=("documentation") + elif [[ $commit =~ ^style ]]; then + labels+=("style") + elif [[ $commit =~ ^refactor ]]; then + labels+=("refactor") + elif [[ $commit =~ ^test ]]; then + labels+=("test") + elif [[ $commit =~ ^ci ]]; then + labels+=("ci") + elif [[ $commit =~ ^chore ]]; then + labels+=("chore") + fi + done < commits.txt + + # Remove duplicate labels and join them as a newline-separated string + unique_labels=$(printf "%s\n" "${labels[@]}" | sort -u) + + # Debug output for unique labels + echo "Unique labels:" + echo "$unique_labels" + + # Set the output as a newline-separated string + echo "labels<> $GITHUB_OUTPUT + echo "$unique_labels" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Add labels to PR + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: ${{ steps.set-labels.outputs.labels }} + + - name: Assign PR creator + uses: actions/github-script@v6 + with: + script: | + await github.rest.issues.addAssignees({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + assignees: [context.actor] + }) diff --git a/.gitmessage b/.gitmessage new file mode 100644 index 0000000..75439b9 --- /dev/null +++ b/.gitmessage @@ -0,0 +1,18 @@ +# Overview (Uncomment one of the following templates) +#feat: +# └ A new feature +#fix: +# └ A bug fix +#docs: +# └ Documentation only changes +#style: +# └ Changes that do not affect the meaning of the code +# (white-space, formatting, missing semi-colons, etc) +#refactor: +# └ A code change that neither fixes a bug nor adds a featur +#test: +# └ Adding missing or correcting existing tests +#ci: +# └ Changes to our CI configuration files and scripts +#chore: +# └ Updating grunt tasks etc; no production code change diff --git a/.vscode/settings.json b/.vscode/settings.json index 2476714..182c0b8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -59,6 +59,9 @@ "icon": "issue-closed" } }, + "files.associations": { + ".gitmessage": "plaintext" + }, "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true, "python.testing.autoTestDiscoverOnSaveEnabled": true, diff --git a/docs/en/developer_guidelines/index.md b/docs/en/developer_guidelines/index.md index b2d3caa..a92b9fc 100644 --- a/docs/en/developer_guidelines/index.md +++ b/docs/en/developer_guidelines/index.md @@ -44,7 +44,67 @@ While there are no strict rules, the following naming conventions are recommende - `bugfix/xxx`: (xxx represents the bug being fixed) - `hotfix/xxx`: (xxx represents the urgent fix) -### Merging +## Conventional Commits + +The commit messages should preferably follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) guidelines. + +### Commit Message Format + +By using `.gitmessage`, a template for commit messages is provided. This template can be enabled locally for this project by configuring `git config --local`. + +```bash +git config --local commit.template .gitmessage +``` + +Once configured, running `git commit` will display the contents of `.gitmessage` in your editor (Vim by default). + +```bash +git commit +# Overview (Uncomment one of the following templates) +#feat: +# └ A new feature +#fix: +# └ A bug fix +#docs: +# └ Documentation only changes +#style: +# └ Changes that do not affect the meaning of the code +# (white-space, formatting, missing semi-colons, etc) +#refactor: +# └ A code change that neither fixes a bug nor adds a featur +#test: +# └ Adding missing or correcting existing tests +#ci: +# └ Changes to our CI configuration files and scripts +#chore: +# └ Updating grunt tasks etc; no production code change + +``` + +Select the appropriate template and uncomment it, then write your commit message. + +```bash +docs: Update README.md +# └ Documentation only changes +``` + +## Correspondence between Commit Messages and Labels + +When creating a PR to the `develop` branch, labels are automatically assigned based on the commit messages. +Below is the correspondence between prefixes and labels: + +| Prefix | Label | Description | +|---|---|---| +|feat: | `feature` | Adding a new feature | +|fix: | `bugfix` | Bug fixes | +|docs: | `documentation` | Documentation only changes | +|style: | `style` | Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) | +|refactor: | `refactor` | Code changes that neither fix a bug nor add a feature | +|test: | `test` | Adding or correcting existing tests | +|ci: | `ci` | Adding or updating CI configuration and scripts | +|chore: | `chore` | Minor changes or maintenance tasks | + +## Merging Follow the principles below for merging: diff --git a/docs/ja/developer_guidelines/index.md b/docs/ja/developer_guidelines/index.md index e856deb..07a0d20 100644 --- a/docs/ja/developer_guidelines/index.md +++ b/docs/ja/developer_guidelines/index.md @@ -44,6 +44,67 @@ gitGraph LR: - `bugfix/xxx`: (xxxはバグ修正の内容) - `hotfix/xxx`: (xxxは緊急修正の内容) +## コミットメッセージ + +コミットメッセージは[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)に従うことが望ましいです。 + +### コミットメッセージのフォーマット + +.gitmessageを利用することでコミットメッセージのテンプレートを提供します。 +これは`git config --local`に設定することで、本プロジェクト内でのみ有効になります。 + +```bash +git config --local commit.template .gitmessage +``` + +この設定を行うことで、`git commit`を実行した際に`.gitmessage`の内容がエディタ(デフォルトではVim)に表示されます。 + +```bash +git commit +# Overview (Uncomment one of the following templates) +#feat: +# └ A new feature +#fix: +# └ A bug fix +#docs: +# └ Documentation only changes +#style: +# └ Changes that do not affect the meaning of the code +# (white-space, formatting, missing semi-colons, etc) +#refactor: +# └ A code change that neither fixes a bug nor adds a featur +#test: +# └ Adding missing or correcting existing tests +#ci: +# └ Changes to our CI configuration files and scripts +#chore: +# └ Updating grunt tasks etc; no production code change + +``` + +適切なテンプレートを選択し、コメントアウトをはずしてコミットメッセージを記述してください。 + +```bash +docs: Update README.md +# └ Documentation only changes +``` + +## コミットメッセージとラベルの対応 + +`develop`ブランチへのPRを作成するときにコミットメッセージからラベルを自動で付与するように設定しています。 +以下、プレフィックスとラベルの対応です。 + +| プレフィックス | ラベル | 説明| +|---|---|---| +|feat: | `feature` | 新機能の追加| +|fix: | `bugfix` | バグの修正| +|docs: | `documentation` | ドキュメントのみの変更| +|style: | `style` | コードの意味に影響を与えない変更(空白、フォーマット、セミコロンの欠落など)| +|refactor: | `refactor` | バグの修正や機能の追加を行わないコードの変更| +|test: | `test` | テストの追加、修正| +|ci: | `ci` | CIの追加、修正| +|chore: | `chore` | 些末な変更 | + ### マージ 以下の原則に従ってマージを行います。