Conversation
Signed-off-by: AU_gdev_19 <64915515+Dargon789@users.noreply.github.com>
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
|
|
This comment was marked as resolved.
This comment was marked as resolved.
Reviewer's GuideThis PR extends the GitHub Actions workflow by inserting a new "validate" job that checks commit message format and enforces file path restrictions before proceeding with the distribution publish process. Sequence Diagram for the New 'validate' Job LogicsequenceDiagram
participant Runner as GitHub Actions Runner
participant Git
participant ScriptEngine as Bash Shell
Runner->>Git: checkout@v3 (Checkout code)
activate Runner
activate Git
Git-->>Runner: Code checked out
deactivate Git
Runner->>ScriptEngine: Execute "Validate commit messages" script
activate ScriptEngine
ScriptEngine->>Git: git log -1 --pretty=%B
activate Git
Git-->>ScriptEngine: Last commit message
deactivate Git
ScriptEngine->>ScriptEngine: grep -E '^(feat|fix|docs|chore|test|refactor): .+'
alt Commit message invalid
ScriptEngine-->>Runner: Exit 1 (Fail)
else Commit message valid
ScriptEngine-->>Runner: Exit 0 (Success)
end
deactivate ScriptEngine
Runner->>ScriptEngine: Execute "Validate file paths" script
activate ScriptEngine
ScriptEngine->>Git: git diff --name-only HEAD~1
activate Git
Git-->>ScriptEngine: Changed file paths
deactivate Git
ScriptEngine->>ScriptEngine: grep -vE '^src|test|config/'
alt Invalid file paths found
ScriptEngine-->>Runner: Echo "Invalid file paths..." & Exit 1 (Fail)
else All file paths valid
ScriptEngine-->>Runner: Exit 0 (Success)
end
deactivate ScriptEngine
deactivate Runner
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
🎉 Snyk checks have passed. No issues have been found so far.✅ code/snyk check is complete. No issues have been found. (View Details) |
There was a problem hiding this comment.
Hey @Dargon789 - I've reviewed your changes - here's some feedback:
- The commit message validation only checks the most recent commit—consider looping over all PR commits (e.g. git log ${{ github.event.pull_request.base.sha }}..HEAD) to enforce your convention across the entire branch.
- Similarly, the file-path check uses git diff HEAD~1 which misses files changed earlier in the PR—diff against the base branch or use the PR merge commit range to catch all affected paths.
- Add
needs: validateto downstream jobs (like your publish steps) so they only run if these validation checks pass.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The commit message validation only checks the most recent commit—consider looping over all PR commits (e.g. git log ${{ github.event.pull_request.base.sha }}..HEAD) to enforce your convention across the entire branch.
- Similarly, the file-path check uses git diff HEAD~1 which misses files changed earlier in the PR—diff against the base branch or use the PR merge commit range to catch all affected paths.
- Add `needs: validate` to downstream jobs (like your publish steps) so they only run if these validation checks pass.
## Individual Comments
### Comment 1
<location> `.github/workflows/publish-dists.yml:97` </location>
<code_context>
+
+ - name: Validate commit messages
+ run: |
+ git log -1 --pretty=%B | grep -E '^(feat|fix|docs|chore|test|refactor): .+' || exit 1
+
+ - name: Validate file paths
</code_context>
<issue_to_address>
Only validating the latest commit message
For multi-commit pushes or PRs, iterate over all commits in the range (e.g., `git log ${{ github.event.before }}..HEAD --pretty=format:%s`) to validate every commit message.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
- name: Validate commit messages
run: |
git log -1 --pretty=%B | grep -E '^(feat|fix|docs|chore|test|refactor): .+' || exit 1
=======
- name: Validate commit messages
run: |
commit_range="${{ github.event.before }}..HEAD"
git log $commit_range --pretty=format:%s | while read -r msg; do
echo "$msg" | grep -E '^(feat|fix|docs|chore|test|refactor): .+' || { echo "Invalid commit message: $msg"; exit 1; }
done
>>>>>>> REPLACE
</suggested_fix>
### Comment 2
<location> `.github/workflows/publish-dists.yml:101` </location>
<code_context>
+
+ - name: Validate file paths
+ run: |
+ invalid_files=$(git diff --name-only HEAD~1 | grep -vE '^src|test|config/')
+ if [ -n "$invalid_files" ]; then
+ echo "Invalid file paths: $invalid_files"
</code_context>
<issue_to_address>
Anchor regex to directory prefixes
The current regex (`^src|test|config/`) will also match files like `srcfile.txt`. Update the pattern to `^(src/|test/|config/)` to match only the intended directories.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
invalid_files=$(git diff --name-only HEAD~1 | grep -vE '^src|test|config/')
=======
invalid_files=$(git diff --name-only HEAD~1 | grep -vE '^(src/|test/|config/)')
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…in permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: AU_gdev_19 <64915515+Dargon789@users.noreply.github.com>
|
Deployment failed with the following error: |
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> Signed-off-by: AU_gdev_19 <64915515+Dargon789@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> Signed-off-by: AU_gdev_19 <64915515+Dargon789@users.noreply.github.com>
|
Deployment failed with the following error: |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Add a new validation job to the publish-dists GitHub Actions workflow to enforce commit message and file path standards.
CI:
validatejob running on Ubuntu to verify commit messages follow conventional commit prefixes.src,test, orconfigdirectories.