Skip to content

Comments

Update publish-dists.yml#42

Merged
Dargon789 merged 4 commits intomasterfrom
Dargon789-patch-1
Jun 13, 2025
Merged

Update publish-dists.yml#42
Dargon789 merged 4 commits intomasterfrom
Dargon789-patch-1

Conversation

@Dargon789
Copy link
Owner

@Dargon789 Dargon789 commented Jun 13, 2025

Summary by Sourcery

Add a new validation job to the publish-dists GitHub Actions workflow to enforce commit message and file path standards.

CI:

  • Introduce a validate job running on Ubuntu to verify commit messages follow conventional commit prefixes.
  • Check changed file paths to allow only updates under src, test, or config directories.

Signed-off-by: AU_gdev_19 <64915515+Dargon789@users.noreply.github.com>
@codesandbox
Copy link

codesandbox bot commented Jun 13, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@vercel

This comment was marked as resolved.

@sourcery-ai
Copy link

sourcery-ai bot commented Jun 13, 2025

Reviewer's Guide

This 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 Logic

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Introduce a dedicated validation job in the publish-dists workflow
  • Define a new "validate" job running on ubuntu-latest
  • Add checkout step using actions/checkout@v3
  • Implement commit message format validation via grep
  • Implement file path validation to restrict changes to allowed directories
.github/workflows/publish-dists.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@snyk-io
Copy link

snyk-io bot commented Jun 13, 2025

🎉 Snyk checks have passed. No issues have been found so far.

code/snyk check is complete. No issues have been found. (View Details)

sourcery-ai[bot]
sourcery-ai bot previously approved these changes Jun 13, 2025
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: validate to 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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
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>
@vercel
Copy link

vercel bot commented Jun 13, 2025

Deployment failed with the following error:

Resource is limited - try again in 24 minutes (more than 100, code: "api-deployments-free-per-day").

Dargon789 and others added 2 commits June 13, 2025 19:39
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>
@vercel
Copy link

vercel bot commented Jun 13, 2025

Deployment failed with the following error:

Resource is limited - try again in 23 minutes (more than 100, code: "api-deployments-free-per-day").

@Dargon789 Dargon789 merged commit 682994e into master Jun 13, 2025
14 of 15 checks passed
@Dargon789 Dargon789 deleted the Dargon789-patch-1 branch June 13, 2025 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant