Skip to content

feat(github,dotfiles): add CI to check PR title scope against changed files#148

Merged
shiron-dev merged 5 commits intomainfrom
feat/pr-scope-check-ci
Jul 6, 2025
Merged

feat(github,dotfiles): add CI to check PR title scope against changed files#148
shiron-dev merged 5 commits intomainfrom
feat/pr-scope-check-ci

Conversation

@shiron-dev
Copy link
Owner

This CI ensures that the scope(s) in a PR title accurately reflect the directories of the changed files.

It introduces:

  • A GitHub Actions workflow (.github/workflows/check_pr_scope.yml) to perform the check.
  • A configuration file (scope-rules.json) to define the mapping between file patterns and scopes.
  • A README.md explaining the CI's purpose and usage.

This CI ensures that the scope(s) in a PR title accurately reflect the directories of the changed files.

It introduces:
- A GitHub Actions workflow (`.github/workflows/check_pr_scope.yml`) to perform the check.
- A configuration file (`scope-rules.json`) to define the mapping between file patterns and scopes.
- A `README.md` explaining the CI's purpose and usage.
@github-actions
Copy link
Contributor

github-actions bot commented Jul 5, 2025

undefined

@shiron-dev shiron-dev changed the title feat(github): add CI to check PR title scope against changed files feat: add CI to check PR title scope against changed files Jul 6, 2025
Updates the PR scope check CI to post a comment on the pull request when the scope validation fails.

The comment details:
- If the PR title format is incorrect (missing scope).
- Which scopes are missing from the PR title based on changed files.

This provides immediate feedback to the PR author, making it easier to correct the PR title.

Also ensures README.md is correctly created and updated with this new behavior.
@shiron-dev shiron-dev force-pushed the feat/pr-scope-check-ci branch from 61a4dce to 91f321f Compare July 6, 2025 15:36
…ling

This commit addresses the issue where 'undefined' could appear in PR comments posted by the scope check CI.

Fixes include:
- Robust handling of empty PR titles, with specific error messages.
- Sanitization of PR titles to remove potential newline characters from jq output.
- Improved logic for constructing suggestion messages in comments, ensuring variables are correctly handled even if empty.
- Safe multi-line string assignment to GITHUB_ENV for the comment body using heredocs, preventing issues with special characters and newlines.

These changes ensure more reliable and informative feedback in PR comments when scope validation fails.
@shiron-dev shiron-dev force-pushed the feat/pr-scope-check-ci branch from 91f321f to 166d70a Compare July 6, 2025 15:37
@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2025

undefined

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2025

undefined

@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2025

undefined

@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2025

PRのスコープが正しくありません。
タイトル:
変更ファイル:

@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2025

PRのスコープが正しくありません。
現在のスコープ:
検知したスコープ:

@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2025

PRのスコープが正しくありません。
現在のスコープ:
検知したスコープ: .github/workflows/check_pr_scope.yml
README.md
scope-rules.json
scripts/check_pr_scope.sh

@shiron-dev shiron-dev changed the title feat: add CI to check PR title scope against changed files feat(a): add CI to check PR title scope against changed files Jul 6, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2025

PRのスコープが正しくありません。
現在のスコープ:
検知したスコープ: .github/workflows/check_pr_scope.yml
README.md
scope-rules.json
scripts/check_pr_scope.sh

@shiron-dev shiron-dev changed the title feat(a): add CI to check PR title scope against changed files feat(github): add CI to check PR title scope against changed files Jul 6, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2025

PRのスコープが正しくありません。
現在のスコープ:
検知したスコープ: .github/workflows/check_pr_scope.yml
README.md
scope-rules.json
scripts/check_pr_scope.sh

@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2025

PRのスコープが正しくありません。
現在のスコープ:
検知したスコープ:

2 similar comments
@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2025

PRのスコープが正しくありません。
現在のスコープ:
検知したスコープ:

@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2025

PRのスコープが正しくありません。
現在のスコープ:
検知したスコープ:

@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2025

PRのスコープが正しくありません。
現在のスコープ: feat(github): add CI to check PR title scope against changed files
検知したスコープ: github dotfiles

@shiron-dev shiron-dev changed the title feat(github): add CI to check PR title scope against changed files feat(github,dotfiles): add CI to check PR title scope against changed files Jul 6, 2025
@shiron-dev shiron-dev changed the title feat(github,dotfiles): add CI to check PR title scope against changed files feat(github,abc): add CI to check PR title scope against changed files Jul 6, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2025

PRのスコープが正しくありません。
現在のスコープ: feat(github,abc): add CI to check PR title scope against changed files
検知したスコープ: github dotfiles

@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2025

PRのスコープが正しくありません。
現在のスコープ: github abc
検知したスコープ: github dotfiles

@shiron-dev shiron-dev changed the title feat(github,abc): add CI to check PR title scope against changed files feat(*github,abc*): add CI to check PR title scope against changed files Jul 6, 2025
@shiron-dev shiron-dev changed the title feat(*github,abc*): add CI to check PR title scope against changed files feat(*): add CI to check PR title scope against changed files Jul 6, 2025
This commit updates the `.github/workflows/check_pr_scope.yml` file to:
- Upgrade the `actions/checkout` from v3 to v4 for improved functionality.
- Upgrade the `actions/github-script` from v6 to v7 for better performance.
- Enhance the handling of environment variables and multi-line string assignments for output consistency.

These changes aim to streamline the workflow and ensure compatibility with the latest GitHub Actions features.

refactor: improve PR scope check script for clarity and efficiency

This commit refactors the `check_pr_scope.sh` script to enhance readability and performance. Key changes include:
- Replaced the use of array assignment with `mapfile` for trimming whitespace from scopes.
- Simplified the reading of `scope-rules.json` using a direct `jq` command.
- Cleaned up conditional checks for scope matching to improve clarity.

These modifications aim to streamline the script's functionality and maintainability.

fix: enhance PR comment body handling in scope check workflow

This commit improves the GitHub Actions workflow for PR scope checks by:
- Adding a step to set the comment body with detailed information about scope validation failures.
- Updating the comment creation step to utilize the newly set comment body, ensuring accurate and informative feedback for PR authors.

These changes aim to provide clearer communication regarding scope issues in pull requests.

fix: update PR comment body for clarity in scope validation

This commit modifies the comment body in the PR scope check workflow to provide clearer information regarding scope validation failures. The changes include:
- Updating the wording to specify the current and detected scopes more explicitly.

These adjustments aim to enhance communication with PR authors about scope issues.

fix: enhance output handling in PR scope check workflow

This commit updates the `.github/workflows/check_pr_scope.yml` file to improve the output handling of the PR scope check job. Key changes include:
- Adding outputs for the PR title and changed files, allowing for more informative feedback in the workflow.
These enhancements aim to provide clearer context and details for PR authors regarding scope validation.

fix: improve multi-line string handling in PR scope check workflow

This commit updates the `.github/workflows/check_pr_scope.yml` file to enhance the handling of the comment body for PR scope validation failures. Key changes include:
- Utilizing a heredoc format for setting the comment body, allowing for clearer multi-line output.
- Ensuring that the message structure is more readable and maintains the intended formatting.

These improvements aim to provide better feedback to PR authors regarding scope issues.

fix: add required scopes output to PR scope check workflow

This commit enhances the GitHub Actions workflow for PR scope checks by:
- Adding the `required_scopes` output to the workflow, providing more detailed information about the scopes needed based on changed files.
- Updating the comment body to reflect the correct required scopes in case of validation failures.

These changes aim to improve feedback for PR authors regarding scope validation issues.

fix: add debug steps to PR scope check workflow

This commit enhances the GitHub Actions workflow for PR scope checks by:
- Adding debug steps to output the PR title and changed files before the scope check.
- Providing clearer visibility into the workflow's execution, aiding in troubleshooting and validation of inputs.

These changes aim to improve the debugging process for PR authors and maintainers.

fix: add debug output for PR title retrieval in scope check workflow

This commit enhances the GitHub Actions workflow by adding debug output steps to the PR title retrieval process. Key changes include:
- Printing the contents of `GITHUB_EVENT_PATH` and the output of the `jq` command to provide better visibility into the data being processed.
- This improvement aims to facilitate troubleshooting and ensure the correct PR title is being captured for scope validation.

fix: streamline PR title retrieval in scope check workflow

This commit simplifies the PR title retrieval process in the GitHub Actions workflow by:
- Removing unnecessary debug output for `GITHUB_EVENT_PATH` and `jq` command results.
- Directly capturing and echoing the PR title, enhancing clarity and reducing clutter in the workflow logs.

These changes aim to improve the efficiency of the workflow while maintaining essential output for debugging.

fix: update PR scope output handling in workflow and script

This commit enhances the GitHub Actions workflow and the associated script for PR scope checks by:
- Modifying the workflow to output `pr_scopes` instead of the PR title, providing more relevant information for scope validation.
- Adding the `pr_scopes` output to the `GITHUB_OUTPUT` in the script, ensuring it is available for subsequent steps.

These changes aim to improve the clarity and accuracy of the feedback provided to PR authors regarding scope validation issues.
@shiron-dev shiron-dev changed the title feat(*): add CI to check PR title scope against changed files feat(github,dotfiles): add CI to check PR title scope against changed files Jul 6, 2025
@shiron-dev shiron-dev force-pushed the feat/pr-scope-check-ci branch from aae6eb6 to 8a01b2e Compare July 6, 2025 16:12
This commit deletes the `README.md` file that provided an overview of the PR scope check CI, including its purpose, functionality, configuration, and troubleshooting steps. The removal is part of a cleanup effort to streamline documentation and may indicate a shift in how information is presented or maintained in the repository.
@shiron-dev shiron-dev enabled auto-merge (squash) July 6, 2025 16:12
@shiron-dev shiron-dev merged commit 82a17af into main Jul 6, 2025
10 checks passed
@shiron-dev shiron-dev deleted the feat/pr-scope-check-ci branch July 6, 2025 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant